vagrant-aws-alb-target-group 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +30 -0
- data/README.md +0 -0
- data/Rakefile +2 -0
- data/lib/vagrant-aws-alb-target-group.rb +6 -0
- data/lib/vagrant-aws-alb-target-group/action/add_instance.rb +18 -0
- data/lib/vagrant-aws-alb-target-group/action/base.rb +28 -0
- data/lib/vagrant-aws-alb-target-group/action/remove_instance.rb +18 -0
- data/lib/vagrant-aws-alb-target-group/config.rb +25 -0
- data/lib/vagrant-aws-alb-target-group/plugin.rb +47 -0
- data/lib/vagrant-aws-alb-target-group/util/aws_util.rb +52 -0
- data/lib/vagrant-aws-alb-target-group/version.rb +5 -0
- data/vagrant-aws-alb-target-group.gemspec +27 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6ae586dca9e87f26c8c140edb21228256299c93e
|
4
|
+
data.tar.gz: 9b0e4053341dee5bd8d75c86baa523f9a2d41fb7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: aa3673968a15de883dd300837274e3001bf772f1c92e7d0b37267cd3ad2d881834c099abc5c1f37d3c24664781fce6ea85db63d42fb295b32f08733d743bc1da
|
7
|
+
data.tar.gz: 6aa9ec8d015e33d6bb84a993a26363ca97017a0f308bacace2aac9ccbd3d1d37847fc1e66da1d018ff3b1774f45190271270e67912255d1f8762d9838901e4a7
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
vagrant-aws-alb-target-group (0.1.2)
|
5
|
+
aws-sdk (~> 2.6.44)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
aws-sdk (2.6.50)
|
11
|
+
aws-sdk-resources (= 2.6.50)
|
12
|
+
aws-sdk-core (2.6.50)
|
13
|
+
aws-sigv4 (~> 1.0)
|
14
|
+
jmespath (~> 1.0)
|
15
|
+
aws-sdk-resources (2.6.50)
|
16
|
+
aws-sdk-core (= 2.6.50)
|
17
|
+
aws-sigv4 (1.0.3)
|
18
|
+
jmespath (1.4.0)
|
19
|
+
rake (10.5.0)
|
20
|
+
|
21
|
+
PLATFORMS
|
22
|
+
ruby
|
23
|
+
|
24
|
+
DEPENDENCIES
|
25
|
+
bundler (~> 1.16)
|
26
|
+
rake (~> 10.0)
|
27
|
+
vagrant-aws-alb-target-group!
|
28
|
+
|
29
|
+
BUNDLED WITH
|
30
|
+
1.16.0
|
data/README.md
ADDED
File without changes
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative 'base'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module AwsAlbTargetGroup
|
5
|
+
module Action
|
6
|
+
class AddInstance < Base
|
7
|
+
|
8
|
+
def call(env)
|
9
|
+
super env do |instance_id, target_group_name|
|
10
|
+
@aws.add_instance(instance_id, target_group_name)
|
11
|
+
@machine.ui.info("Add instance #{instance_id} to #{target_group_name}.")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'aws-sdk'
|
2
|
+
require_relative '../util/aws_util'
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module AwsAlbTargetGroup
|
6
|
+
module Action
|
7
|
+
class Base
|
8
|
+
|
9
|
+
def initialize(app, env)
|
10
|
+
@app = app
|
11
|
+
@machine = env[:machine]
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(env)
|
15
|
+
return @app.call(env) if @machine.config.aws_alb.target_group_name.nil?
|
16
|
+
|
17
|
+
@aws = AwsAlbTargetGroup::Util::AwsUtil.new(@machine.provider_config.access_key_id,
|
18
|
+
@machine.provider_config.secret_access_key,
|
19
|
+
@machine.provider_config.region)
|
20
|
+
yield @machine.id, @machine.config.aws_alb.target_group_name if block_given?
|
21
|
+
|
22
|
+
@app.call(env)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative 'base'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module AwsAlbTargetGroup
|
5
|
+
module Action
|
6
|
+
class RemoveInstance < Base
|
7
|
+
|
8
|
+
def call(env)
|
9
|
+
super env do |instance_id, target_group_name|
|
10
|
+
@aws.remove_instance(instance_id, target_group_name)
|
11
|
+
@machine.ui.info("Remove instance #{instance_id} to #{target_group_name}.")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'vagrant'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module AwsAlbTargetGroup
|
5
|
+
class Config < Vagrant.plugin('2', :config)
|
6
|
+
attr_accessor :target_group_name
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@target_group_name = UNSET_VALUE
|
10
|
+
end
|
11
|
+
|
12
|
+
def finalize!
|
13
|
+
@target_group_name = nil if @target_group_name == UNSET_VALUE
|
14
|
+
end
|
15
|
+
|
16
|
+
def validate(machine)
|
17
|
+
finalize!
|
18
|
+
|
19
|
+
errors = _detected_errors
|
20
|
+
|
21
|
+
{ 'AwsAlbTargetGroup' => errors }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'vagrant'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module AwsAlbTargetGroup
|
5
|
+
class Plugin < Vagrant.plugin('2')
|
6
|
+
name 'aws-alb-target-group'
|
7
|
+
|
8
|
+
description <<-DESC
|
9
|
+
A Vagrant plugin that allows you to setup ALB Target Group.
|
10
|
+
DESC
|
11
|
+
|
12
|
+
config :aws_alb do
|
13
|
+
require_relative 'config'
|
14
|
+
Config
|
15
|
+
end
|
16
|
+
|
17
|
+
action_hook :add_instance, :machine_action_up do |hook|
|
18
|
+
require_relative 'action/add_instance'
|
19
|
+
hook.after VagrantPlugins::AWS::Action::RunInstance, VagrantPlugins::AwsAlbTargetGroup::Action::AddInstance
|
20
|
+
hook.after VagrantPlugins::AWS::Action::StartInstance, VagrantPlugins::AwsAlbTargetGroup::Action::AddInstance
|
21
|
+
end
|
22
|
+
|
23
|
+
action_hook :remove_instance, :machine_action_halt do |hook|
|
24
|
+
require_relative 'action/remove_instance'
|
25
|
+
hook.after VagrantPlugins::AWS::Action::StopInstance, VagrantPlugins::AwsAlbTargetGroup::Action::RemoveInstance
|
26
|
+
hook.after VagrantPlugins::AWS::Action::TerminateInstance, VagrantPlugins::AwsAlbTargetGroup::Action::RemoveInstance
|
27
|
+
end
|
28
|
+
|
29
|
+
action_hook :remove_instance, :machine_action_destroy do |hook|
|
30
|
+
require_relative 'action/remove_instance'
|
31
|
+
hook.before VagrantPlugins::AWS::Action::StopInstance, VagrantPlugins::AwsAlbTargetGroup::Action::RemoveInstance
|
32
|
+
hook.before VagrantPlugins::AWS::Action::TerminateInstance, VagrantPlugins::AwsAlbTargetGroup::Action::RemoveInstance
|
33
|
+
end
|
34
|
+
|
35
|
+
action_hook :add_instance, :machine_action_reload do |hook|
|
36
|
+
require_relative 'action/remove_instance'
|
37
|
+
hook.after VagrantPlugins::AWS::Action::StopInstance, VagrantPlugins::AwsAlbTargetGroup::Action::RemoveInstance
|
38
|
+
hook.after VagrantPlugins::AWS::Action::TerminateInstance, VagrantPlugins::AwsAlbTargetGroup::Action::RemoveInstance
|
39
|
+
|
40
|
+
require_relative 'action/add_instance'
|
41
|
+
hook.after VagrantPlugins::AWS::Action::RunInstance, VagrantPlugins::AwsAlbTargetGroup::Action::AddInstance
|
42
|
+
hook.after VagrantPlugins::AWS::Action::StartInstance, VagrantPlugins::AwsAlbTargetGroup::Action::AddInstance
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'aws-sdk'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module AwsAlbTargetGroup
|
5
|
+
module Util
|
6
|
+
class AwsUtil
|
7
|
+
|
8
|
+
attr_reader :alb
|
9
|
+
|
10
|
+
def initialize(accesskey, secretkey, region)
|
11
|
+
credentials = Aws::Credentials.new(accesskey, secretkey)
|
12
|
+
@alb = Aws::ElasticLoadBalancingV2::Client.new(
|
13
|
+
credentials: credentials,
|
14
|
+
region: region
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_instance(instance_id, target_group_name)
|
19
|
+
@alb.register_targets(
|
20
|
+
{
|
21
|
+
target_group_arn: get_target_group_arn(target_group_name),
|
22
|
+
targets: [
|
23
|
+
{
|
24
|
+
id: instance_id,
|
25
|
+
},
|
26
|
+
],
|
27
|
+
}
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
def remove_instance(instance_id, target_group_name)
|
32
|
+
@alb.deregister_targets(
|
33
|
+
{
|
34
|
+
target_group_arn: get_target_group_arn(target_group_name),
|
35
|
+
targets: [
|
36
|
+
{
|
37
|
+
id: instance_id,
|
38
|
+
},
|
39
|
+
],
|
40
|
+
}
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def get_target_group_arn(target_group_name)
|
47
|
+
@alb.describe_target_groups({ names: [target_group_name] }).target_groups[0].target_group_arn
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "vagrant-aws-alb-target-group/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "vagrant-aws-alb-target-group"
|
7
|
+
spec.version = Vagrant::AwsAlbTargetGroup::VERSION
|
8
|
+
spec.authors = ["henteko"]
|
9
|
+
spec.email = ["henteko07@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = %q{Setup AWS ALB Target Group}
|
12
|
+
spec.description = %q{Setup AWS ALB Target Group}
|
13
|
+
spec.homepage = "https://github.com/henteko/vagrant-aws-alb-target-group"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_dependency 'aws-sdk', '~> 2.6.44'
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-aws-alb-target-group
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- henteko
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-07-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: aws-sdk
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.6.44
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.6.44
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.16'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.16'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: Setup AWS ALB Target Group
|
56
|
+
email:
|
57
|
+
- henteko07@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- Gemfile.lock
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- lib/vagrant-aws-alb-target-group.rb
|
68
|
+
- lib/vagrant-aws-alb-target-group/action/add_instance.rb
|
69
|
+
- lib/vagrant-aws-alb-target-group/action/base.rb
|
70
|
+
- lib/vagrant-aws-alb-target-group/action/remove_instance.rb
|
71
|
+
- lib/vagrant-aws-alb-target-group/config.rb
|
72
|
+
- lib/vagrant-aws-alb-target-group/plugin.rb
|
73
|
+
- lib/vagrant-aws-alb-target-group/util/aws_util.rb
|
74
|
+
- lib/vagrant-aws-alb-target-group/version.rb
|
75
|
+
- vagrant-aws-alb-target-group.gemspec
|
76
|
+
homepage: https://github.com/henteko/vagrant-aws-alb-target-group
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
metadata: {}
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.6.13
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: Setup AWS ALB Target Group
|
100
|
+
test_files: []
|