miasma-aws 0.1.6 → 0.1.8
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/CHANGELOG.md +7 -0
- data/lib/miasma-aws/version.rb +1 -1
- data/lib/miasma/contrib/aws.rb +38 -0
- data/lib/miasma/contrib/aws/orchestration.rb +55 -7
- 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: e6251cdfa71808a80c15f084a1c5b99fef161210
|
4
|
+
data.tar.gz: 257f0b4f25ec6fb9b5b2a47720ac852ff069579a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55f7fc516d4de71dfc646e603ceff90c5b7e38fe0f3c78332c7a731f40ce5a732c58a218ab4e3586a36f5e11c2129db89ae3d2e498123fbb62a267c61bc2f3f3
|
7
|
+
data.tar.gz: 5dd3c7418bbbdb9436f4ef5342dcdedf51716b5d891e0fd211ba8cb8e34016a8b8f59570925f14df1adb0d1a5d2887f7acc415964fb4073134946b0720d7b712
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## v0.1.8
|
2
|
+
* Include resource mapping for Stack
|
3
|
+
* Add support for aws credentials file
|
4
|
+
* Add stack tagging support
|
5
|
+
* Enable on failure option for stack creation
|
6
|
+
* Update list requests to use post + form to prevent param limitations via get
|
7
|
+
|
1
8
|
## v0.1.6
|
2
9
|
* Fix state assignment when undefined within orchestration stacks
|
3
10
|
* Fix multi-part S3 uploads
|
data/lib/miasma-aws/version.rb
CHANGED
data/lib/miasma/contrib/aws.rb
CHANGED
@@ -327,6 +327,8 @@ module Miasma
|
|
327
327
|
|
328
328
|
def self.included(klass)
|
329
329
|
klass.class_eval do
|
330
|
+
attribute :aws_profile_name, String
|
331
|
+
attribute :aws_credentials_file, String, :required => true, :default => File.expand_path('~/.aws/credentials')
|
330
332
|
attribute :aws_access_key_id, String, :required => true
|
331
333
|
attribute :aws_secret_access_key, String, :required => true
|
332
334
|
attribute :aws_region, String, :required => true
|
@@ -356,6 +358,42 @@ module Miasma
|
|
356
358
|
end
|
357
359
|
end
|
358
360
|
|
361
|
+
# Allow loading credentials via local credentials file
|
362
|
+
#
|
363
|
+
# @param creds [Hash]
|
364
|
+
# @return [TrueClass]
|
365
|
+
def custom_setup(creds)
|
366
|
+
if(creds[:aws_profile_name])
|
367
|
+
creds.replace(load_aws_credentials(creds[:aws_profile_name]).merge(creds))
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
371
|
+
# Load credentials from the AWS credentials file
|
372
|
+
#
|
373
|
+
# @param profile [String] name of profile to load
|
374
|
+
# @return [Smash]
|
375
|
+
def load_aws_credentials(profile)
|
376
|
+
credentials = Smash.new.tap do |creds|
|
377
|
+
key = nil
|
378
|
+
File.readlines(aws_credentials_file).each do |line|
|
379
|
+
line.strip!
|
380
|
+
if(line.start_with?('[') && line.end_with?(']'))
|
381
|
+
key = line.tr('[]', '')
|
382
|
+
creds[key] = Smash.new
|
383
|
+
else
|
384
|
+
creds[key].merge!(Smash[*line.split('=')])
|
385
|
+
end
|
386
|
+
end
|
387
|
+
end
|
388
|
+
credentials.fetch(
|
389
|
+
:default, Smash.new
|
390
|
+
).merge(
|
391
|
+
credentials.fetch(
|
392
|
+
profile, Smash.new
|
393
|
+
)
|
394
|
+
)
|
395
|
+
end
|
396
|
+
|
359
397
|
# Setup for API connections
|
360
398
|
def connect
|
361
399
|
unless(aws_host)
|
@@ -5,6 +5,12 @@ module Miasma
|
|
5
5
|
class Orchestration
|
6
6
|
class Aws < Orchestration
|
7
7
|
|
8
|
+
# Extended stack model to provide AWS specific stack options
|
9
|
+
class Stack < Orchestration::Stack
|
10
|
+
attribute :stack_policy_body, Hash, :coerce => lambda{|v| MultiJson.load(v).to_smash}
|
11
|
+
attribute :stack_policy_url, String
|
12
|
+
end
|
13
|
+
|
8
14
|
# Service name of the API
|
9
15
|
API_SERVICE = 'cloudformation'
|
10
16
|
# Supported version of the AutoScaling API
|
@@ -35,6 +41,10 @@ module Miasma
|
|
35
41
|
'AWS::AutoScaling::AutoScalingGroup' => Smash.new(
|
36
42
|
:api => :auto_scale,
|
37
43
|
:collection => :groups
|
44
|
+
),
|
45
|
+
'AWS::CloudFormation::Stack' => Smash.new(
|
46
|
+
:api => :orchestration,
|
47
|
+
:collection => :stacks
|
38
48
|
)
|
39
49
|
)
|
40
50
|
|
@@ -53,16 +63,29 @@ module Miasma
|
|
53
63
|
descriptions = all_result_pages(nil, :body, 'DescribeStacksResponse', 'DescribeStacksResult', 'Stacks', 'member') do |options|
|
54
64
|
request(
|
55
65
|
:path => '/',
|
56
|
-
:
|
66
|
+
:form => options.merge(d_params),
|
67
|
+
:method => :post
|
57
68
|
)
|
58
69
|
end
|
70
|
+
policy = request(
|
71
|
+
:path => '/',
|
72
|
+
:method => :get,
|
73
|
+
:params => Smash.new(
|
74
|
+
'Action' => 'GetStackPolicy',
|
75
|
+
'StackName' => stack.id
|
76
|
+
)
|
77
|
+
).get(:body, 'GetStackPolicyResult', 'StackPolicyBody')
|
78
|
+
if(policy)
|
79
|
+
descriptions.first[:stack_policy] = MultiJson.load(policy).to_smash
|
80
|
+
end
|
59
81
|
else
|
60
82
|
descriptions = []
|
61
83
|
end
|
62
84
|
lists = all_result_pages(nil, :body, 'ListStacksResponse', 'ListStacksResult', 'StackSummaries', 'member') do |options|
|
63
85
|
request(
|
64
86
|
:path => '/',
|
65
|
-
:
|
87
|
+
:form => options.merge(l_params),
|
88
|
+
:method => :post
|
66
89
|
)
|
67
90
|
end.map do |stk|
|
68
91
|
desc = descriptions.detect do |d_stk|
|
@@ -102,11 +125,19 @@ module Miasma
|
|
102
125
|
:description => o['Description']
|
103
126
|
)
|
104
127
|
},
|
128
|
+
:tags => Smash[
|
129
|
+
[stk.fetch('Tags', 'member', [])].flatten(1).map{|param|
|
130
|
+
[param['Key'], param['Value']]
|
131
|
+
}
|
132
|
+
],
|
105
133
|
:parameters => Smash[
|
106
134
|
[stk.fetch('Parameters', 'member', [])].flatten(1).map{|param|
|
107
135
|
[param['ParameterKey'], param['ParameterValue']]
|
108
136
|
}
|
109
|
-
]
|
137
|
+
],
|
138
|
+
:custom => Smash.new(
|
139
|
+
:stack_policy_body => policy
|
140
|
+
)
|
110
141
|
).valid_state
|
111
142
|
end
|
112
143
|
end
|
@@ -127,6 +158,22 @@ module Miasma
|
|
127
158
|
(stack.notification_topics || []).each_with_index do |topic, idx|
|
128
159
|
params["NotificationARNs.member.#{idx + 1}"] = topic
|
129
160
|
end
|
161
|
+
(stack.tags || {}).each_with_index do |tag, idx|
|
162
|
+
params["Tags.member.#{idx + 1}.Key"] = tag.first
|
163
|
+
params["Tags.member.#{idx + 1}.Value"] = tag.last
|
164
|
+
end
|
165
|
+
if(stack.custom[:stack_policy_body])
|
166
|
+
params['StackPolicyBody'] = MultiJson.dump(stack.custom[:stack_policy_body])
|
167
|
+
end
|
168
|
+
if(stack.custom[:stack_policy_url])
|
169
|
+
params['StackPolicyURL'] = stack.custom[:stack_policy_url]
|
170
|
+
end
|
171
|
+
unless(stack.disable_rollback.nil?)
|
172
|
+
params['OnFailure'] = stack.disable_rollback ? 'nothing' : 'delete'
|
173
|
+
end
|
174
|
+
if(stack.on_failure)
|
175
|
+
params['OnFailure'] = stack.on_failure == 'nothing' ? 'DO_NOTHING' : stack.on_failure.upcase
|
176
|
+
end
|
130
177
|
if(stack.template.empty?)
|
131
178
|
params['UsePreviousTemplate'] = true
|
132
179
|
else
|
@@ -149,8 +196,7 @@ module Miasma
|
|
149
196
|
:path => '/',
|
150
197
|
:method => :post,
|
151
198
|
:form => Smash.new(
|
152
|
-
'Action' => 'CreateStack'
|
153
|
-
'DisableRollback' => !!stack.disable_rollback
|
199
|
+
'Action' => 'CreateStack'
|
154
200
|
).merge(params)
|
155
201
|
)
|
156
202
|
stack.id = result.get(:body, 'CreateStackResponse', 'CreateStackResult', 'StackId')
|
@@ -268,7 +314,8 @@ module Miasma
|
|
268
314
|
results = all_result_pages(nil, :body, 'DescribeStackResourcesResponse', 'DescribeStackResourcesResult', 'StackResources', 'member') do |options|
|
269
315
|
request(
|
270
316
|
:path => '/',
|
271
|
-
:
|
317
|
+
:method => :post,
|
318
|
+
:form => options.merge(
|
272
319
|
Smash.new(
|
273
320
|
'Action' => 'DescribeStackResources',
|
274
321
|
'StackName' => stack.id
|
@@ -307,7 +354,8 @@ module Miasma
|
|
307
354
|
results = all_result_pages(nil, :body, 'DescribeStackEventsResponse', 'DescribeStackEventsResult', 'StackEvents', 'member') do |options|
|
308
355
|
request(
|
309
356
|
:path => '/',
|
310
|
-
:
|
357
|
+
:method => :post,
|
358
|
+
:form => options.merge(
|
311
359
|
'Action' => 'DescribeStackEvents',
|
312
360
|
'StackName' => stack.id
|
313
361
|
)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: miasma-aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Roberts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: miasma
|