convection 0.2.21 → 0.2.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/convection/model/template.rb +1 -0
- data/lib/convection/model/template/resource.rb +4 -0
- data/lib/convection/model/template/resource/aws_auto_scaling_auto_scaling_group.rb +5 -0
- data/lib/convection/model/template/resource/aws_directory_service_simple_ad.rb +23 -0
- data/lib/convection/model/template/resource_attribute.rb +15 -0
- data/lib/convection/model/template/resource_attribute/update_policy.rb +44 -0
- data/test/convection/model/test_directory_service.rb +40 -0
- data/test/convection/model/test_update_policies.rb +54 -0
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fef6875e285987d265328f4eb0fc5aebcaa8508c
|
4
|
+
data.tar.gz: 2cdd25d2e78400356af0770840830eb8026ce7cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8636d3d6a2581bda118b8e59827cf5da3f6c0a7e17389e4d55b82fb09f8214f11b6b128b59715de158a59e828d898833d63cb909ea2063f3f8c6726f89267a55
|
7
|
+
data.tar.gz: e6053ae4416c69d5e50a059fc5a0833b706a2e084a21ef93a4838954516a8e083e295e58ec2be08b7ca273ccfe67a09a38939c10ba124f7540afa30849fa6386
|
@@ -287,6 +287,7 @@ module Convection
|
|
287
287
|
attr_reader :name
|
288
288
|
attr_reader :template
|
289
289
|
attr_reader :properties
|
290
|
+
attr_reader :resource_attributes
|
290
291
|
attr_reader :exist
|
291
292
|
alias_method :exist?, :exist
|
292
293
|
|
@@ -298,6 +299,8 @@ module Convection
|
|
298
299
|
@deletion_policy = nil
|
299
300
|
@exist = false
|
300
301
|
|
302
|
+
@resource_attributes = []
|
303
|
+
|
301
304
|
## Instantiate properties
|
302
305
|
@properties = Model::Collection.new
|
303
306
|
resource = self
|
@@ -353,6 +356,7 @@ module Convection
|
|
353
356
|
'Type' => type,
|
354
357
|
'Properties' => properties.map(true, &:render)
|
355
358
|
}.tap do |resource|
|
359
|
+
resource_attributes.map { |a| a.render resource }
|
356
360
|
resource['DependsOn'] = @depends_on unless @depends_on.empty?
|
357
361
|
resource['DeletionPolicy'] = @deletion_policy unless @deletion_policy.nil?
|
358
362
|
render_condition(resource)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative '../resource'
|
2
|
+
|
3
|
+
module Convection
|
4
|
+
module Model
|
5
|
+
class Template
|
6
|
+
class Resource
|
7
|
+
##
|
8
|
+
# AWS::DirectoryService::SimpleAD
|
9
|
+
##
|
10
|
+
class DirectoryServiceSimpleAD < Resource
|
11
|
+
type 'AWS::DirectoryService::SimpleAD', :directoryservice_simple_ad
|
12
|
+
property :description, 'Description'
|
13
|
+
property :enable_sso, 'EnableSso'
|
14
|
+
property :name, 'Name'
|
15
|
+
property :password, 'Password'
|
16
|
+
property :short_name, 'ShortName'
|
17
|
+
property :size, 'Size'
|
18
|
+
property :vpc_settings, 'VpcSettings', :type => :hash
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Convection
|
2
|
+
module Model
|
3
|
+
class Template
|
4
|
+
# Base class for {http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-product-attribute-reference.html}
|
5
|
+
class ResourceAttribute
|
6
|
+
def initialize(parent)
|
7
|
+
parent.resource_attributes << self
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
## Require all resource attributes
|
15
|
+
Dir.glob(File.expand_path('../resource_attribute/*.rb', __FILE__)).map { |r| require r }
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require_relative '../resource_attribute'
|
2
|
+
|
3
|
+
module Convection
|
4
|
+
module Model
|
5
|
+
class Template
|
6
|
+
class ResourceAttribute
|
7
|
+
# Represents {http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-updatepolicy.html}
|
8
|
+
class UpdatePolicy < ResourceAttribute
|
9
|
+
@pause = 'PT5M'
|
10
|
+
@min_in_service = 0
|
11
|
+
@max_batch = 1
|
12
|
+
|
13
|
+
def pause_time(val)
|
14
|
+
@pause = val
|
15
|
+
end
|
16
|
+
|
17
|
+
def min_instances_in_service(val)
|
18
|
+
@min_in_service = val
|
19
|
+
end
|
20
|
+
|
21
|
+
def max_batch_size(val)
|
22
|
+
@max_batch = val
|
23
|
+
end
|
24
|
+
|
25
|
+
def render(resource)
|
26
|
+
resource.tap do |r|
|
27
|
+
r['UpdatePolicy'] = {
|
28
|
+
'AutoScalingScheduledAction' => {
|
29
|
+
'IgnoreUnmodifiedGroupSizeProperties' => true
|
30
|
+
},
|
31
|
+
'AutoScalingRollingUpdate' => {
|
32
|
+
'MinInstancesInService' => @min_in_service,
|
33
|
+
'MaxBatchSize' => @max_batch,
|
34
|
+
'WaitOnResourceSignals' => false,
|
35
|
+
'PauseTime' => @pause
|
36
|
+
}
|
37
|
+
}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
describe 'AWS::DirectoryService' do
|
5
|
+
let(:simple_ad_template) do
|
6
|
+
::Convection.template do
|
7
|
+
directoryservice_simple_ad 'SimpleActiveDirectory' do
|
8
|
+
description 'Example simple AD'
|
9
|
+
enable_sso false
|
10
|
+
name 'ExampleSimpleAD'
|
11
|
+
password 'directory.password'
|
12
|
+
short_name 'directory.name'
|
13
|
+
size 'Small'
|
14
|
+
|
15
|
+
vpc_settings 'SubnetIds', ['subnet-deadb33f']
|
16
|
+
vpc_settings 'VpcId', 'vpc-deadb33f'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'SimpleAD' do
|
22
|
+
it 'sets VpcSettings.SubnetIds' do
|
23
|
+
vpc_settings = simple_ad_json.fetch('Properties').fetch('VpcSettings')
|
24
|
+
assert_equal vpc_settings.fetch('SubnetIds'), ['subnet-deadb33f']
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'sets VpcSettings.VpcId' do
|
28
|
+
vpc_settings = simple_ad_json.fetch('Properties').fetch('VpcSettings')
|
29
|
+
assert_equal vpc_settings.fetch('VpcId'), 'vpc-deadb33f'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def simple_ad_json
|
36
|
+
JSON.parse(simple_ad_template.to_json)
|
37
|
+
.fetch('Resources')
|
38
|
+
.fetch('SimpleActiveDirectory')
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'json'
|
3
|
+
require 'pp'
|
4
|
+
|
5
|
+
class TestUpdatePolicies < Minitest::Test
|
6
|
+
def setup
|
7
|
+
@template = ::Convection.template do
|
8
|
+
description 'UpdatePolicies Test Template'
|
9
|
+
|
10
|
+
ec2_security_group 'MyEC2SecGroup' do
|
11
|
+
ingress_rule(:tcp, 80, 'my.ip.address')
|
12
|
+
end
|
13
|
+
|
14
|
+
auto_scaling_launch_configuration 'TestLaunchConfig' do
|
15
|
+
image_id 'ami-123'
|
16
|
+
instance_type 't2.nano'
|
17
|
+
|
18
|
+
security_group fn_ref('MyEC2SecGroup')
|
19
|
+
end
|
20
|
+
|
21
|
+
auto_scaling_auto_scaling_group 'TestAutoScalingGroup' do
|
22
|
+
launch_configuration_name fn_ref('TestLaunchConfig')
|
23
|
+
|
24
|
+
update_policy do
|
25
|
+
pause_time 'test_time'
|
26
|
+
min_instances_in_service 10
|
27
|
+
max_batch_size 2
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def from_json
|
34
|
+
JSON.parse(@template.to_json)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_update_policy
|
38
|
+
json = from_json['Resources']['TestAutoScalingGroup']
|
39
|
+
type = json['Type']
|
40
|
+
assert_equal 'AWS::AutoScaling::AutoScalingGroup', type
|
41
|
+
|
42
|
+
update_policy = json['UpdatePolicy']
|
43
|
+
refute update_policy.nil?, 'UpdatePolicy does not exist in the generated template'
|
44
|
+
|
45
|
+
pause_time = json['UpdatePolicy']['AutoScalingRollingUpdate']['PauseTime']
|
46
|
+
assert_equal 'test_time', pause_time
|
47
|
+
|
48
|
+
min_in_service = json['UpdatePolicy']['AutoScalingRollingUpdate']['MinInstancesInService']
|
49
|
+
assert_equal 10, min_in_service
|
50
|
+
|
51
|
+
max_batch_size = json['UpdatePolicy']['AutoScalingRollingUpdate']['MaxBatchSize']
|
52
|
+
assert_equal 2, max_batch_size
|
53
|
+
end
|
54
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: convection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Manero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- lib/convection/model/template/resource/aws_auto_scaling_scaling_policy.rb
|
133
133
|
- lib/convection/model/template/resource/aws_cloud_watch_alarm.rb
|
134
134
|
- lib/convection/model/template/resource/aws_cloudfront_distribution.rb
|
135
|
+
- lib/convection/model/template/resource/aws_directory_service_simple_ad.rb
|
135
136
|
- lib/convection/model/template/resource/aws_ec2_eip.rb
|
136
137
|
- lib/convection/model/template/resource/aws_ec2_eip_association.rb
|
137
138
|
- lib/convection/model/template/resource/aws_ec2_instance.rb
|
@@ -185,6 +186,8 @@ files:
|
|
185
186
|
- lib/convection/model/template/resource/aws_sns_topic_policy.rb
|
186
187
|
- lib/convection/model/template/resource/aws_sqs_queue.rb
|
187
188
|
- lib/convection/model/template/resource/aws_sqs_queue_policy.rb
|
189
|
+
- lib/convection/model/template/resource_attribute.rb
|
190
|
+
- lib/convection/model/template/resource_attribute/update_policy.rb
|
188
191
|
- lib/convection/model/template/resource_property.rb
|
189
192
|
- lib/convection/model/template/resource_property/aws_cloudfront_cachebehavior.rb
|
190
193
|
- lib/convection/model/template/resource_property/aws_cloudfront_customerrorresponse.rb
|
@@ -207,6 +210,7 @@ files:
|
|
207
210
|
- lib/convection/model/template/resource_property/aws_lambda_vpc_config.rb
|
208
211
|
- lib/convection/version.rb
|
209
212
|
- test/convection/model/test_conditions.rb
|
213
|
+
- test/convection/model/test_directory_service.rb
|
210
214
|
- test/convection/model/test_elasticache.rb
|
211
215
|
- test/convection/model/test_lambdas.rb
|
212
216
|
- test/convection/model/test_loggroups.rb
|
@@ -214,6 +218,7 @@ files:
|
|
214
218
|
- test/convection/model/test_rds.rb
|
215
219
|
- test/convection/model/test_template.rb
|
216
220
|
- test/convection/model/test_trust.rb
|
221
|
+
- test/convection/model/test_update_policies.rb
|
217
222
|
- test/convection/model/test_validation.rb
|
218
223
|
- test/convection/model/test_vpc_endpoint.rb
|
219
224
|
- test/test_helper.rb
|
@@ -243,6 +248,7 @@ specification_version: 4
|
|
243
248
|
summary: A fully generic, modular DSL for AWS CloudFormation
|
244
249
|
test_files:
|
245
250
|
- test/convection/model/test_conditions.rb
|
251
|
+
- test/convection/model/test_directory_service.rb
|
246
252
|
- test/convection/model/test_elasticache.rb
|
247
253
|
- test/convection/model/test_lambdas.rb
|
248
254
|
- test/convection/model/test_loggroups.rb
|
@@ -250,6 +256,7 @@ test_files:
|
|
250
256
|
- test/convection/model/test_rds.rb
|
251
257
|
- test/convection/model/test_template.rb
|
252
258
|
- test/convection/model/test_trust.rb
|
259
|
+
- test/convection/model/test_update_policies.rb
|
253
260
|
- test/convection/model/test_validation.rb
|
254
261
|
- test/convection/model/test_vpc_endpoint.rb
|
255
262
|
- test/test_helper.rb
|