convection 0.2.32 → 0.2.33
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +0 -1
- data/.rubocop_todo.yml +1 -2
- data/Gemfile +2 -1
- data/Rakefile +3 -7
- data/lib/convection.rb +2 -2
- data/lib/convection/control/stack.rb +49 -10
- data/lib/convection/model/event.rb +3 -2
- data/lib/convection/model/template.rb +13 -1
- data/lib/convection/model/template/metadata.rb +22 -0
- data/lib/convection/model/template/resource/aws_ec2_subnet.rb +1 -0
- data/lib/convection/model/template/resource/aws_events_rule.rb +4 -0
- data/spec/cf_client_context.rb +10 -0
- data/spec/collect_availability_zones_task_context.rb +17 -0
- data/spec/convection/control/stack/after_create_tasks_spec.rb +51 -0
- data/spec/convection/control/stack/after_delete_tasks_spec.rb +51 -0
- data/spec/convection/control/stack/after_update_tasks_spec.rb +54 -0
- data/spec/convection/control/stack/before_create_tasks_spec.rb +52 -0
- data/spec/convection/control/stack/before_delete_tasks_spec.rb +51 -0
- data/spec/convection/control/stack/before_update_tasks_spec.rb +55 -0
- data/spec/convection/dsl/intrinsic_functions_spec.rb +88 -0
- data/spec/convection/model/template/condition_spec.rb +38 -0
- data/spec/convection/model/template/resource/directoryservice_simple_ad_spec.rb +39 -0
- data/spec/convection/model/template/resource/ec2_security_group_spec.rb +39 -0
- data/spec/convection/model/template/resource/ec2_subnet_spec.rb +48 -0
- data/spec/convection/model/template/resource/elasticache_cache_cluster_spec.rb +52 -0
- data/spec/convection/model/template/resource/elasticache_parameter_group_spec.rb +38 -0
- data/spec/convection/model/template/resource/elasticache_security_group_ingress_spec.rb +40 -0
- data/spec/convection/model/template/resource/elasticache_security_group_spec.rb +32 -0
- data/spec/convection/model/template/resource/events_rule_spec.rb +44 -0
- data/spec/convection/model/template/resource/iam_role_spec.rb +37 -0
- data/spec/convection/model/template/resource/lambdas_spec.rb +70 -0
- data/spec/convection/model/template/resource/loggroups_spec.rb +34 -0
- data/spec/convection/model/template/resource/permission_spec.rb +43 -0
- data/spec/convection/model/template/resource/rds_security_groups_spec.rb +50 -0
- data/spec/convection/model/template/resource/vpc_endpoints_spec.rb +65 -0
- data/spec/convection/model/template/resource_attribute/update_policies_spec.rb +66 -0
- data/spec/convection/model/template/template_spec.rb +60 -0
- data/spec/convection/model/template/validate_bytesize_spec.rb +49 -0
- data/spec/convection/model/template/validate_description_spec.rb +31 -0
- data/spec/convection/model/template/validate_mappings_spec.rb +88 -0
- data/spec/convection/model/template/validate_outputs_spec.rb +62 -0
- data/spec/convection/model/template/validate_parameters_spec.rb +84 -0
- data/spec/convection/model/template/validate_resources_spec.rb +50 -0
- data/spec/ec2_client_context.rb +18 -0
- data/spec/spec_helper.rb +11 -0
- metadata +72 -40
- data/test/convection/model/test_conditions.rb +0 -121
- data/test/convection/model/test_directory_service.rb +0 -40
- data/test/convection/model/test_elasticache.rb +0 -97
- data/test/convection/model/test_lambdas.rb +0 -53
- data/test/convection/model/test_loggroups.rb +0 -25
- data/test/convection/model/test_permission.rb +0 -31
- data/test/convection/model/test_rds.rb +0 -76
- data/test/convection/model/test_template.rb +0 -64
- data/test/convection/model/test_trust.rb +0 -28
- data/test/convection/model/test_update_policies.rb +0 -54
- data/test/convection/model/test_validation.rb +0 -216
- data/test/convection/model/test_vpc_endpoint.rb +0 -51
- data/test/convection/tasks/test_after_create_tasks.rb +0 -66
- data/test/convection/tasks/test_after_delete_tasks.rb +0 -66
- data/test/convection/tasks/test_after_update_tasks.rb +0 -71
- data/test/convection/tasks/test_before_create_tasks.rb +0 -66
- data/test/convection/tasks/test_before_delete_tasks.rb +0 -66
- data/test/convection/tasks/test_before_update_tasks.rb +0 -71
- data/test/test_helper.rb +0 -72
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class Convection::Model::Template::ResourceAttribute
|
4
|
+
describe UpdatePolicy do
|
5
|
+
let(:template) do
|
6
|
+
Convection.template do
|
7
|
+
description 'UpdatePolicies Test Template'
|
8
|
+
|
9
|
+
ec2_security_group 'MyEC2SecGroup' do
|
10
|
+
ingress_rule(:tcp, 80, 'my.ip.address')
|
11
|
+
end
|
12
|
+
|
13
|
+
auto_scaling_launch_configuration 'TestLaunchConfig' do
|
14
|
+
image_id 'ami-123'
|
15
|
+
instance_type 't2.nano'
|
16
|
+
|
17
|
+
security_group fn_ref('MyEC2SecGroup')
|
18
|
+
end
|
19
|
+
|
20
|
+
auto_scaling_auto_scaling_group 'TestAutoScalingGroup' do
|
21
|
+
launch_configuration_name fn_ref('TestLaunchConfig')
|
22
|
+
|
23
|
+
update_policy do
|
24
|
+
pause_time 'test_time'
|
25
|
+
min_instances_in_service 10
|
26
|
+
max_batch_size 2
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
subject do
|
33
|
+
template_json
|
34
|
+
.fetch('Resources')
|
35
|
+
.fetch('TestAutoScalingGroup')
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'Type is defined correctly' do
|
39
|
+
expect(subject['Type']).to eq('AWS::AutoScaling::AutoScalingGroup')
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'UpdatePolicy is defiend' do
|
43
|
+
expect(subject['UpdatePolicy']).to_not eq(nil)
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'UpdatePolicy PauseTime is defined correctly' do
|
47
|
+
expect(subject['UpdatePolicy']['AutoScalingRollingUpdate']['PauseTime']).to eq('test_time')
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'UpdatePolicy MinInstancesInService is defined correctly' do
|
51
|
+
expect(subject['UpdatePolicy']['AutoScalingRollingUpdate']['MinInstancesInService']).to eq(10)
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'UpdatePolicy MaxBatchSize is defined correctly' do
|
55
|
+
expect(subject['UpdatePolicy']['AutoScalingRollingUpdate']['MaxBatchSize']).to eq(2)
|
56
|
+
end
|
57
|
+
|
58
|
+
# TODO: add tests for TestLaunchConfig and MyEC2SecGroup
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def template_json
|
63
|
+
JSON.parse(template.to_json)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class Convection::Model::Template
|
4
|
+
describe self do
|
5
|
+
let(:template) do
|
6
|
+
Convection.template do
|
7
|
+
description 'Test Template'
|
8
|
+
|
9
|
+
ec2_instance 'TestInstance1' do
|
10
|
+
availability_zone 'us-east-1'
|
11
|
+
image_id 'ami-asdf83'
|
12
|
+
end
|
13
|
+
|
14
|
+
ec2_instance 'TestInstance2' do
|
15
|
+
availability_zone 'us-west-1'
|
16
|
+
image_id 'ami-lda34f'
|
17
|
+
depends_on 'TestInstance1'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
subject do
|
23
|
+
template_json
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'template format version is 2010-09-09 ' do
|
27
|
+
expect(subject['AWSTemplateFormatVersion']).to eq('2010-09-09')
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'Template descriptions are set correctly' do
|
31
|
+
expect(subject['Description']).to eq('Test Template')
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'template TestInstance1 has properties' do
|
35
|
+
expect(subject['Resources']['TestInstance1']['Properties']).to_not eq(nil)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'TestInstance1 Type is AWS::EC2::Instance' do
|
39
|
+
expect(subject['Resources']['TestInstance1']['Type']).to eq('AWS::EC2::Instance')
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'DependsOn values are set correctly' do
|
43
|
+
expect(subject['Resources']['TestInstance2']['DependsOn'][0]).to eq('TestInstance1')
|
44
|
+
end
|
45
|
+
|
46
|
+
it { is_expected.to have_key('Parameters') }
|
47
|
+
|
48
|
+
it { is_expected.to have_key('Mappings') }
|
49
|
+
|
50
|
+
it { is_expected.to have_key('Conditions') }
|
51
|
+
|
52
|
+
it { is_expected.to have_key('Resources') }
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def template_json
|
57
|
+
JSON.parse(template.to_json)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class Convection::Model::Template
|
4
|
+
describe '#validate_bytesize' do
|
5
|
+
context 'with a regular Template bytesize' do
|
6
|
+
subject do
|
7
|
+
Convection.template do
|
8
|
+
description 'Validations Test Template - Regular Bytesize'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'does not raise an excessive description error' do
|
13
|
+
rendered = subject.render
|
14
|
+
expect { subject.validate(rendered) }.to_not raise_error
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'with excessive Template bytesize' do
|
19
|
+
subject do
|
20
|
+
Convection.template do
|
21
|
+
description 'Validations Test Template - Excessive Bytesize'
|
22
|
+
|
23
|
+
200.times do |count|
|
24
|
+
resource "EC2_INSTANCE_#{count}" do
|
25
|
+
type 'AWS::EC2::Instance'
|
26
|
+
property 'AvailabilityZone', 'us-east-1a'
|
27
|
+
property 'ImageId', 'ami-76e27e1e'
|
28
|
+
property 'KeyName', 'test'
|
29
|
+
property 'SecurityGroupIds', ['sg-dd733c41', 'sg-dd738df3']
|
30
|
+
property 'Tags', [{ 'Key' => 'Name', 'Value' => 'test-1' }]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
80.times do |count|
|
35
|
+
mapping "Mapping_#{count}" do
|
36
|
+
item 'us-east-1', 'test', 'cf-test-keys'
|
37
|
+
item 'us-west-1', 'test', 'cf-test-keys'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'raises an excessive description error' do
|
44
|
+
rendered = subject.render
|
45
|
+
expect { subject.validate(rendered) }.to raise_error(ExcessiveTemplateSizeError)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class Convection::Model::Template
|
4
|
+
describe '#validate_description' do
|
5
|
+
context 'with a regular Description bytesize' do
|
6
|
+
subject do
|
7
|
+
Convection.template do
|
8
|
+
description '0' * CF_MAX_DESCRIPTION_BYTESIZE
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'does not raise an excessive description error' do
|
13
|
+
rendered = subject.render
|
14
|
+
expect { subject.validate(rendered) }.to_not raise_error
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'with excessive Description bytesize' do
|
19
|
+
subject do
|
20
|
+
Convection.template do
|
21
|
+
description '0' * (CF_MAX_DESCRIPTION_BYTESIZE + 1)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'raises an excessive description error' do
|
26
|
+
rendered = subject.render
|
27
|
+
expect { subject.validate(rendered) }.to raise_error(ExcessiveDescriptionError)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class Convection::Model::Template
|
4
|
+
describe '#validate_mappings' do
|
5
|
+
context 'with a regular Mappings' do
|
6
|
+
subject do
|
7
|
+
Convection.template do
|
8
|
+
mapping 'Mapping0' do
|
9
|
+
item 'us-east-1', 'test', 'cf-test-keys'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'does not raise an excessive mappings error' do
|
15
|
+
rendered = subject.render
|
16
|
+
expect { subject.validate(rendered) }.to_not raise_error
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'with excessive Mappings' do
|
21
|
+
subject do
|
22
|
+
Convection.template do
|
23
|
+
(CF_MAX_MAPPINGS + 1).times do |i|
|
24
|
+
mapping "Mapping#{i}" do
|
25
|
+
item 'us-east-1', 'test', 'cf-test-keys'
|
26
|
+
item 'us-west-1', 'test', 'cf-test-keys'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'raises an excessive mappings error' do
|
33
|
+
rendered = subject.render
|
34
|
+
expect { subject.validate(rendered) }.to raise_error(ExcessiveMappingsError)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'with excessive Mappings Name' do
|
39
|
+
subject do
|
40
|
+
Convection.template do
|
41
|
+
mapping_name = '0' * (CF_MAX_MAPPING_NAME + 1)
|
42
|
+
mapping mapping_name do
|
43
|
+
item 'us-east-1', 'test', 'cf-test-keys'
|
44
|
+
item 'us-west-1', 'test', 'cf-test-keys'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'raises an excessive mappings error' do
|
50
|
+
rendered = subject.render
|
51
|
+
expect { subject.validate(rendered) }.to raise_error(ExcessiveMappingNameError)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'with excessive Mappings Attributes' do
|
56
|
+
subject do
|
57
|
+
Convection.template do
|
58
|
+
mapping 'Mapping0' do
|
59
|
+
(CF_MAX_MAPPING_ATTRIBUTES + 1).times do |i|
|
60
|
+
item "#{i}1", "#{i}2", "#{i}3"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'raises an excessive mapping attributes error' do
|
67
|
+
rendered = subject.render
|
68
|
+
expect { subject.validate(rendered) }.to raise_error(ExcessiveMappingAttributesError)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'with excessive Mappings Attribute names' do
|
73
|
+
subject do
|
74
|
+
Convection.template do
|
75
|
+
mapping 'Mapping0' do
|
76
|
+
attribute_name = '0' * (CF_MAX_MAPPING_ATTRIBUTE_NAME + 1)
|
77
|
+
item attribute_name, 'value', 'value'
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'raises an excessive mapping attribute names error' do
|
83
|
+
rendered = subject.render
|
84
|
+
expect { subject.validate(rendered) }.to raise_error(ExcessiveMappingAttributeNameError)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class Convection::Model::Template
|
4
|
+
describe '#validate_outputs' do
|
5
|
+
context 'with regular Output count/name' do
|
6
|
+
subject do
|
7
|
+
Convection.template do
|
8
|
+
description 'Validations Test Template - Regular Output Name'
|
9
|
+
|
10
|
+
output 'TestOutput' do
|
11
|
+
description 'An Important Attribute'
|
12
|
+
value get_att('Resource', 'Attribute')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'does not raise an output count/name error' do
|
18
|
+
rendered = subject.render
|
19
|
+
expect { subject.validate(rendered) }.to_not raise_error
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'with excessive Output Name' do
|
24
|
+
subject do
|
25
|
+
Convection.template do
|
26
|
+
description 'Validations Test Template - Excessive Output Name'
|
27
|
+
|
28
|
+
output_name = '0' * (CF_MAX_OUTPUT_NAME_CHARACTERS + 1)
|
29
|
+
output output_name do
|
30
|
+
description 'An Important Attribute'
|
31
|
+
value get_att('Resource', 'Attribute')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'raises an excessive output name error' do
|
37
|
+
rendered = subject.render
|
38
|
+
expect { subject.validate(rendered) }.to raise_error(ExcessiveOutputNameError)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'with excessive Outputs' do
|
43
|
+
subject do
|
44
|
+
Convection.template do
|
45
|
+
description 'Validations Test Template - Too Many Outputs'
|
46
|
+
|
47
|
+
(CF_MAX_OUTPUTS + 1).times do |i|
|
48
|
+
output "TestOutput#{i}" do
|
49
|
+
description 'An Important Attribute'
|
50
|
+
value get_att('Resource', 'Attribute')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'raises an excessive outputs error' do
|
57
|
+
rendered = subject.render
|
58
|
+
expect { subject.validate(rendered) }.to raise_error(ExcessiveOutputsError)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class Convection::Model::Template
|
4
|
+
describe '#validate_parameters' do
|
5
|
+
context 'with regular Parameter count/name' do
|
6
|
+
subject do
|
7
|
+
Convection.template do
|
8
|
+
description 'Validations Test Template - Regular Parameter Name'
|
9
|
+
|
10
|
+
parameter 'Parameter0' do
|
11
|
+
type 'String'
|
12
|
+
description 'Example Parameter'
|
13
|
+
default 'm3.medium'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'does not raise an parameter count/name error' do
|
19
|
+
rendered = subject.render
|
20
|
+
expect { subject.validate(rendered) }.to_not raise_error
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'with excessive Parameter Bytesize' do
|
25
|
+
subject do
|
26
|
+
Convection.template do
|
27
|
+
description 'Validations Test Template - Excessive Parameter Bytesize'
|
28
|
+
|
29
|
+
parameter 'Parameter0' do
|
30
|
+
type 'String'
|
31
|
+
description 'Example Parameter'
|
32
|
+
default '0' * (CF_MAX_PARAMETER_VALUE_BYTESIZE + 1)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'raises an excessive parameter bytesize error' do
|
38
|
+
rendered = subject.render
|
39
|
+
expect { subject.validate(rendered) }.to raise_error(ExcessiveParameterBytesizeError)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'with excessive Parameter Name' do
|
44
|
+
subject do
|
45
|
+
Convection.template do
|
46
|
+
description 'Validations Test Template - Excessive Parameter Name'
|
47
|
+
|
48
|
+
parameter_name = '0' * (CF_MAX_PARAMETER_NAME_CHARACTERS + 1)
|
49
|
+
parameter parameter_name do
|
50
|
+
type 'String'
|
51
|
+
description 'Example Parameter'
|
52
|
+
default 'm3.medium'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'raises an excessive parameter name error' do
|
58
|
+
rendered = subject.render
|
59
|
+
expect { subject.validate(rendered) }.to raise_error(ExcessiveParameterNameError)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'with excessive Parameters' do
|
64
|
+
subject do
|
65
|
+
Convection.template do
|
66
|
+
description 'Validations Test Template - Too Many Parameters'
|
67
|
+
|
68
|
+
(CF_MAX_PARAMETERS + 1).times do |i|
|
69
|
+
parameter "Parameter#{i}" do
|
70
|
+
type 'String'
|
71
|
+
description 'Example Parameter'
|
72
|
+
default 'm3.medium'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'raises an excessive parameters error' do
|
79
|
+
rendered = subject.render
|
80
|
+
expect { subject.validate(rendered) }.to raise_error(ExcessiveParametersError)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|