convection 0.2.32 → 0.2.33

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +0 -1
  3. data/.rubocop_todo.yml +1 -2
  4. data/Gemfile +2 -1
  5. data/Rakefile +3 -7
  6. data/lib/convection.rb +2 -2
  7. data/lib/convection/control/stack.rb +49 -10
  8. data/lib/convection/model/event.rb +3 -2
  9. data/lib/convection/model/template.rb +13 -1
  10. data/lib/convection/model/template/metadata.rb +22 -0
  11. data/lib/convection/model/template/resource/aws_ec2_subnet.rb +1 -0
  12. data/lib/convection/model/template/resource/aws_events_rule.rb +4 -0
  13. data/spec/cf_client_context.rb +10 -0
  14. data/spec/collect_availability_zones_task_context.rb +17 -0
  15. data/spec/convection/control/stack/after_create_tasks_spec.rb +51 -0
  16. data/spec/convection/control/stack/after_delete_tasks_spec.rb +51 -0
  17. data/spec/convection/control/stack/after_update_tasks_spec.rb +54 -0
  18. data/spec/convection/control/stack/before_create_tasks_spec.rb +52 -0
  19. data/spec/convection/control/stack/before_delete_tasks_spec.rb +51 -0
  20. data/spec/convection/control/stack/before_update_tasks_spec.rb +55 -0
  21. data/spec/convection/dsl/intrinsic_functions_spec.rb +88 -0
  22. data/spec/convection/model/template/condition_spec.rb +38 -0
  23. data/spec/convection/model/template/resource/directoryservice_simple_ad_spec.rb +39 -0
  24. data/spec/convection/model/template/resource/ec2_security_group_spec.rb +39 -0
  25. data/spec/convection/model/template/resource/ec2_subnet_spec.rb +48 -0
  26. data/spec/convection/model/template/resource/elasticache_cache_cluster_spec.rb +52 -0
  27. data/spec/convection/model/template/resource/elasticache_parameter_group_spec.rb +38 -0
  28. data/spec/convection/model/template/resource/elasticache_security_group_ingress_spec.rb +40 -0
  29. data/spec/convection/model/template/resource/elasticache_security_group_spec.rb +32 -0
  30. data/spec/convection/model/template/resource/events_rule_spec.rb +44 -0
  31. data/spec/convection/model/template/resource/iam_role_spec.rb +37 -0
  32. data/spec/convection/model/template/resource/lambdas_spec.rb +70 -0
  33. data/spec/convection/model/template/resource/loggroups_spec.rb +34 -0
  34. data/spec/convection/model/template/resource/permission_spec.rb +43 -0
  35. data/spec/convection/model/template/resource/rds_security_groups_spec.rb +50 -0
  36. data/spec/convection/model/template/resource/vpc_endpoints_spec.rb +65 -0
  37. data/spec/convection/model/template/resource_attribute/update_policies_spec.rb +66 -0
  38. data/spec/convection/model/template/template_spec.rb +60 -0
  39. data/spec/convection/model/template/validate_bytesize_spec.rb +49 -0
  40. data/spec/convection/model/template/validate_description_spec.rb +31 -0
  41. data/spec/convection/model/template/validate_mappings_spec.rb +88 -0
  42. data/spec/convection/model/template/validate_outputs_spec.rb +62 -0
  43. data/spec/convection/model/template/validate_parameters_spec.rb +84 -0
  44. data/spec/convection/model/template/validate_resources_spec.rb +50 -0
  45. data/spec/ec2_client_context.rb +18 -0
  46. data/spec/spec_helper.rb +11 -0
  47. metadata +72 -40
  48. data/test/convection/model/test_conditions.rb +0 -121
  49. data/test/convection/model/test_directory_service.rb +0 -40
  50. data/test/convection/model/test_elasticache.rb +0 -97
  51. data/test/convection/model/test_lambdas.rb +0 -53
  52. data/test/convection/model/test_loggroups.rb +0 -25
  53. data/test/convection/model/test_permission.rb +0 -31
  54. data/test/convection/model/test_rds.rb +0 -76
  55. data/test/convection/model/test_template.rb +0 -64
  56. data/test/convection/model/test_trust.rb +0 -28
  57. data/test/convection/model/test_update_policies.rb +0 -54
  58. data/test/convection/model/test_validation.rb +0 -216
  59. data/test/convection/model/test_vpc_endpoint.rb +0 -51
  60. data/test/convection/tasks/test_after_create_tasks.rb +0 -66
  61. data/test/convection/tasks/test_after_delete_tasks.rb +0 -66
  62. data/test/convection/tasks/test_after_update_tasks.rb +0 -71
  63. data/test/convection/tasks/test_before_create_tasks.rb +0 -66
  64. data/test/convection/tasks/test_before_delete_tasks.rb +0 -66
  65. data/test/convection/tasks/test_before_update_tasks.rb +0 -71
  66. data/test/test_helper.rb +0 -72
@@ -1,51 +0,0 @@
1
- require 'test_helper'
2
- require 'json'
3
- require 'pp'
4
-
5
- class TestVpcEndpoint < Minitest::Test
6
- def setup
7
- @template = ::Convection.template do
8
- description 'VPC Endpoint Test Template'
9
-
10
- ec2_vpc_endpoint 'TestVpcEndpoint' do
11
- service 's3'
12
- vpc 'vpc-foo'
13
- route_tables %w(table1 table2)
14
-
15
- allow do
16
- s3_resource 'bucket-bar', '*'
17
- action 's3:GetObject'
18
- end
19
- end
20
- end
21
- end
22
-
23
- def from_json
24
- JSON.parse(@template.to_json)
25
- end
26
-
27
- def test_endpoint
28
- json = from_json['Resources']
29
-
30
- endpoint = json['TestVpcEndpoint']
31
- refute endpoint.nil?, 'VpcEndpoint not present in generated template'
32
-
33
- props = endpoint['Properties']
34
- assert_equal 'vpc-foo', props['VpcId']
35
-
36
- service_name = props['ServiceName']
37
- refute service_name.nil?, 'ServiceName not present in generated template'
38
-
39
- assert service_name.is_a? Hash
40
- s3_string_arr = service_name['Fn::Join']
41
- refute s3_string_arr.nil?, 'ServiceName value is not specified as a string array'
42
-
43
- assert s3_string_arr.is_a? Array
44
- assert_equal '.', s3_string_arr[0]
45
-
46
- s3_path_as_array = s3_string_arr[1]
47
- refute s3_path_as_array.nil?, "The path for S3 should be defined as an array in #{s3_string_arr}"
48
-
49
- assert s3_path_as_array.last == 's3', "ServiceName (#{s3_path_as_array}) does not contain \'s3\' as final element"
50
- end
51
- end
@@ -1,66 +0,0 @@
1
- require 'test_helper'
2
-
3
- class TestAfterCreateTasks < Minitest::Test
4
- include TestHelper
5
-
6
- def setup
7
- @template = ::Convection.template do
8
- description 'EC2 VPC Test Template'
9
-
10
- ec2_vpc 'TargetVPC' do
11
- network '10.0.0.0'
12
- subnet_length 24
13
- enable_dns
14
- end
15
- end
16
- end
17
-
18
- def test_after_create_task_is_registered
19
- Aws::CloudFormation::Client.stub :new, mock_cloudformation_client do
20
- Aws::EC2::Client.stub :new, mock_ec2_client do
21
- # when - a stack is initialized with a after_create_task
22
- stack = ::Convection::Control::Stack.new('EC2 VPC Test Stack', @template) do
23
- after_create_task CollectAvailabilityZonesTask.new
24
- end
25
-
26
- # then - at least one task should be present
27
- refute_empty stack.tasks[:after_create]
28
- end
29
- end
30
- end
31
-
32
- def test_after_create_task_is_executed
33
- Aws::CloudFormation::Client.stub :new, mock_cloudformation_client do
34
- Aws::EC2::Client.stub :new, mock_ec2_client do
35
- # given - a stack initialized with a after_create_task
36
- task = CollectAvailabilityZonesTask.new
37
- stack = ::Convection::Control::Stack.new('EC2 VPC Test Stack', @template) do
38
- after_create_task task
39
- end
40
-
41
- # when - any changes to the stack are applied
42
- stack.apply
43
-
44
- # then - the task should have been executed
45
- assert_includes task.availability_zones, 'eu-central-1'
46
- end
47
- end
48
- end
49
-
50
- def test_after_create_task_is_deregistered
51
- Aws::CloudFormation::Client.stub :new, mock_cloudformation_client do
52
- Aws::EC2::Client.stub :new, mock_ec2_client do
53
- # given - a stack initialized with a after_create_task
54
- stack = ::Convection::Control::Stack.new('EC2 VPC Test Stack', @template) do
55
- after_create_task CollectAvailabilityZonesTask.new
56
- end
57
-
58
- # when - any changes to the stack are applied
59
- stack.apply
60
-
61
- # then - the task should have been deregistered
62
- assert_empty stack.tasks[:after_create]
63
- end
64
- end
65
- end
66
- end
@@ -1,66 +0,0 @@
1
- require 'test_helper'
2
-
3
- class TestBeforeDeleteTasks < Minitest::Test
4
- include TestHelper
5
-
6
- def setup
7
- @template = ::Convection.template do
8
- description 'EC2 VPC Test Template'
9
-
10
- ec2_vpc 'TargetVPC' do
11
- network '10.0.0.0'
12
- subnet_length 24
13
- enable_dns
14
- end
15
- end
16
- end
17
-
18
- def test_after_delete_task_is_registered
19
- Aws::CloudFormation::Client.stub :new, mock_cloudformation_client do
20
- Aws::EC2::Client.stub :new, mock_ec2_client do
21
- # when - a stack is initialized with a after_delete_task
22
- stack = ::Convection::Control::Stack.new('EC2 VPC Test Stack', @template) do
23
- after_delete_task CollectAvailabilityZonesTask.new
24
- end
25
-
26
- # then - at least one task should be present
27
- refute_empty stack.tasks[:after_delete]
28
- end
29
- end
30
- end
31
-
32
- def test_after_delete_task_is_executed
33
- Aws::CloudFormation::Client.stub :new, mock_cloudformation_client do
34
- Aws::EC2::Client.stub :new, mock_ec2_client do
35
- # given - a stack initialized with a after_delete_task
36
- task = CollectAvailabilityZonesTask.new
37
- stack = ::Convection::Control::Stack.new('EC2 VPC Test Stack', @template) do
38
- after_delete_task task
39
- end
40
-
41
- # when - any changes to the stack are applied
42
- stack.delete
43
-
44
- # then - the task should have been executed
45
- assert_includes task.availability_zones, 'eu-central-1'
46
- end
47
- end
48
- end
49
-
50
- def test_after_delete_task_is_deregistered
51
- Aws::CloudFormation::Client.stub :new, mock_cloudformation_client do
52
- Aws::EC2::Client.stub :new, mock_ec2_client do
53
- # given - a stack initialized with a after_delete_task
54
- stack = ::Convection::Control::Stack.new('EC2 VPC Test Stack', @template) do
55
- after_delete_task CollectAvailabilityZonesTask.new
56
- end
57
-
58
- # when - any changes to the stack are applied
59
- stack.delete
60
-
61
- # then - the task should have been deregistered
62
- assert_empty stack.tasks[:after_delete]
63
- end
64
- end
65
- end
66
- end
@@ -1,71 +0,0 @@
1
- require 'test_helper'
2
-
3
- class TestAfterUpdateTasks < Minitest::Test
4
- include TestHelper
5
-
6
- def setup
7
- @template = ::Convection.template do
8
- description 'EC2 VPC Test Template'
9
-
10
- ec2_vpc 'TargetVPC' do
11
- network '10.0.0.0'
12
- subnet_length 24
13
- enable_dns
14
- end
15
- end
16
- end
17
-
18
- def test_after_update_task_is_registered
19
- Aws::CloudFormation::Client.stub :new, mock_cloudformation_client do
20
- Aws::EC2::Client.stub :new, mock_ec2_client do
21
- # when - a stack is initialized with a after_update_task
22
- task = CollectAvailabilityZonesTask.new
23
- stack = ::Convection::Control::Stack.new('EC2 VPC Test Stack', @template) do
24
- after_update_task task
25
- end
26
-
27
- # then - the given stack should be present
28
- assert_includes stack.tasks[:after_update], task
29
- end
30
- end
31
- end
32
-
33
- def test_after_update_task_is_executed
34
- Aws::CloudFormation::Client.stub :new, mock_cloudformation_client do
35
- Aws::EC2::Client.stub :new, mock_ec2_client do
36
- # given - a stack initialized with a after_update_task
37
- task = CollectAvailabilityZonesTask.new
38
- stack = ::Convection::Control::Stack.new('EC2 VPC Test Stack', @template) do
39
- after_update_task task
40
- end
41
-
42
- # when - any changes to the stack are applied
43
- stub_existence(stack, true) do
44
- stack.apply
45
- end
46
-
47
- # then - the task should have been executed
48
- assert_includes task.availability_zones, 'eu-central-1'
49
- end
50
- end
51
- end
52
-
53
- def test_after_update_task_is_deregistered
54
- Aws::CloudFormation::Client.stub :new, mock_cloudformation_client do
55
- Aws::EC2::Client.stub :new, mock_ec2_client do
56
- # given - a stack initialized with a after_update_task
57
- stack = ::Convection::Control::Stack.new('EC2 VPC Test Stack', @template) do
58
- after_update_task CollectAvailabilityZonesTask.new
59
- end
60
-
61
- # when - any changes to the stack are applied
62
- stub_existence(stack, true) do
63
- stack.apply
64
- end
65
-
66
- # then - the task should have been deregistered
67
- assert_empty stack.tasks[:after_update]
68
- end
69
- end
70
- end
71
- end
@@ -1,66 +0,0 @@
1
- require 'test_helper'
2
-
3
- class TestBeforeCreateTasks < Minitest::Test
4
- include TestHelper
5
-
6
- def setup
7
- @template = ::Convection.template do
8
- description 'EC2 VPC Test Template'
9
-
10
- ec2_vpc 'TargetVPC' do
11
- network '10.0.0.0'
12
- subnet_length 24
13
- enable_dns
14
- end
15
- end
16
- end
17
-
18
- def test_before_create_task_is_registered
19
- Aws::CloudFormation::Client.stub :new, mock_cloudformation_client do
20
- Aws::EC2::Client.stub :new, mock_ec2_client do
21
- # when - a stack is initialized with a before_create_task
22
- stack = ::Convection::Control::Stack.new('EC2 VPC Test Stack', @template) do
23
- before_create_task CollectAvailabilityZonesTask.new
24
- end
25
-
26
- # then - at least one task should be present
27
- refute_empty stack.tasks[:before_create]
28
- end
29
- end
30
- end
31
-
32
- def test_before_create_task_is_executed
33
- Aws::CloudFormation::Client.stub :new, mock_cloudformation_client do
34
- Aws::EC2::Client.stub :new, mock_ec2_client do
35
- # given - a stack initialized with a before_create_task
36
- task = CollectAvailabilityZonesTask.new
37
- stack = ::Convection::Control::Stack.new('EC2 VPC Test Stack', @template) do
38
- before_create_task task
39
- end
40
-
41
- # when - any changes to the stack are applied
42
- stack.apply
43
-
44
- # then - the task should have been executed
45
- assert_includes task.availability_zones, 'eu-central-1'
46
- end
47
- end
48
- end
49
-
50
- def test_before_create_task_is_deregistered
51
- Aws::CloudFormation::Client.stub :new, mock_cloudformation_client do
52
- Aws::EC2::Client.stub :new, mock_ec2_client do
53
- # given - a stack initialized with a before_create_task
54
- stack = ::Convection::Control::Stack.new('EC2 VPC Test Stack', @template) do
55
- before_create_task CollectAvailabilityZonesTask.new
56
- end
57
-
58
- # when - any changes to the stack are applied
59
- stack.apply
60
-
61
- # then - the task should have been deregistered
62
- assert_empty stack.tasks[:before_create]
63
- end
64
- end
65
- end
66
- end
@@ -1,66 +0,0 @@
1
- require 'test_helper'
2
-
3
- class TestBeforeDeleteTasks < Minitest::Test
4
- include TestHelper
5
-
6
- def setup
7
- @template = ::Convection.template do
8
- description 'EC2 VPC Test Template'
9
-
10
- ec2_vpc 'TargetVPC' do
11
- network '10.0.0.0'
12
- subnet_length 24
13
- enable_dns
14
- end
15
- end
16
- end
17
-
18
- def test_before_delete_task_is_registered
19
- Aws::CloudFormation::Client.stub :new, mock_cloudformation_client do
20
- Aws::EC2::Client.stub :new, mock_ec2_client do
21
- # when - a stack is initialized with a before_delete_task
22
- stack = ::Convection::Control::Stack.new('EC2 VPC Test Stack', @template) do
23
- before_delete_task CollectAvailabilityZonesTask.new
24
- end
25
-
26
- # then - at least one task should be present
27
- refute_empty stack.tasks[:before_delete]
28
- end
29
- end
30
- end
31
-
32
- def test_before_delete_task_is_executed
33
- Aws::CloudFormation::Client.stub :new, mock_cloudformation_client do
34
- Aws::EC2::Client.stub :new, mock_ec2_client do
35
- # given - a stack initialized with a before_delete_task
36
- task = CollectAvailabilityZonesTask.new
37
- stack = ::Convection::Control::Stack.new('EC2 VPC Test Stack', @template) do
38
- before_delete_task task
39
- end
40
-
41
- # when - any changes to the stack are applied
42
- stack.delete
43
-
44
- # then - the task should have been executed
45
- assert_includes task.availability_zones, 'eu-central-1'
46
- end
47
- end
48
- end
49
-
50
- def test_before_delete_task_is_deregistered
51
- Aws::CloudFormation::Client.stub :new, mock_cloudformation_client do
52
- Aws::EC2::Client.stub :new, mock_ec2_client do
53
- # given - a stack initialized with a before_delete_task
54
- stack = ::Convection::Control::Stack.new('EC2 VPC Test Stack', @template) do
55
- before_delete_task CollectAvailabilityZonesTask.new
56
- end
57
-
58
- # when - any changes to the stack are applied
59
- stack.delete
60
-
61
- # then - the task should have been deregistered
62
- assert_empty stack.tasks[:before_delete]
63
- end
64
- end
65
- end
66
- end
@@ -1,71 +0,0 @@
1
- require 'test_helper'
2
-
3
- class TestBeforeUpdateTasks < Minitest::Test
4
- include TestHelper
5
-
6
- def setup
7
- @template = ::Convection.template do
8
- description 'EC2 VPC Test Template'
9
-
10
- ec2_vpc 'TargetVPC' do
11
- network '10.0.0.0'
12
- subnet_length 24
13
- enable_dns
14
- end
15
- end
16
- end
17
-
18
- def test_before_update_task_is_registered
19
- Aws::CloudFormation::Client.stub :new, mock_cloudformation_client do
20
- Aws::EC2::Client.stub :new, mock_ec2_client do
21
- # when - a stack is initialized with a before_update_task
22
- task = CollectAvailabilityZonesTask.new
23
- stack = ::Convection::Control::Stack.new('EC2 VPC Test Stack', @template) do
24
- before_update_task task
25
- end
26
-
27
- # then - the given stack should be present
28
- assert_includes stack.tasks[:before_update], task
29
- end
30
- end
31
- end
32
-
33
- def test_before_update_task_is_executed
34
- Aws::CloudFormation::Client.stub :new, mock_cloudformation_client do
35
- Aws::EC2::Client.stub :new, mock_ec2_client do
36
- # given - a stack initialized with a before_update_task
37
- task = CollectAvailabilityZonesTask.new
38
- stack = ::Convection::Control::Stack.new('EC2 VPC Test Stack', @template) do
39
- before_update_task task
40
- end
41
-
42
- # when - any changes to the stack are applied
43
- stub_existence(stack, true) do
44
- stack.apply
45
- end
46
-
47
- # then - the task should have been executed
48
- assert_includes task.availability_zones, 'eu-central-1'
49
- end
50
- end
51
- end
52
-
53
- def test_before_update_task_is_deregistered
54
- Aws::CloudFormation::Client.stub :new, mock_cloudformation_client do
55
- Aws::EC2::Client.stub :new, mock_ec2_client do
56
- # given - a stack initialized with a before_update_task
57
- stack = ::Convection::Control::Stack.new('EC2 VPC Test Stack', @template) do
58
- before_update_task CollectAvailabilityZonesTask.new
59
- end
60
-
61
- # when - any changes to the stack are applied
62
- stub_existence(stack, true) do
63
- stack.apply
64
- end
65
-
66
- # then - the task should have been deregistered
67
- assert_empty stack.tasks[:before_update]
68
- end
69
- end
70
- end
71
- end