chef-provisioning-aws 3.0.4 → 3.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +16 -5
  3. data/Rakefile +15 -6
  4. data/chef-provisioning-aws.gemspec +17 -17
  5. data/lib/chef/provider/aws_auto_scaling_group.rb +5 -6
  6. data/lib/chef/provider/aws_cache_cluster.rb +21 -15
  7. data/lib/chef/provider/aws_cache_replication_group.rb +12 -8
  8. data/lib/chef/provider/aws_cache_subnet_group.rb +3 -3
  9. data/lib/chef/provider/aws_cloudsearch_domain.rb +9 -13
  10. data/lib/chef/provider/aws_cloudwatch_alarm.rb +10 -12
  11. data/lib/chef/provider/aws_dhcp_options.rb +18 -21
  12. data/lib/chef/provider/aws_ebs_volume.rb +24 -26
  13. data/lib/chef/provider/aws_eip_address.rb +10 -13
  14. data/lib/chef/provider/aws_elasticsearch_domain.rb +19 -18
  15. data/lib/chef/provider/aws_iam_instance_profile.rb +5 -7
  16. data/lib/chef/provider/aws_iam_role.rb +14 -17
  17. data/lib/chef/provider/aws_image.rb +6 -6
  18. data/lib/chef/provider/aws_instance.rb +5 -5
  19. data/lib/chef/provider/aws_internet_gateway.rb +8 -11
  20. data/lib/chef/provider/aws_key_pair.rb +15 -17
  21. data/lib/chef/provider/aws_launch_configuration.rb +11 -14
  22. data/lib/chef/provider/aws_load_balancer.rb +1 -2
  23. data/lib/chef/provider/aws_nat_gateway.rb +6 -7
  24. data/lib/chef/provider/aws_network_acl.rb +28 -29
  25. data/lib/chef/provider/aws_network_interface.rb +25 -27
  26. data/lib/chef/provider/aws_rds_instance.rb +12 -13
  27. data/lib/chef/provider/aws_rds_parameter_group.rb +8 -8
  28. data/lib/chef/provider/aws_rds_subnet_group.rb +8 -9
  29. data/lib/chef/provider/aws_route_table.rb +19 -20
  30. data/lib/chef/provider/aws_s3_bucket.rb +22 -25
  31. data/lib/chef/provider/aws_security_group.rb +268 -285
  32. data/lib/chef/provider/aws_server_certificate.rb +6 -5
  33. data/lib/chef/provider/aws_sns_topic.rb +4 -6
  34. data/lib/chef/provider/aws_sqs_queue.rb +3 -4
  35. data/lib/chef/provider/aws_subnet.rb +29 -34
  36. data/lib/chef/provider/aws_vpc.rb +108 -116
  37. data/lib/chef/provider/aws_vpc_peering_connection.rb +11 -11
  38. data/lib/chef/provisioning/aws_driver.rb +4 -2
  39. data/lib/chef/provisioning/aws_driver/aws_provider.rb +234 -241
  40. data/lib/chef/provisioning/aws_driver/aws_rds_resource.rb +5 -7
  41. data/lib/chef/provisioning/aws_driver/aws_resource.rb +182 -185
  42. data/lib/chef/provisioning/aws_driver/aws_resource_with_entry.rb +17 -17
  43. data/lib/chef/provisioning/aws_driver/aws_taggable.rb +13 -15
  44. data/lib/chef/provisioning/aws_driver/aws_tagger.rb +47 -48
  45. data/lib/chef/provisioning/aws_driver/credentials.rb +96 -100
  46. data/lib/chef/provisioning/aws_driver/credentials2.rb +42 -45
  47. data/lib/chef/provisioning/aws_driver/driver.rb +1349 -1362
  48. data/lib/chef/provisioning/aws_driver/exceptions.rb +10 -12
  49. data/lib/chef/provisioning/aws_driver/super_lwrp.rb +60 -60
  50. data/lib/chef/provisioning/aws_driver/tagging_strategy/auto_scaling.rb +49 -50
  51. data/lib/chef/provisioning/aws_driver/tagging_strategy/ec2.rb +37 -38
  52. data/lib/chef/provisioning/aws_driver/tagging_strategy/elasticsearch.rb +14 -15
  53. data/lib/chef/provisioning/aws_driver/tagging_strategy/elb.rb +29 -31
  54. data/lib/chef/provisioning/aws_driver/tagging_strategy/rds.rb +39 -40
  55. data/lib/chef/provisioning/aws_driver/tagging_strategy/s3.rb +41 -43
  56. data/lib/chef/provisioning/aws_driver/version.rb +5 -5
  57. data/lib/chef/provisioning/driver_init/aws.rb +2 -2
  58. data/lib/chef/resource/aws_auto_scaling_group.rb +1 -1
  59. data/lib/chef/resource/aws_cache_cluster.rb +9 -12
  60. data/lib/chef/resource/aws_cache_replication_group.rb +9 -11
  61. data/lib/chef/resource/aws_cache_subnet_group.rb +8 -10
  62. data/lib/chef/resource/aws_cloudsearch_domain.rb +4 -5
  63. data/lib/chef/resource/aws_cloudwatch_alarm.rb +17 -18
  64. data/lib/chef/resource/aws_dhcp_options.rb +2 -2
  65. data/lib/chef/resource/aws_ebs_volume.rb +10 -10
  66. data/lib/chef/resource/aws_eip_address.rb +5 -5
  67. data/lib/chef/resource/aws_elasticsearch_domain.rb +4 -4
  68. data/lib/chef/resource/aws_iam_instance_profile.rb +4 -5
  69. data/lib/chef/resource/aws_iam_role.rb +2 -3
  70. data/lib/chef/resource/aws_image.rb +3 -3
  71. data/lib/chef/resource/aws_instance.rb +4 -4
  72. data/lib/chef/resource/aws_internet_gateway.rb +3 -3
  73. data/lib/chef/resource/aws_key_pair.rb +7 -7
  74. data/lib/chef/resource/aws_launch_configuration.rb +4 -4
  75. data/lib/chef/resource/aws_load_balancer.rb +7 -7
  76. data/lib/chef/resource/aws_nat_gateway.rb +11 -11
  77. data/lib/chef/resource/aws_network_acl.rb +7 -8
  78. data/lib/chef/resource/aws_network_interface.rb +9 -9
  79. data/lib/chef/resource/aws_rds_instance.rb +4 -4
  80. data/lib/chef/resource/aws_rds_parameter_group.rb +3 -3
  81. data/lib/chef/resource/aws_rds_subnet_group.rb +4 -4
  82. data/lib/chef/resource/aws_route53_hosted_zone.rb +37 -40
  83. data/lib/chef/resource/aws_route53_record_set.rb +22 -24
  84. data/lib/chef/resource/aws_route_table.rb +7 -7
  85. data/lib/chef/resource/aws_s3_bucket.rb +7 -7
  86. data/lib/chef/resource/aws_security_group.rb +10 -10
  87. data/lib/chef/resource/aws_server_certificate.rb +6 -8
  88. data/lib/chef/resource/aws_sns_topic.rb +2 -2
  89. data/lib/chef/resource/aws_sqs_queue.rb +5 -7
  90. data/lib/chef/resource/aws_subnet.rb +9 -9
  91. data/lib/chef/resource/aws_vpc.rb +11 -11
  92. data/lib/chef/resource/aws_vpc_peering_connection.rb +4 -4
  93. data/spec/aws_support.rb +44 -45
  94. data/spec/aws_support/aws_resource_run_wrapper.rb +2 -2
  95. data/spec/aws_support/deep_matcher.rb +2 -3
  96. data/spec/aws_support/deep_matcher/fuzzy_match_objects.rb +6 -9
  97. data/spec/aws_support/deep_matcher/match_values_failure_messages.rb +30 -37
  98. data/spec/aws_support/deep_matcher/matchable_array.rb +0 -1
  99. data/spec/aws_support/deep_matcher/matchable_object.rb +1 -2
  100. data/spec/aws_support/deep_matcher/rspec_monkeypatches.rb +4 -4
  101. data/spec/aws_support/delayed_stream.rb +2 -2
  102. data/spec/aws_support/matchers/create_an_aws_object.rb +6 -6
  103. data/spec/aws_support/matchers/destroy_an_aws_object.rb +6 -6
  104. data/spec/aws_support/matchers/have_aws_object_tags.rb +4 -5
  105. data/spec/aws_support/matchers/match_an_aws_object.rb +5 -6
  106. data/spec/aws_support/matchers/update_an_aws_object.rb +6 -7
  107. data/spec/integration/aws_auto_scaling_group_spec.rb +56 -64
  108. data/spec/integration/aws_cache_cluster_spec.rb +70 -71
  109. data/spec/integration/aws_cache_subnet_group_spec.rb +13 -14
  110. data/spec/integration/aws_cloudsearch_domain_spec.rb +6 -8
  111. data/spec/integration/aws_cloudwatch_alarm_spec.rb +200 -208
  112. data/spec/integration/aws_dhcp_options_spec.rb +32 -43
  113. data/spec/integration/aws_ebs_volume_spec.rb +52 -73
  114. data/spec/integration/aws_eip_address_spec.rb +24 -31
  115. data/spec/integration/aws_elasticsearch_domain_spec.rb +31 -33
  116. data/spec/integration/aws_iam_instance_profile_spec.rb +36 -45
  117. data/spec/integration/aws_iam_role_spec.rb +39 -46
  118. data/spec/integration/aws_internet_gateway_spec.rb +64 -75
  119. data/spec/integration/aws_key_pair_spec.rb +6 -6
  120. data/spec/integration/aws_launch_configuration_spec.rb +17 -18
  121. data/spec/integration/aws_nat_gateway_spec.rb +21 -24
  122. data/spec/integration/aws_network_acl_spec.rb +81 -95
  123. data/spec/integration/aws_network_interface_spec.rb +28 -43
  124. data/spec/integration/aws_rds_instance_spec.rb +29 -40
  125. data/spec/integration/aws_rds_parameter_group_spec.rb +32 -35
  126. data/spec/integration/aws_rds_subnet_group_spec.rb +30 -40
  127. data/spec/integration/aws_route53_hosted_zone_spec.rb +205 -205
  128. data/spec/integration/aws_route_table_spec.rb +118 -136
  129. data/spec/integration/aws_s3_bucket_spec.rb +19 -27
  130. data/spec/integration/aws_security_group_spec.rb +369 -388
  131. data/spec/integration/aws_server_certificate_spec.rb +16 -18
  132. data/spec/integration/aws_subnet_spec.rb +44 -58
  133. data/spec/integration/aws_vpc_peering_connection_spec.rb +43 -50
  134. data/spec/integration/aws_vpc_spec.rb +99 -115
  135. data/spec/integration/load_balancer_spec.rb +169 -183
  136. data/spec/integration/machine_batch_spec.rb +24 -31
  137. data/spec/integration/machine_image_spec.rb +54 -66
  138. data/spec/integration/machine_spec.rb +216 -237
  139. data/spec/persistence_file.txt +219 -0
  140. data/spec/spec_helper.rb +16 -17
  141. data/spec/unit/chef/provisioning/aws_driver/credentials_spec.rb +67 -74
  142. data/spec/unit/chef/provisioning/aws_driver/driver_spec.rb +29 -29
  143. data/spec/unit/chef/provisioning/aws_driver/route53_spec.rb +13 -15
  144. metadata +4 -3
@@ -1,71 +1,70 @@
1
- require 'spec_helper'
2
-
3
- describe Chef::Resource::AwsCacheCluster, :super_slow do
4
- extend AWSSupport
5
-
6
- when_the_chef_12_server "exists", organization: 'foo', server_scope: :context do
7
- with_aws "with a VPC, subnet, subnet_group and security_group" do
8
- after(:context) do
9
- # Cache Cluster takes around 7 minutes to get deleted
10
- # and all the dependent resources can be deleted after that only.
11
- # Hence waiting for 8 minutes.
12
- sleep(480)
13
- converge {
14
- aws_cache_subnet_group 'test-subnet-group' do
15
- action :destroy
16
- end
17
-
18
- aws_vpc "test_vpc" do
19
- action :purge
20
- end
21
- }
22
- end
23
-
24
- it "aws_cache_cluster 'TestRedisCluster' creates a cache cluster" do
25
- converge {
26
- aws_vpc "test_vpc" do
27
- cidr_block '10.0.0.0/24'
28
- internet_gateway true
29
- end
30
-
31
- aws_subnet "test_subnet" do
32
- vpc 'test_vpc'
33
- cidr_block "10.0.0.0/24"
34
- end
35
-
36
- aws_cache_subnet_group 'test-subnet-group' do
37
- description 'Test Subnet Group'
38
- subnets [ 'test_subnet' ]
39
- end
40
-
41
- aws_security_group 'test_sg' do
42
- vpc 'test_vpc'
43
- end
44
- }
45
-
46
- expect_recipe {
47
- aws_cache_cluster 'TestRedisCluster' do
48
- az_mode 'single-az'
49
- engine 'redis'
50
- engine_version '3.2.6'
51
- node_type 'cache.t2.micro'
52
- number_nodes 1
53
- security_groups 'test_sg'
54
- subnet_group_name 'test-subnet-group'
55
- end
56
- }.to create_an_aws_cache_cluster('TestRedisCluster',
57
- cache_cluster_id: "testrediscluster",
58
- cache_node_type: "cache.t2.micro",
59
- engine: "redis",
60
- engine_version: "3.2.6",
61
- num_cache_nodes: 1,
62
- pending_modified_values: {},
63
- cache_security_groups: [],
64
- cache_parameter_group:
65
- {cache_parameter_group_name: "default.redis3.2", parameter_apply_status: "in-sync", cache_node_ids_to_reboot: []},
66
- cache_subnet_group_name: "test-subnet-group"
67
- ).and be_idempotent
68
- end
69
- end
70
- end
71
- end
1
+ require "spec_helper"
2
+
3
+ describe Chef::Resource::AwsCacheCluster, :super_slow do
4
+ extend AWSSupport
5
+
6
+ when_the_chef_12_server "exists", organization: "foo", server_scope: :context do
7
+ with_aws "with a VPC, subnet, subnet_group and security_group" do
8
+ after(:context) do
9
+ # Cache Cluster takes around 7 minutes to get deleted
10
+ # and all the dependent resources can be deleted after that only.
11
+ # Hence waiting for 8 minutes.
12
+ sleep(480)
13
+ converge do
14
+ aws_cache_subnet_group "test-subnet-group" do
15
+ action :destroy
16
+ end
17
+
18
+ aws_vpc "test_vpc" do
19
+ action :purge
20
+ end
21
+ end
22
+ end
23
+
24
+ it "aws_cache_cluster 'TestRedisCluster' creates a cache cluster" do
25
+ converge do
26
+ aws_vpc "test_vpc" do
27
+ cidr_block "10.0.0.0/24"
28
+ internet_gateway true
29
+ end
30
+
31
+ aws_subnet "test_subnet" do
32
+ vpc "test_vpc"
33
+ cidr_block "10.0.0.0/24"
34
+ end
35
+
36
+ aws_cache_subnet_group "test-subnet-group" do
37
+ description "Test Subnet Group"
38
+ subnets ["test_subnet"]
39
+ end
40
+
41
+ aws_security_group "test_sg" do
42
+ vpc "test_vpc"
43
+ end
44
+ end
45
+
46
+ expect_recipe do
47
+ aws_cache_cluster "TestRedisCluster" do
48
+ az_mode "single-az"
49
+ engine "redis"
50
+ engine_version "3.2.6"
51
+ node_type "cache.t2.micro"
52
+ number_nodes 1
53
+ security_groups "test_sg"
54
+ subnet_group_name "test-subnet-group"
55
+ end
56
+ end.to create_an_aws_cache_cluster("TestRedisCluster",
57
+ cache_cluster_id: "testrediscluster",
58
+ cache_node_type: "cache.t2.micro",
59
+ engine: "redis",
60
+ engine_version: "3.2.6",
61
+ num_cache_nodes: 1,
62
+ pending_modified_values: {},
63
+ cache_security_groups: [],
64
+ cache_parameter_group:
65
+ { cache_parameter_group_name: "default.redis3.2", parameter_apply_status: "in-sync", cache_node_ids_to_reboot: [] },
66
+ cache_subnet_group_name: "test-subnet-group").and be_idempotent
67
+ end
68
+ end
69
+ end
70
+ end
@@ -1,32 +1,31 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Chef::Resource::AwsCacheSubnetGroup do
4
4
  extend AWSSupport
5
5
 
6
- when_the_chef_12_server "exists", organization: 'foo', server_scope: :context do
6
+ when_the_chef_12_server "exists", organization: "foo", server_scope: :context do
7
7
  with_aws "with a VPC with an internet gateway and subnet" do
8
8
  aws_vpc "test_vpc" do
9
- cidr_block '10.0.0.0/24'
9
+ cidr_block "10.0.0.0/24"
10
10
  internet_gateway true
11
11
  end
12
12
 
13
13
  aws_subnet "test_subnet" do
14
- vpc 'test_vpc'
14
+ vpc "test_vpc"
15
15
  cidr_block "10.0.0.0/24"
16
16
  end
17
17
 
18
18
  it "aws_cache_subnet_group 'test-subnet-group' creates a cache subnet group" do
19
- expect_recipe {
20
- aws_cache_subnet_group 'test-subnet-group' do
21
- description 'Test Subnet Group'
22
- subnets [ 'test_subnet' ]
19
+ expect_recipe do
20
+ aws_cache_subnet_group "test-subnet-group" do
21
+ description "Test Subnet Group"
22
+ subnets ["test_subnet"]
23
23
  end
24
- }.to create_an_aws_cache_subnet_group('test-subnet-group',
25
- vpc_id: test_vpc.aws_object.id,
26
- subnets: [
27
- { subnet_identifier: test_subnet.aws_object.id }
28
- ]
29
- ).and be_idempotent
24
+ end.to create_an_aws_cache_subnet_group("test-subnet-group",
25
+ vpc_id: test_vpc.aws_object.id,
26
+ subnets: [
27
+ { subnet_identifier: test_subnet.aws_object.id }
28
+ ]).and be_idempotent
30
29
  end
31
30
  end
32
31
  end
@@ -1,31 +1,29 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Chef::Resource::AwsCloudsearchDomain do
4
4
  extend AWSSupport
5
5
  when_the_chef_12_server "exists", organization: "foo", server_scope: :context do
6
6
  with_aws "when connected to AWS" do
7
-
8
7
  # Cloudsearch can take forevvvver to delete so we need to randomize our names
9
- time = DateTime.now.strftime('%Q')
8
+ time = DateTime.now.strftime("%Q")
10
9
 
11
10
  it "aws_cloudsearch_domain 'test-#{time}' creates a cloudsearch domain" do
12
- expect_recipe {
11
+ expect_recipe do
13
12
  aws_cloudsearch_domain "test-#{time}" do
14
13
  multi_az false
15
14
  end
16
- }.to create_an_aws_cloudsearch_domain("test-#{time}", {}).and be_idempotent
15
+ end.to create_an_aws_cloudsearch_domain("test-#{time}", {}).and be_idempotent
17
16
  end
18
17
 
19
18
  it "returns nil when aws_object is called for something that does not exist" do
20
19
  r = nil
21
- converge {
20
+ converge do
22
21
  r = aws_cloudsearch_domain "wont-exist" do
23
22
  action :nothing
24
23
  end
25
- }
24
+ end
26
25
  expect(r.aws_object).to eq(nil)
27
26
  end
28
-
29
27
  end
30
28
  end
31
29
  end
@@ -1,286 +1,278 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Chef::Resource::AwsCloudwatchAlarm do
4
4
  extend AWSSupport
5
5
 
6
- when_the_chef_12_server 'exists', organization: 'foo', server_scope: :context do
7
- with_aws 'When connected to AWS' do
8
-
9
- aws_sns_topic 'mytesttopic1'
10
- aws_sns_topic 'mytesttopic2'
6
+ when_the_chef_12_server "exists", organization: "foo", server_scope: :context do
7
+ with_aws "When connected to AWS" do
8
+ aws_sns_topic "mytesttopic1"
9
+ aws_sns_topic "mytesttopic2"
11
10
 
12
11
  it "creates an aws_cloudwatch_alarm with minimum properties" do
13
- expect_recipe {
14
- aws_cloudwatch_alarm 'my-test-alert' do
15
- namespace 'AWS/EC2'
16
- metric_name 'CPUUtilization'
17
- comparison_operator 'GreaterThanThreshold'
12
+ expect_recipe do
13
+ aws_cloudwatch_alarm "my-test-alert" do
14
+ namespace "AWS/EC2"
15
+ metric_name "CPUUtilization"
16
+ comparison_operator "GreaterThanThreshold"
18
17
  evaluation_periods 1
19
18
  period 60
20
- statistic 'Average'
19
+ statistic "Average"
21
20
  threshold 80
22
21
  end
23
- }.to create_an_aws_cloudwatch_alarm('my-test-alert',
24
- namespace: 'AWS/EC2',
25
- metric_name: 'CPUUtilization',
26
- comparison_operator: 'GreaterThanThreshold',
27
- evaluation_periods: 1,
28
- period: 60,
29
- statistic: 'Average',
30
- threshold: 80,
31
- actions_enabled: true # this is true by default
32
- ).and be_idempotent
22
+ end.to create_an_aws_cloudwatch_alarm("my-test-alert",
23
+ namespace: "AWS/EC2",
24
+ metric_name: "CPUUtilization",
25
+ comparison_operator: "GreaterThanThreshold",
26
+ evaluation_periods: 1,
27
+ period: 60,
28
+ statistic: "Average",
29
+ threshold: 80,
30
+ actions_enabled: true # this is true by default
31
+ ).and be_idempotent
33
32
  end
34
33
 
35
34
  it "creates an aws_cloudwatch_alarm with maximum properties" do
36
- expect_recipe {
37
- aws_cloudwatch_alarm 'my-test-alert' do
38
- namespace 'AWS/EC2'
39
- metric_name 'CPUUtilization'
40
- comparison_operator 'GreaterThanThreshold'
35
+ expect_recipe do
36
+ aws_cloudwatch_alarm "my-test-alert" do
37
+ namespace "AWS/EC2"
38
+ metric_name "CPUUtilization"
39
+ comparison_operator "GreaterThanThreshold"
41
40
  evaluation_periods 1
42
41
  period 60
43
- statistic 'Average'
42
+ statistic "Average"
44
43
  threshold 80
45
44
  dimensions([
46
- {
47
- name: "foo1",
48
- value: "bar1"
49
- },
50
- {
51
- name: "foo2",
52
- value: "bar2"
53
- }
54
- ])
55
- insufficient_data_actions ['mytesttopic1']
56
- ok_actions ['mytesttopic1']
57
- alarm_actions ['mytesttopic1']
45
+ {
46
+ name: "foo1",
47
+ value: "bar1"
48
+ },
49
+ {
50
+ name: "foo2",
51
+ value: "bar2"
52
+ }
53
+ ])
54
+ insufficient_data_actions ["mytesttopic1"]
55
+ ok_actions ["mytesttopic1"]
56
+ alarm_actions ["mytesttopic1"]
58
57
  actions_enabled false
59
58
  alarm_description "description"
60
59
  unit "Percent"
61
60
  end
62
- }.to create_an_aws_cloudwatch_alarm('my-test-alert',
63
- namespace: 'AWS/EC2',
64
- metric_name: 'CPUUtilization',
65
- comparison_operator: 'GreaterThanThreshold',
66
- evaluation_periods: 1,
67
- period: 60,
68
- statistic: 'Average',
69
- threshold: 80,
70
- dimensions: [
71
- {
72
- name: "foo1",
73
- value: "bar1"
74
- },
75
- {
76
- name: "foo2",
77
- value: "bar2"
78
- }
79
- ],
80
- insufficient_data_actions: [mytesttopic1.aws_object.attributes["TopicArn"]],
81
- ok_actions: [mytesttopic1.aws_object.attributes["TopicArn"]],
82
- alarm_actions: [mytesttopic1.aws_object.attributes["TopicArn"]],
83
- actions_enabled: false,
84
- alarm_description: "description",
85
- unit: "Percent",
86
- ).and be_idempotent
61
+ end.to create_an_aws_cloudwatch_alarm("my-test-alert",
62
+ namespace: "AWS/EC2",
63
+ metric_name: "CPUUtilization",
64
+ comparison_operator: "GreaterThanThreshold",
65
+ evaluation_periods: 1,
66
+ period: 60,
67
+ statistic: "Average",
68
+ threshold: 80,
69
+ dimensions: [
70
+ {
71
+ name: "foo1",
72
+ value: "bar1"
73
+ },
74
+ {
75
+ name: "foo2",
76
+ value: "bar2"
77
+ }
78
+ ],
79
+ insufficient_data_actions: [mytesttopic1.aws_object.attributes["TopicArn"]],
80
+ ok_actions: [mytesttopic1.aws_object.attributes["TopicArn"]],
81
+ alarm_actions: [mytesttopic1.aws_object.attributes["TopicArn"]],
82
+ actions_enabled: false,
83
+ alarm_description: "description",
84
+ unit: "Percent").and be_idempotent
87
85
  end
88
86
 
89
87
  context "with an existing minimum cloudwatch alarm" do
90
- aws_cloudwatch_alarm 'my-test-alert' do
91
- namespace 'AWS/EC2'
92
- metric_name 'CPUUtilization'
93
- comparison_operator 'GreaterThanThreshold'
88
+ aws_cloudwatch_alarm "my-test-alert" do
89
+ namespace "AWS/EC2"
90
+ metric_name "CPUUtilization"
91
+ comparison_operator "GreaterThanThreshold"
94
92
  evaluation_periods 1
95
93
  period 60
96
- statistic 'Average'
94
+ statistic "Average"
97
95
  threshold 80
98
96
  end
99
97
 
100
98
  it "updates an aws_cloudwatch_alarm with maximum properties" do
101
- expect_recipe {
102
- aws_cloudwatch_alarm 'my-test-alert' do
103
- namespace 'AWS/EC2'
104
- metric_name 'CPUUtilization'
105
- comparison_operator 'GreaterThanThreshold'
99
+ expect_recipe do
100
+ aws_cloudwatch_alarm "my-test-alert" do
101
+ namespace "AWS/EC2"
102
+ metric_name "CPUUtilization"
103
+ comparison_operator "GreaterThanThreshold"
106
104
  evaluation_periods 1
107
105
  period 60
108
- statistic 'Average'
106
+ statistic "Average"
109
107
  threshold 80
110
108
  dimensions([
111
- {
112
- name: "foo1",
113
- value: "bar1"
114
- },
115
- {
116
- name: "foo2",
117
- value: "bar2"
118
- }
119
- ])
120
- insufficient_data_actions ['mytesttopic1']
121
- ok_actions ['mytesttopic1']
122
- alarm_actions ['mytesttopic1']
109
+ {
110
+ name: "foo1",
111
+ value: "bar1"
112
+ },
113
+ {
114
+ name: "foo2",
115
+ value: "bar2"
116
+ }
117
+ ])
118
+ insufficient_data_actions ["mytesttopic1"]
119
+ ok_actions ["mytesttopic1"]
120
+ alarm_actions ["mytesttopic1"]
123
121
  actions_enabled false
124
122
  alarm_description "description"
125
123
  unit "Percent"
126
124
  end
127
- }.to update_an_aws_cloudwatch_alarm('my-test-alert',
128
- namespace: 'AWS/EC2',
129
- metric_name: 'CPUUtilization',
130
- comparison_operator: 'GreaterThanThreshold',
131
- evaluation_periods: 1,
132
- period: 60,
133
- statistic: 'Average',
134
- threshold: 80,
135
- dimensions: [
136
- {
137
- name: "foo1",
138
- value: "bar1"
139
- },
140
- {
141
- name: "foo2",
142
- value: "bar2"
143
- }
144
- ],
145
- insufficient_data_actions: [mytesttopic1.aws_object.attributes["TopicArn"]],
146
- ok_actions: [mytesttopic1.aws_object.attributes["TopicArn"]],
147
- alarm_actions: [mytesttopic1.aws_object.attributes["TopicArn"]],
148
- actions_enabled: false,
149
- alarm_description: "description",
150
- unit: "Percent",
151
- ).and be_idempotent
125
+ end.to update_an_aws_cloudwatch_alarm("my-test-alert",
126
+ namespace: "AWS/EC2",
127
+ metric_name: "CPUUtilization",
128
+ comparison_operator: "GreaterThanThreshold",
129
+ evaluation_periods: 1,
130
+ period: 60,
131
+ statistic: "Average",
132
+ threshold: 80,
133
+ dimensions: [
134
+ {
135
+ name: "foo1",
136
+ value: "bar1"
137
+ },
138
+ {
139
+ name: "foo2",
140
+ value: "bar2"
141
+ }
142
+ ],
143
+ insufficient_data_actions: [mytesttopic1.aws_object.attributes["TopicArn"]],
144
+ ok_actions: [mytesttopic1.aws_object.attributes["TopicArn"]],
145
+ alarm_actions: [mytesttopic1.aws_object.attributes["TopicArn"]],
146
+ actions_enabled: false,
147
+ alarm_description: "description",
148
+ unit: "Percent").and be_idempotent
152
149
  end
153
-
154
150
  end
155
151
 
156
152
  context "with an existing maximum cloudwatch alarm" do
157
- aws_cloudwatch_alarm 'my-test-alert' do
158
- namespace 'AWS/EC2'
159
- metric_name 'CPUUtilization'
160
- comparison_operator 'GreaterThanThreshold'
153
+ aws_cloudwatch_alarm "my-test-alert" do
154
+ namespace "AWS/EC2"
155
+ metric_name "CPUUtilization"
156
+ comparison_operator "GreaterThanThreshold"
161
157
  evaluation_periods 1
162
158
  period 60
163
- statistic 'Average'
159
+ statistic "Average"
164
160
  threshold 80
165
161
  dimensions([
166
- {
167
- name: "foo1",
168
- value: "bar1"
169
- },
170
- {
171
- name: "foo2",
172
- value: "bar2"
173
- }
174
- ])
175
- insufficient_data_actions ['mytesttopic1']
176
- ok_actions ['mytesttopic1']
177
- alarm_actions ['mytesttopic1']
162
+ {
163
+ name: "foo1",
164
+ value: "bar1"
165
+ },
166
+ {
167
+ name: "foo2",
168
+ value: "bar2"
169
+ }
170
+ ])
171
+ insufficient_data_actions ["mytesttopic1"]
172
+ ok_actions ["mytesttopic1"]
173
+ alarm_actions ["mytesttopic1"]
178
174
  actions_enabled false
179
175
  alarm_description "description"
180
176
  unit "Percent"
181
177
  end
182
178
 
183
179
  it "updates all updateable attributes" do
184
- expect_recipe {
185
- aws_cloudwatch_alarm 'my-test-alert' do
186
- namespace 'AWS/S3'
187
- metric_name 'foo'
188
- comparison_operator 'LessThanThreshold'
180
+ expect_recipe do
181
+ aws_cloudwatch_alarm "my-test-alert" do
182
+ namespace "AWS/S3"
183
+ metric_name "foo"
184
+ comparison_operator "LessThanThreshold"
189
185
  evaluation_periods 2
190
186
  period 120
191
- statistic 'Maximum'
187
+ statistic "Maximum"
192
188
  threshold 70
193
189
  dimensions([
194
- {
195
- name: "foo3",
196
- value: "bar3"
197
- }
198
- ])
199
- insufficient_data_actions ['mytesttopic2']
200
- ok_actions ['mytesttopic1', 'mytesttopic2']
201
- alarm_actions ['mytesttopic2']
190
+ {
191
+ name: "foo3",
192
+ value: "bar3"
193
+ }
194
+ ])
195
+ insufficient_data_actions ["mytesttopic2"]
196
+ ok_actions %w{mytesttopic1 mytesttopic2}
197
+ alarm_actions ["mytesttopic2"]
202
198
  actions_enabled true
203
199
  alarm_description "description2"
204
200
  unit "Bits"
205
201
  end
206
- }.to update_an_aws_cloudwatch_alarm('my-test-alert',
207
- namespace: 'AWS/S3',
208
- metric_name: 'foo',
209
- comparison_operator: 'LessThanThreshold',
210
- evaluation_periods: 2,
211
- period: 120,
212
- statistic: 'Maximum',
213
- threshold: 70,
214
- dimensions: [
215
- {
216
- name: "foo3",
217
- value: "bar3"
218
- }
219
- ],
220
- insufficient_data_actions: [mytesttopic2.aws_object.attributes["TopicArn"]],
221
- ok_actions: Set[mytesttopic1.aws_object.attributes["TopicArn"], mytesttopic2.aws_object.attributes["TopicArn"]],
222
- alarm_actions: [mytesttopic2.aws_object.attributes["TopicArn"]],
223
- actions_enabled: true,
224
- alarm_description: "description2",
225
- unit: "Bits",
226
- ).and be_idempotent
202
+ end.to update_an_aws_cloudwatch_alarm("my-test-alert",
203
+ namespace: "AWS/S3",
204
+ metric_name: "foo",
205
+ comparison_operator: "LessThanThreshold",
206
+ evaluation_periods: 2,
207
+ period: 120,
208
+ statistic: "Maximum",
209
+ threshold: 70,
210
+ dimensions: [
211
+ {
212
+ name: "foo3",
213
+ value: "bar3"
214
+ }
215
+ ],
216
+ insufficient_data_actions: [mytesttopic2.aws_object.attributes["TopicArn"]],
217
+ ok_actions: Set[mytesttopic1.aws_object.attributes["TopicArn"], mytesttopic2.aws_object.attributes["TopicArn"]],
218
+ alarm_actions: [mytesttopic2.aws_object.attributes["TopicArn"]],
219
+ actions_enabled: true,
220
+ alarm_description: "description2",
221
+ unit: "Bits").and be_idempotent
227
222
  end
228
223
 
229
224
  it "updates only the specified properties" do
230
- expect_recipe {
231
- aws_cloudwatch_alarm 'my-test-alert' do
225
+ expect_recipe do
226
+ aws_cloudwatch_alarm "my-test-alert" do
232
227
  unit "Gigabytes"
233
228
  end
234
- }.to update_an_aws_cloudwatch_alarm('my-test-alert',
235
- namespace: 'AWS/S3',
236
- metric_name: 'foo',
237
- comparison_operator: 'LessThanThreshold',
238
- evaluation_periods: 2,
239
- period: 120,
240
- statistic: 'Maximum',
241
- threshold: 70,
242
- dimensions: [
243
- {
244
- name: "foo3",
245
- value: "bar3"
246
- }
247
- ],
248
- insufficient_data_actions: [mytesttopic2.aws_object.attributes["TopicArn"]],
249
- ok_actions: Set[mytesttopic1.aws_object.attributes["TopicArn"], mytesttopic2.aws_object.attributes["TopicArn"]],
250
- alarm_actions: [mytesttopic2.aws_object.attributes["TopicArn"]],
251
- actions_enabled: true,
252
- alarm_description: "description2",
253
- unit: "Gigabytes",
254
- ).and be_idempotent
229
+ end.to update_an_aws_cloudwatch_alarm("my-test-alert",
230
+ namespace: "AWS/S3",
231
+ metric_name: "foo",
232
+ comparison_operator: "LessThanThreshold",
233
+ evaluation_periods: 2,
234
+ period: 120,
235
+ statistic: "Maximum",
236
+ threshold: 70,
237
+ dimensions: [
238
+ {
239
+ name: "foo3",
240
+ value: "bar3"
241
+ }
242
+ ],
243
+ insufficient_data_actions: [mytesttopic2.aws_object.attributes["TopicArn"]],
244
+ ok_actions: Set[mytesttopic1.aws_object.attributes["TopicArn"], mytesttopic2.aws_object.attributes["TopicArn"]],
245
+ alarm_actions: [mytesttopic2.aws_object.attributes["TopicArn"]],
246
+ actions_enabled: true,
247
+ alarm_description: "description2",
248
+ unit: "Gigabytes").and be_idempotent
255
249
  end
256
250
 
257
251
  it "clears out all clearable arrays" do
258
- expect_recipe {
259
- aws_cloudwatch_alarm 'my-test-alert' do
252
+ expect_recipe do
253
+ aws_cloudwatch_alarm "my-test-alert" do
260
254
  dimensions []
261
255
  insufficient_data_actions []
262
256
  ok_actions []
263
257
  alarm_actions []
264
258
  end
265
- }.to create_an_aws_cloudwatch_alarm('my-test-alert',
266
- namespace: 'AWS/S3',
267
- metric_name: 'foo',
268
- comparison_operator: 'LessThanThreshold',
269
- evaluation_periods: 2,
270
- period: 120,
271
- statistic: 'Maximum',
272
- threshold: 70,
273
- dimensions: [],
274
- insufficient_data_actions: [],
275
- ok_actions: [],
276
- alarm_actions: [],
277
- actions_enabled: true,
278
- alarm_description: "description2",
279
- unit: "Gigabytes",
280
- ).and be_idempotent
259
+ end.to create_an_aws_cloudwatch_alarm("my-test-alert",
260
+ namespace: "AWS/S3",
261
+ metric_name: "foo",
262
+ comparison_operator: "LessThanThreshold",
263
+ evaluation_periods: 2,
264
+ period: 120,
265
+ statistic: "Maximum",
266
+ threshold: 70,
267
+ dimensions: [],
268
+ insufficient_data_actions: [],
269
+ ok_actions: [],
270
+ alarm_actions: [],
271
+ actions_enabled: true,
272
+ alarm_description: "description2",
273
+ unit: "Gigabytes").and be_idempotent
281
274
  end
282
275
  end
283
-
284
276
  end
285
277
  end
286
278
  end