awspec 1.12.7 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +14 -8
- data/doc/_resource_types/launch_template.md +48 -0
- data/doc/resource_types.md +58 -1
- data/lib/awspec/command/generate.rb +1 -1
- data/lib/awspec/generator.rb +2 -0
- data/lib/awspec/generator/doc/type/launch_template.rb +17 -0
- data/lib/awspec/generator/spec/alb_listener.rb +110 -0
- data/lib/awspec/generator/spec/nlb_listener.rb +110 -0
- data/lib/awspec/helper/finder/alb.rb +11 -0
- data/lib/awspec/helper/finder/ec2.rb +25 -0
- data/lib/awspec/helper/finder/nlb.rb +11 -0
- data/lib/awspec/helper/type.rb +1 -1
- data/lib/awspec/shared_context.rb +6 -0
- data/lib/awspec/stub/launch_template.rb +16 -0
- data/lib/awspec/type/launch_template.rb +34 -0
- data/lib/awspec/version.rb +1 -1
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6592ba53cb08813b9a65ac0f08b40f2a83a8963e6bbc15cb21251698e43fb0b
|
4
|
+
data.tar.gz: e52fbceb662756bedb71815b620184dac9b5b0728b384fea5c82b99b1aa13884
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 668b292eccd60ebf47b57d3179271a051cec0351cf1f57203ee302a9d8543220cda7cf132e39fb8fa0ede6a06f3f71e038c7664fb1adada870e7b46ecd9d991f
|
7
|
+
data.tar.gz: 7439bb05f1d7a5e0900b934e6a9d4f562e3bf2e96449e43cfe586cbed35636af05973133b26ed627315a4173b1f349862f6f32af7fbee2b3e16bf2b0bb408afb
|
data/.travis.yml
CHANGED
@@ -1,13 +1,19 @@
|
|
1
1
|
language: ruby
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
matrix:
|
3
|
+
include:
|
4
|
+
- rvm: 2.5.3
|
5
|
+
env: RUBYGEMS_VERSION=
|
6
|
+
- rvm: 2.4.5
|
7
|
+
env: RUBYGEMS_VERSION=
|
8
|
+
- rvm: 2.3.8
|
9
|
+
env: RUBYGEMS_VERSION=
|
10
|
+
- rvm: 2.2.10
|
11
|
+
env: RUBYGEMS_VERSION=2.7.8
|
12
|
+
- rvm: 2.1.10
|
13
|
+
env: RUBYGEMS_VERSION=2.7.8
|
8
14
|
before_install:
|
9
|
-
- gem update --system
|
15
|
+
- gem update --system ${RUBYGEMS_VERSION}
|
10
16
|
- gem pristine bundler
|
11
|
-
|
17
|
+
|
12
18
|
script:
|
13
19
|
- bundle exec rake spec
|
@@ -0,0 +1,48 @@
|
|
1
|
+
### exist
|
2
|
+
|
3
|
+
You can set launch template version ( default: $Default ).
|
4
|
+
|
5
|
+
```ruby
|
6
|
+
# launch_template_id or launch_template_name
|
7
|
+
describe launch_template('my-launch-template') do
|
8
|
+
it { should exist }
|
9
|
+
its(:default_version_number) { should eq 1 }
|
10
|
+
its(:latest_version_number) { should eq 2 }
|
11
|
+
its('launch_template_version.launch_template_data.image_id') { should eq 'ami-12345foobar' }
|
12
|
+
its('launch_template_version.launch_template_data.instance_type') { should eq 't2.micro' }
|
13
|
+
end
|
14
|
+
```
|
15
|
+
|
16
|
+
#### specify version
|
17
|
+
|
18
|
+
Specify "latest" or version_number.
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
# version_number
|
22
|
+
describe launch_template('my-launch-template'), version: 2 do
|
23
|
+
it { should exist }
|
24
|
+
its('launch_template_version.launch_template_data.instance_type') { should eq 't2.micro' }
|
25
|
+
end
|
26
|
+
|
27
|
+
# latest
|
28
|
+
describe launch_template('my-launch-template'), version: 'latest' do
|
29
|
+
it { should exist }
|
30
|
+
its('launch_template_version.launch_template_data.instance_type') { should eq 't2.micro' }
|
31
|
+
end
|
32
|
+
```
|
33
|
+
|
34
|
+
### have_tag
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
describe launch_template('my-launch-template') do
|
38
|
+
it { should have_tag('env').value('dev') }
|
39
|
+
end
|
40
|
+
```
|
41
|
+
|
42
|
+
### have_version_number
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
describe launch_template('my-launch-template') do
|
46
|
+
it { should have_version_number(2) }
|
47
|
+
end
|
48
|
+
```
|
data/doc/resource_types.md
CHANGED
@@ -46,6 +46,7 @@
|
|
46
46
|
| [kms](#kms)
|
47
47
|
| [lambda](#lambda)
|
48
48
|
| [launch_configuration](#launch_configuration)
|
49
|
+
| [launch_template](#launch_template)
|
49
50
|
| [nat_gateway](#nat_gateway)
|
50
51
|
| [network_acl](#network_acl)
|
51
52
|
| [network_interface](#network_interface)
|
@@ -2043,6 +2044,62 @@ end
|
|
2043
2044
|
```
|
2044
2045
|
|
2045
2046
|
### its(:launch_configuration_name), its(:launch_configuration_arn), its(:image_id), its(:key_name), its(:security_groups), its(:classic_link_vpc_id), its(:classic_link_vpc_security_groups), its(:user_data), its(:instance_type), its(:kernel_id), its(:ramdisk_id), its(:spot_price), its(:iam_instance_profile), its(:created_time), its(:ebs_optimized), its(:associate_public_ip_address), its(:placement_tenancy)
|
2047
|
+
## <a name="launch_template">launch_template</a>
|
2048
|
+
|
2049
|
+
LaunchTemplate resource type.
|
2050
|
+
|
2051
|
+
### exist
|
2052
|
+
|
2053
|
+
You can set launch template version ( default: $Default ).
|
2054
|
+
|
2055
|
+
```ruby
|
2056
|
+
# launch_template_id or launch_template_name
|
2057
|
+
describe launch_template('my-launch-template') do
|
2058
|
+
it { should exist }
|
2059
|
+
its(:default_version_number) { should eq 1 }
|
2060
|
+
its(:latest_version_number) { should eq 2 }
|
2061
|
+
its('launch_template_version.launch_template_data.image_id') { should eq 'ami-12345foobar' }
|
2062
|
+
its('launch_template_version.launch_template_data.instance_type') { should eq 't2.micro' }
|
2063
|
+
end
|
2064
|
+
```
|
2065
|
+
|
2066
|
+
#### specify version
|
2067
|
+
|
2068
|
+
Specify "latest" or version_number.
|
2069
|
+
|
2070
|
+
```ruby
|
2071
|
+
# version_number
|
2072
|
+
describe launch_template('my-launch-template'), version: 2 do
|
2073
|
+
it { should exist }
|
2074
|
+
its('launch_template_version.launch_template_data.instance_type') { should eq 't2.micro' }
|
2075
|
+
end
|
2076
|
+
|
2077
|
+
# latest
|
2078
|
+
describe launch_template('my-launch-template'), version: 'latest' do
|
2079
|
+
it { should exist }
|
2080
|
+
its('launch_template_version.launch_template_data.instance_type') { should eq 't2.micro' }
|
2081
|
+
end
|
2082
|
+
```
|
2083
|
+
|
2084
|
+
|
2085
|
+
### have_tag
|
2086
|
+
|
2087
|
+
```ruby
|
2088
|
+
describe launch_template('my-launch-template') do
|
2089
|
+
it { should have_tag('env').value('dev') }
|
2090
|
+
end
|
2091
|
+
```
|
2092
|
+
|
2093
|
+
|
2094
|
+
### have_version_number
|
2095
|
+
|
2096
|
+
```ruby
|
2097
|
+
describe launch_template('my-launch-template') do
|
2098
|
+
it { should have_version_number(2) }
|
2099
|
+
end
|
2100
|
+
```
|
2101
|
+
|
2102
|
+
### its(:launch_template_id), its(:launch_template_name), its(:create_time), its(:created_by), its(:default_version_number), its(:latest_version_number), its(:tags)
|
2046
2103
|
## <a name="nat_gateway">nat_gateway</a>
|
2047
2104
|
|
2048
2105
|
NatGateway resource type.
|
@@ -3244,7 +3301,7 @@ end
|
|
3244
3301
|
```
|
3245
3302
|
|
3246
3303
|
|
3247
|
-
### its(:default_action), its(:web_acl_id), its(:name), its(:metric_name)
|
3304
|
+
### its(:default_action), its(:web_acl_id), its(:name), its(:metric_name), its(:web_acl_arn)
|
3248
3305
|
# Account and Attributes
|
3249
3306
|
|
3250
3307
|
## <a name="account">account</a>
|
@@ -9,7 +9,7 @@ module Awspec
|
|
9
9
|
|
10
10
|
types = %w(
|
11
11
|
vpc ec2 rds security_group elb network_acl route_table subnet nat_gateway network_interface alb nlb
|
12
|
-
internet_gateway autoscaling_group
|
12
|
+
internet_gateway autoscaling_group alb_listener nlb_listener
|
13
13
|
)
|
14
14
|
|
15
15
|
types.each do |type|
|
data/lib/awspec/generator.rb
CHANGED
@@ -33,6 +33,8 @@ require 'awspec/generator/spec/rds_db_parameter_group'
|
|
33
33
|
require 'awspec/generator/spec/rds_db_cluster_parameter_group'
|
34
34
|
require 'awspec/generator/spec/codebuild'
|
35
35
|
require 'awspec/generator/spec/autoscaling_group'
|
36
|
+
require 'awspec/generator/spec/alb_listener'
|
37
|
+
require 'awspec/generator/spec/nlb_listener'
|
36
38
|
|
37
39
|
# Doc
|
38
40
|
require 'awspec/generator/doc/type'
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Awspec::Generator
|
2
|
+
module Doc
|
3
|
+
module Type
|
4
|
+
class LaunchTemplate < Base
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
@type_name = 'LaunchTemplate'
|
8
|
+
@type = Awspec::Type::LaunchTemplate.new('my-launch-template')
|
9
|
+
@ret = @type.resource_via_client
|
10
|
+
@matchers = []
|
11
|
+
@ignore_matchers = []
|
12
|
+
@describes = []
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
module Awspec::Generator
|
2
|
+
module Spec
|
3
|
+
class AlbListener
|
4
|
+
include Awspec::Helper::Finder
|
5
|
+
def generate_by_vpc_id(vpc_id)
|
6
|
+
describes = %w(
|
7
|
+
load_balancer_arn port protocol ssl_policy
|
8
|
+
)
|
9
|
+
vpc = find_vpc(vpc_id)
|
10
|
+
raise 'Not Found VPC' unless vpc
|
11
|
+
@vpc_id = vpc[:vpc_id]
|
12
|
+
@vpc_tag_name = vpc.tag_name
|
13
|
+
albs = select_alb_by_vpc_id(@vpc_id)
|
14
|
+
|
15
|
+
specs = albs.map do |alb|
|
16
|
+
alb_listeners = select_alb_listener_by_alb_arn(alb.load_balancer_arn)
|
17
|
+
alb_listeners.map do |listener|
|
18
|
+
rules = select_rule_by_alb_listener_id(listener.listener_arn).map(&:to_h)
|
19
|
+
rules.map do |rule|
|
20
|
+
content = ERB.new(alb_listener_spec_template, nil, '-').result(binding).gsub(/^\n/, '')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
specs.join("\n")
|
25
|
+
end
|
26
|
+
|
27
|
+
def generate_rule_conditions_specs(conditions)
|
28
|
+
conditions_lines = []
|
29
|
+
conditions.each do |condition|
|
30
|
+
conditions_lines.push("{field: '#{condition[:field]}', values: #{condition[:values]}}")
|
31
|
+
end
|
32
|
+
conditions_lines.join(', ')
|
33
|
+
end
|
34
|
+
|
35
|
+
def generate_action_configs_specs(config)
|
36
|
+
action_config = []
|
37
|
+
config.each do |key, value|
|
38
|
+
if value.is_a?(String)
|
39
|
+
action_config.push("#{key}: '#{value}'")
|
40
|
+
elsif value.is_a?(Hash)
|
41
|
+
value.each do |vkey, vvalue|
|
42
|
+
if vvalue.is_a?(String)
|
43
|
+
action_config.push("#{key}: {#{vkey}: '#{vvalue}'}")
|
44
|
+
else
|
45
|
+
action_config.push("#{key}: {#{vkey}: #{vvalue}}")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
else
|
49
|
+
action_config.push("#{key}: #{value}")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
action_config
|
53
|
+
end
|
54
|
+
|
55
|
+
def generate_rule_actions_specs(actions)
|
56
|
+
actions_line = []
|
57
|
+
actions.each do |action|
|
58
|
+
action_line = []
|
59
|
+
action_line.push("type: '#{action[:type]}'")
|
60
|
+
action_line.push("order: #{action[:order]}") unless action[:order].nil?
|
61
|
+
action_line.push("target_group_arn: '#{action[:target_group_arn]}'") unless action[:target_group_arn].nil?
|
62
|
+
unless action[:redirect_config].nil?
|
63
|
+
redirect_config = generate_action_configs_specs(action[:redirect_config])
|
64
|
+
action_line.push("redirect_config: {#{redirect_config.join(', ')}}")
|
65
|
+
end
|
66
|
+
unless action[:fixed_response_config].nil?
|
67
|
+
fixed_response_config = generate_action_configs_specs(action[:fixed_response_config])
|
68
|
+
action_line.push("fixed_response_config: {#{fixed_response_config.join(', ')}}")
|
69
|
+
end
|
70
|
+
unless action[:authenticate_oidc_config].nil?
|
71
|
+
authenticate_oidc_config = generate_action_configs_specs(action[:authenticate_oidc_config])
|
72
|
+
action_line.push("authenticate_oidc_config: {#{authenticate_oidc_config.join(', ')}}")
|
73
|
+
end
|
74
|
+
actions_line.push("{#{action_line.join(', ')}}")
|
75
|
+
end
|
76
|
+
actions_line.join(', ')
|
77
|
+
end
|
78
|
+
|
79
|
+
def alb_listener_spec_template
|
80
|
+
template = <<-'EOF'
|
81
|
+
describe alb_listener('<%= listener.listener_arn %>') do
|
82
|
+
it { should exist }
|
83
|
+
<%- describes.each do |describe| -%>
|
84
|
+
<%- if listener.key?(describe) -%>
|
85
|
+
<%- if listener[describe].is_a?(String) -%>
|
86
|
+
its(:<%= describe %>) { should eq '<%= listener[describe] %>' }
|
87
|
+
<%- else -%>
|
88
|
+
its(:<%= describe %>) { should eq <%= listener[describe] %> }
|
89
|
+
<%- end -%>
|
90
|
+
<%- end -%>
|
91
|
+
<%- end -%>
|
92
|
+
<%- rules.each do |rule| -%>
|
93
|
+
it { should have_rule('<%= rule[:rule_arn] %>') }
|
94
|
+
it do
|
95
|
+
should have_rule.priority('<%= rule[:priority] %>')
|
96
|
+
<%- unless rule[:conditions].empty? -%>
|
97
|
+
.conditions([<%= generate_rule_conditions_specs(rule[:conditions]) %>])
|
98
|
+
<%- end -%>
|
99
|
+
<%- unless rule[:actions].empty? -%>
|
100
|
+
.actions([<%= generate_rule_actions_specs(rule[:actions]) %>])
|
101
|
+
<%- end -%>
|
102
|
+
end
|
103
|
+
<%- end -%>
|
104
|
+
end
|
105
|
+
EOF
|
106
|
+
template
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
module Awspec::Generator
|
2
|
+
module Spec
|
3
|
+
class NlbListener
|
4
|
+
include Awspec::Helper::Finder
|
5
|
+
def generate_by_vpc_id(vpc_id)
|
6
|
+
describes = %w(
|
7
|
+
load_balancer_arn port protocol ssl_policy
|
8
|
+
)
|
9
|
+
vpc = find_vpc(vpc_id)
|
10
|
+
raise 'Not Found VPC' unless vpc
|
11
|
+
@vpc_id = vpc[:vpc_id]
|
12
|
+
@vpc_tag_name = vpc.tag_name
|
13
|
+
nlbs = select_nlb_by_vpc_id(@vpc_id)
|
14
|
+
|
15
|
+
specs = nlbs.map do |nlb|
|
16
|
+
nlb_listeners = select_nlb_listener_by_nlb_arn(nlb.load_balancer_arn)
|
17
|
+
nlb_listeners.map do |listener|
|
18
|
+
rules = select_rule_by_nlb_listener_id(listener.listener_arn).map(&:to_h)
|
19
|
+
rules.map do |rule|
|
20
|
+
content = ERB.new(nlb_listener_spec_template, nil, '-').result(binding).gsub(/^\n/, '')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
specs.join("\n")
|
25
|
+
end
|
26
|
+
|
27
|
+
def generate_rule_conditions_specs(conditions)
|
28
|
+
conditions_lines = []
|
29
|
+
conditions.each do |condition|
|
30
|
+
conditions_lines.push("{field: '#{condition[:field]}', values: #{condition[:values]}}")
|
31
|
+
end
|
32
|
+
conditions_lines.join(', ')
|
33
|
+
end
|
34
|
+
|
35
|
+
def generate_action_configs_specs(config)
|
36
|
+
action_config = []
|
37
|
+
config.each do |key, value|
|
38
|
+
if value.is_a?(String)
|
39
|
+
action_config.push("#{key}: '#{value}'")
|
40
|
+
elsif value.is_a?(Hash)
|
41
|
+
value.each do |vkey, vvalue|
|
42
|
+
if vvalue.is_a?(String)
|
43
|
+
action_config.push("#{key}: {#{vkey}: '#{vvalue}'}")
|
44
|
+
else
|
45
|
+
action_config.push("#{key}: {#{vkey}: #{vvalue}}")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
else
|
49
|
+
action_config.push("#{key}: #{value}")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
action_config
|
53
|
+
end
|
54
|
+
|
55
|
+
def generate_rule_actions_specs(actions)
|
56
|
+
actions_line = []
|
57
|
+
actions.each do |action|
|
58
|
+
action_line = []
|
59
|
+
action_line.push("type: '#{action[:type]}'")
|
60
|
+
action_line.push("order: #{action[:order]}") unless action[:order].nil?
|
61
|
+
action_line.push("target_group_arn: '#{action[:target_group_arn]}'") unless action[:target_group_arn].nil?
|
62
|
+
unless action[:redirect_config].nil?
|
63
|
+
redirect_config = generate_action_configs_specs(action[:redirect_config])
|
64
|
+
action_line.push("redirect_config: {#{redirect_config.join(', ')}}")
|
65
|
+
end
|
66
|
+
unless action[:fixed_response_config].nil?
|
67
|
+
fixed_response_config = generate_action_configs_specs(action[:fixed_response_config])
|
68
|
+
action_line.push("fixed_response_config: {#{fixed_response_config.join(', ')}}")
|
69
|
+
end
|
70
|
+
unless action[:authenticate_oidc_config].nil?
|
71
|
+
authenticate_oidc_config = generate_action_configs_specs(action[:authenticate_oidc_config])
|
72
|
+
action_line.push("authenticate_oidc_config: {#{authenticate_oidc_config.join(', ')}}")
|
73
|
+
end
|
74
|
+
actions_line.push("{#{action_line.join(', ')}}")
|
75
|
+
end
|
76
|
+
actions_line.join(', ')
|
77
|
+
end
|
78
|
+
|
79
|
+
def nlb_listener_spec_template
|
80
|
+
template = <<-'EOF'
|
81
|
+
describe nlb_listener('<%= listener.listener_arn %>') do
|
82
|
+
it { should exist }
|
83
|
+
<%- describes.each do |describe| -%>
|
84
|
+
<%- if listener.key?(describe) -%>
|
85
|
+
<%- if listener[describe].is_a?(String) -%>
|
86
|
+
its(:<%= describe %>) { should eq '<%= listener[describe] %>' }
|
87
|
+
<%- else -%>
|
88
|
+
its(:<%= describe %>) { should eq <%= listener[describe] %> }
|
89
|
+
<%- end -%>
|
90
|
+
<%- end -%>
|
91
|
+
<%- end -%>
|
92
|
+
<%- rules.each do |rule| -%>
|
93
|
+
it { should have_rule('<%= rule[:rule_arn] %>') }
|
94
|
+
it do
|
95
|
+
should have_rule.priority('<%= rule[:priority] %>')
|
96
|
+
<%- unless rule[:conditions].empty? -%>
|
97
|
+
.conditions([<%= generate_rule_conditions_specs(rule[:conditions]) %>])
|
98
|
+
<%- end -%>
|
99
|
+
<%- unless rule[:actions].empty? -%>
|
100
|
+
.actions([<%= generate_rule_actions_specs(rule[:actions]) %>])
|
101
|
+
<%- end -%>
|
102
|
+
end
|
103
|
+
<%- end -%>
|
104
|
+
end
|
105
|
+
EOF
|
106
|
+
template
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -24,6 +24,17 @@ module Awspec::Helper
|
|
24
24
|
return nil
|
25
25
|
end
|
26
26
|
|
27
|
+
def select_alb_listener_by_alb_arn(arn)
|
28
|
+
selected = []
|
29
|
+
next_marker = nil
|
30
|
+
loop do
|
31
|
+
res = elbv2_client.describe_listeners({ marker: next_marker, load_balancer_arn: arn })
|
32
|
+
selected += res.listeners unless res.nil?
|
33
|
+
(res.nil? && next_marker = res.next_marker) || break
|
34
|
+
end
|
35
|
+
selected
|
36
|
+
end
|
37
|
+
|
27
38
|
def find_alb_target_group(id)
|
28
39
|
res = elbv2_client.describe_target_groups({ names: [id] })
|
29
40
|
res.target_groups.select do |tg|
|
@@ -162,6 +162,31 @@ module Awspec::Helper
|
|
162
162
|
})
|
163
163
|
res.network_interfaces
|
164
164
|
end
|
165
|
+
|
166
|
+
def find_launch_template(id)
|
167
|
+
# launch_template_id or launch_template_name
|
168
|
+
begin
|
169
|
+
res = ec2_client.describe_launch_templates({
|
170
|
+
launch_template_ids: [id]
|
171
|
+
})
|
172
|
+
rescue
|
173
|
+
res = ec2_client.describe_launch_templates({
|
174
|
+
launch_template_names: [id]
|
175
|
+
})
|
176
|
+
end
|
177
|
+
res.launch_templates.single_resource(id)
|
178
|
+
end
|
179
|
+
|
180
|
+
def find_launch_template_versions(id)
|
181
|
+
# launch_template_id or launch_template_name
|
182
|
+
res = ec2_client.describe_launch_template_versions({
|
183
|
+
launch_template_id: id
|
184
|
+
})
|
185
|
+
rescue
|
186
|
+
res = ec2_client.describe_launch_template_versions({
|
187
|
+
launch_template_name: id
|
188
|
+
})
|
189
|
+
end
|
165
190
|
end
|
166
191
|
end
|
167
192
|
end
|
@@ -24,6 +24,17 @@ module Awspec::Helper
|
|
24
24
|
return nil
|
25
25
|
end
|
26
26
|
|
27
|
+
def select_nlb_listener_by_nlb_arn(arn)
|
28
|
+
selected = []
|
29
|
+
next_marker = nil
|
30
|
+
loop do
|
31
|
+
res = elbv2_client.describe_listeners({ marker: next_marker, load_balancer_arn: arn })
|
32
|
+
selected += res.listeners unless res.nil?
|
33
|
+
(res.nil? && next_marker = res.next_marker) || break
|
34
|
+
end
|
35
|
+
selected
|
36
|
+
end
|
37
|
+
|
27
38
|
def find_nlb_target_group(id)
|
28
39
|
res = elbv2_client.describe_target_groups({ names: [id] })
|
29
40
|
httpx_res = res.target_groups.select do |tg|
|
data/lib/awspec/helper/type.rb
CHANGED
@@ -13,7 +13,7 @@ module Awspec
|
|
13
13
|
cloudwatch_alarm cloudwatch_event directconnect_virtual_interface
|
14
14
|
ebs ec2 ecr_repository ecs_cluster ecs_container_instance ecs_service ecs_task_definition
|
15
15
|
efs eks elasticache elasticache_cache_parameter_group elasticsearch elb emr firehose iam_group
|
16
|
-
iam_policy iam_role iam_user kinesis kms lambda launch_configuration nat_gateway
|
16
|
+
iam_policy iam_role iam_user kinesis kms lambda launch_configuration launch_template nat_gateway
|
17
17
|
network_acl network_interface nlb nlb_listener nlb_target_group
|
18
18
|
rds rds_db_cluster_parameter_group rds_db_parameter_group route53_hosted_zone
|
19
19
|
route_table s3_bucket security_group ses_identity subnet vpc cloudfront_distribution
|
@@ -23,3 +23,9 @@ shared_context 'cluster', :cluster do
|
|
23
23
|
example.metadata[:described_class].cluster = example.metadata[:cluster]
|
24
24
|
end
|
25
25
|
end
|
26
|
+
|
27
|
+
shared_context 'version', :version do
|
28
|
+
before do |example|
|
29
|
+
example.metadata[:described_class].version = example.metadata[:version]
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Aws.config[:ec2] = {
|
2
|
+
stub_responses: {
|
3
|
+
describe_launch_templates: {
|
4
|
+
launch_templates: [
|
5
|
+
{
|
6
|
+
create_time: Time.parse('2018-01-16T04:32:57.000Z'),
|
7
|
+
created_by: 'arn:aws:iam::123456789012:root',
|
8
|
+
default_version_number: 1,
|
9
|
+
latest_version_number: 2,
|
10
|
+
launch_template_id: 'lt-01238c059e3466abc',
|
11
|
+
launch_template_name: 'my-launch-template'
|
12
|
+
}
|
13
|
+
]
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Awspec::Type
|
2
|
+
class LaunchTemplate < ResourceBase
|
3
|
+
attr_accessor :version
|
4
|
+
tags_allowed
|
5
|
+
|
6
|
+
def resource_via_client
|
7
|
+
@resource_via_client ||= find_launch_template(@display_name)
|
8
|
+
end
|
9
|
+
|
10
|
+
def id
|
11
|
+
@id ||= resource_via_client.launch_template_id if resource_via_client
|
12
|
+
end
|
13
|
+
|
14
|
+
def has_version_number?(version_number)
|
15
|
+
launch_template_versions = find_launch_template_versions(@id)
|
16
|
+
launch_template_versions.launch_template_versions.each do |launch_template_version|
|
17
|
+
return true if launch_template_version.version_number.to_s == version_number.to_s
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# launch_template_versions
|
22
|
+
define_method 'launch_template_version' do
|
23
|
+
if @version.nil? || @version == 'default'
|
24
|
+
@version = '$Default'
|
25
|
+
elsif @version == 'latest'
|
26
|
+
@version = '$Latest'
|
27
|
+
end
|
28
|
+
res = ec2_client.describe_launch_template_versions({
|
29
|
+
launch_template_id: @id,
|
30
|
+
versions: [@version.to_s]
|
31
|
+
}).launch_template_versions.first
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/awspec/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- k1LoW
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -260,6 +260,7 @@ files:
|
|
260
260
|
- doc/_resource_types/lambda.md
|
261
261
|
- doc/_resource_types/lambda_account_settings.md
|
262
262
|
- doc/_resource_types/launch_configuration.md
|
263
|
+
- doc/_resource_types/launch_template.md
|
263
264
|
- doc/_resource_types/nat_gateway.md
|
264
265
|
- doc/_resource_types/network_acl.md
|
265
266
|
- doc/_resource_types/network_interface.md
|
@@ -350,6 +351,7 @@ files:
|
|
350
351
|
- lib/awspec/generator/doc/type/lambda.rb
|
351
352
|
- lib/awspec/generator/doc/type/lambda_account_settings.rb
|
352
353
|
- lib/awspec/generator/doc/type/launch_configuration.rb
|
354
|
+
- lib/awspec/generator/doc/type/launch_template.rb
|
353
355
|
- lib/awspec/generator/doc/type/nat_gateway.rb
|
354
356
|
- lib/awspec/generator/doc/type/network_acl.rb
|
355
357
|
- lib/awspec/generator/doc/type/network_interface.rb
|
@@ -376,6 +378,7 @@ files:
|
|
376
378
|
- lib/awspec/generator/doc/type/waf_web_acl.rb
|
377
379
|
- lib/awspec/generator/spec/acm.rb
|
378
380
|
- lib/awspec/generator/spec/alb.rb
|
381
|
+
- lib/awspec/generator/spec/alb_listener.rb
|
379
382
|
- lib/awspec/generator/spec/autoscaling_group.rb
|
380
383
|
- lib/awspec/generator/spec/cloudwatch_alarm.rb
|
381
384
|
- lib/awspec/generator/spec/cloudwatch_event.rb
|
@@ -399,6 +402,7 @@ files:
|
|
399
402
|
- lib/awspec/generator/spec/network_acl.rb
|
400
403
|
- lib/awspec/generator/spec/network_interface.rb
|
401
404
|
- lib/awspec/generator/spec/nlb.rb
|
405
|
+
- lib/awspec/generator/spec/nlb_listener.rb
|
402
406
|
- lib/awspec/generator/spec/rds.rb
|
403
407
|
- lib/awspec/generator/spec/rds_db_cluster_parameter_group.rb
|
404
408
|
- lib/awspec/generator/spec/rds_db_parameter_group.rb
|
@@ -548,6 +552,7 @@ files:
|
|
548
552
|
- lib/awspec/stub/kms.rb
|
549
553
|
- lib/awspec/stub/lambda.rb
|
550
554
|
- lib/awspec/stub/launch_configuration.rb
|
555
|
+
- lib/awspec/stub/launch_template.rb
|
551
556
|
- lib/awspec/stub/nat_gateway.rb
|
552
557
|
- lib/awspec/stub/network_acl.rb
|
553
558
|
- lib/awspec/stub/network_interface.rb
|
@@ -623,6 +628,7 @@ files:
|
|
623
628
|
- lib/awspec/type/lambda.rb
|
624
629
|
- lib/awspec/type/lambda_account_settings.rb
|
625
630
|
- lib/awspec/type/launch_configuration.rb
|
631
|
+
- lib/awspec/type/launch_template.rb
|
626
632
|
- lib/awspec/type/nat_gateway.rb
|
627
633
|
- lib/awspec/type/network_acl.rb
|
628
634
|
- lib/awspec/type/network_interface.rb
|