autostacker24 1.0.63 → 1.0.64
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/autostacker24/stacker.rb +10 -8
- data/lib/autostacker24/template_preprocessor.rb +2 -35
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e43bad33022b4b88bde94e2146b4b8693e2485d
|
4
|
+
data.tar.gz: c6f9b80bc2be1784270ae765f49f37c1b99c58e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 204b3139bf2bad11c5b70367a28849443bc914ce461026287c4f1bc533e94865ff8bf7db1a3a7fb44284e4a4162dbfdf264a97abde9fc7ed2ad16da60dadd753
|
7
|
+
data.tar.gz: 1ce541e41f33c5fc822a58a2a52ac265113cd36099220ce8fe7f6860b64562850a4e18d2a9c48cf319304c4aae3c2de27dbbffdff4335f402c82258750474e13
|
@@ -33,10 +33,11 @@ module Stacker
|
|
33
33
|
def create_stack(stack_name, template, parameters, parent_stack_name = nil, tags = nil)
|
34
34
|
merge_and_validate(template, parameters, parent_stack_name)
|
35
35
|
cloud_formation.create_stack(stack_name: stack_name,
|
36
|
-
template_body: template_body(template
|
36
|
+
template_body: template_body(template),
|
37
37
|
on_failure: 'DELETE',
|
38
38
|
parameters: transform_input(parameters),
|
39
|
-
capabilities: ['CAPABILITY_IAM']
|
39
|
+
capabilities: ['CAPABILITY_IAM'],
|
40
|
+
tags: tags)
|
40
41
|
wait_for_stack(stack_name, :create)
|
41
42
|
end
|
42
43
|
|
@@ -45,9 +46,10 @@ module Stacker
|
|
45
46
|
begin
|
46
47
|
merge_and_validate(template, parameters, parent_stack_name)
|
47
48
|
cloud_formation.update_stack(stack_name: stack_name,
|
48
|
-
template_body: template_body(template
|
49
|
+
template_body: template_body(template),
|
49
50
|
parameters: transform_input(parameters),
|
50
|
-
capabilities: ['CAPABILITY_IAM']
|
51
|
+
capabilities: ['CAPABILITY_IAM'],
|
52
|
+
tags: tags)
|
51
53
|
rescue Aws::CloudFormation::Errors::ValidationError => error
|
52
54
|
raise error unless error.message =~ /No updates are to be performed/i # may be flaky, do more research in API
|
53
55
|
find_stack(stack_name)
|
@@ -74,8 +76,8 @@ module Stacker
|
|
74
76
|
end
|
75
77
|
private :merge_and_validate
|
76
78
|
|
77
|
-
def validate_template(template
|
78
|
-
cloud_formation.validate_template(template_body: template_body(template
|
79
|
+
def validate_template(template)
|
80
|
+
cloud_formation.validate_template(template_body: template_body(template))
|
79
81
|
end
|
80
82
|
|
81
83
|
def delete_stack(stack_name)
|
@@ -173,9 +175,9 @@ module Stacker
|
|
173
175
|
@lazy_cloud_formation
|
174
176
|
end
|
175
177
|
|
176
|
-
def template_body(template
|
178
|
+
def template_body(template)
|
177
179
|
template = File.read(template) if File.exists?(template)
|
178
|
-
AutoStacker24::Preprocessor.preprocess(template
|
180
|
+
AutoStacker24::Preprocessor.preprocess(template)
|
179
181
|
end
|
180
182
|
|
181
183
|
extend self
|
@@ -6,16 +6,13 @@ module AutoStacker24
|
|
6
6
|
|
7
7
|
module Preprocessor
|
8
8
|
|
9
|
-
def self.preprocess(template
|
9
|
+
def self.preprocess(template)
|
10
10
|
if template =~ /^\s*\/{2}\s*/i
|
11
|
-
|
12
|
-
template = preprocess_tags(processed, tags).to_json
|
11
|
+
template = preprocess_json(parse_json(template)).to_json
|
13
12
|
end
|
14
13
|
template
|
15
14
|
end
|
16
15
|
|
17
|
-
SUPPORTED_TYPES = Set[%w(AWS::AutoScaling::AutoScalingGroup AWS::CloudTrail::Trail AWS::EC2::CustomerGateway AWS::EC2::DHCPOptions AWS::EC2::Instance AWS::EC2::InternetGateway AWS::EC2::NetworkAcl AWS::EC2::NetworkInterface AWS::EC2::RouteTable AWS::EC2::SecurityGroup AWS::EC2::Subnet AWS::EC2::Volume AWS::EC2::VPC AWS::EC2::VPCPeeringConnection AWS::EC2::VPNConnection AWS::EC2::VPNGateway AWS::ElasticBeanstalk::Environment AWS::ElasticLoadBalancing::LoadBalancer AWS::RDS::DBCluster AWS::RDS::DBClusterParameterGroup AWS::RDS::DBInstance AWS::RDS::DBParameterGroup AWS::RDS::DBSecurityGroup AWS::RDS::DBSubnetGroup AWS::RDS::OptionGroup AWS::S3::Bucket)]
|
18
|
-
|
19
16
|
def self.parse_json(template)
|
20
17
|
template = template.gsub(/(\s*\/\/.*$)|(".*")/) {|m| m[0] == '"' ? m : ''} # replace comments
|
21
18
|
JSON(template)
|
@@ -25,36 +22,6 @@ module AutoStacker24
|
|
25
22
|
raise e
|
26
23
|
end
|
27
24
|
|
28
|
-
def self.preprocess_tags(template, tags = nil)
|
29
|
-
|
30
|
-
unless tags.nil?
|
31
|
-
|
32
|
-
tags_for_asg = adjust_tags_for_asg(tags)
|
33
|
-
|
34
|
-
template['Resources'].each {|(key, value)|
|
35
|
-
|
36
|
-
tags_to_apply = tags
|
37
|
-
if value['Type'] == 'AWS::AutoScaling::AutoScalingGroup'
|
38
|
-
tags_to_apply = tags_for_asg
|
39
|
-
end
|
40
|
-
|
41
|
-
if SUPPORTED_TYPES.include? value['Type']
|
42
|
-
if value['Properties']['Tags'].nil?
|
43
|
-
value['Properties']['Tags'] = tags_to_apply
|
44
|
-
else
|
45
|
-
value['Properties']['Tags'] = (tags_to_apply + value['Properties']['Tags']).uniq { |s| s.first }
|
46
|
-
end
|
47
|
-
end
|
48
|
-
}
|
49
|
-
end
|
50
|
-
|
51
|
-
template
|
52
|
-
end
|
53
|
-
|
54
|
-
def self.adjust_tags_for_asg(tags)
|
55
|
-
tags.map {|element| element.merge('PropagateAtLaunch' => 'true') }
|
56
|
-
end
|
57
|
-
|
58
25
|
def self.preprocess_json(json)
|
59
26
|
if json.is_a?(Hash)
|
60
27
|
json.inject({}) do |m, (k, v)|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: autostacker24
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.64
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johannes Mueller
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-02-
|
12
|
+
date: 2016-02-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk-core
|