kumogata-template 0.0.35 → 0.0.36

Sign up to get free protection for your applications and to get access to all the features.
Files changed (278) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +4 -2
  3. data/Gemfile +1 -1
  4. data/Rakefile +1 -1
  5. data/kumogata-template.gemspec +4 -4
  6. data/lib/kumogata/template/alb.rb +48 -34
  7. data/lib/kumogata/template/api-gateway.rb +262 -0
  8. data/lib/kumogata/template/autoscaling.rb +17 -44
  9. data/lib/kumogata/template/certificate.rb +11 -8
  10. data/lib/kumogata/template/cloudfront.rb +67 -60
  11. data/lib/kumogata/template/cloudwatch.rb +7 -12
  12. data/lib/kumogata/template/codebuild.rb +4 -8
  13. data/lib/kumogata/template/codecommit.rb +2 -6
  14. data/lib/kumogata/template/codedeploy.rb +15 -0
  15. data/lib/kumogata/template/cognito.rb +203 -0
  16. data/lib/kumogata/template/const.rb +109 -47
  17. data/lib/kumogata/template/datapipeline.rb +16 -47
  18. data/lib/kumogata/template/dynamodb.rb +17 -8
  19. data/lib/kumogata/template/ec2.rb +61 -10
  20. data/lib/kumogata/template/ecr.rb +11 -9
  21. data/lib/kumogata/template/ecs.rb +256 -91
  22. data/lib/kumogata/template/elasticbeanstalk.rb +6 -9
  23. data/lib/kumogata/template/elb.rb +9 -24
  24. data/lib/kumogata/template/emr.rb +184 -51
  25. data/lib/kumogata/template/events.rb +22 -10
  26. data/lib/kumogata/template/ext/kumogata.rb +7 -7
  27. data/lib/kumogata/template/helper.rb +189 -130
  28. data/lib/kumogata/template/iam.rb +556 -146
  29. data/lib/kumogata/template/kinesis.rb +282 -0
  30. data/lib/kumogata/template/lambda.rb +43 -2
  31. data/lib/kumogata/template/logs.rb +2 -6
  32. data/lib/kumogata/template/nlb.rb +10 -0
  33. data/lib/kumogata/template/pinpoint.rb +83 -0
  34. data/lib/kumogata/template/rds.rb +52 -0
  35. data/lib/kumogata/template/redshift.rb +15 -6
  36. data/lib/kumogata/template/role.rb +425 -0
  37. data/lib/kumogata/template/s3.rb +120 -80
  38. data/lib/kumogata/template/sns.rb +2 -6
  39. data/lib/kumogata/template/version.rb +1 -1
  40. data/lib/kumogata/template.rb +9 -1
  41. data/template/_template.rb +2 -2
  42. data/template/alb-load-balancer.rb +5 -4
  43. data/template/alb-target-group.rb +8 -9
  44. data/template/api-gateway-account.rb +15 -0
  45. data/template/api-gateway-api-key.rb +22 -0
  46. data/template/api-gateway-authorizer.rb +38 -0
  47. data/template/api-gateway-base-path-mapping.rb +23 -0
  48. data/template/api-gateway-client-certificate.rb +16 -0
  49. data/template/api-gateway-deployment.rb +24 -0
  50. data/template/api-gateway-domain-name.rb +17 -0
  51. data/template/api-gateway-method.rb +71 -0
  52. data/template/api-gateway-model.rb +23 -0
  53. data/template/api-gateway-resource.rb +32 -0
  54. data/template/api-gateway-rest-api.rb +29 -0
  55. data/template/api-gateway-stage.rb +33 -0
  56. data/template/api-gateway-usage-plan-key.rb +19 -0
  57. data/template/api-gateway-usage-plan.rb +24 -0
  58. data/template/autoscaling-group.rb +2 -2
  59. data/template/autoscaling-launch-configuration.rb +7 -4
  60. data/template/autoscaling-scheduled-action.rb +0 -1
  61. data/template/certificate.rb +2 -2
  62. data/template/cloudfront-distribution.rb +4 -0
  63. data/template/cloudfront-origin-access-identity.rb +19 -0
  64. data/template/cloudtrail.rb +6 -4
  65. data/template/cloudwatch-alarm.rb +9 -3
  66. data/template/codebuild-project.rb +3 -3
  67. data/template/codecommit-repository.rb +2 -2
  68. data/template/codedeploy-application.rb +1 -1
  69. data/template/codedeploy-deployment-config.rb +1 -1
  70. data/template/codedeploy-deployment-group.rb +2 -0
  71. data/template/cognito-identity-pool.rb +34 -0
  72. data/template/cognito-identity-role-attachment.rb +22 -0
  73. data/template/cognito-user-pool-client.rb +28 -0
  74. data/template/cognito-user-pool-group.rb +24 -0
  75. data/template/cognito-user-pool-user-to-group-attachment.rb +20 -0
  76. data/template/cognito-user-pool-user.rb +28 -0
  77. data/template/cognito-user-pool.rb +45 -0
  78. data/template/datapipeline-pipeline.rb +4 -4
  79. data/template/dynamodb-table.rb +5 -1
  80. data/template/ec2-eip-association.rb +1 -1
  81. data/template/ec2-instance.rb +4 -1
  82. data/template/ec2-nat-gateway.rb +4 -0
  83. data/template/ec2-route.rb +4 -0
  84. data/template/ec2-security-group-ingress.rb +1 -1
  85. data/template/ec2-security-group.rb +2 -2
  86. data/template/ec2-subnet.rb +8 -4
  87. data/template/ec2-volume.rb +1 -2
  88. data/template/ec2-vpc-cidr-block.rb +4 -2
  89. data/template/ec2-vpc-endpoint.rb +5 -2
  90. data/template/ecr-repository.rb +2 -2
  91. data/template/ecs-cluster.rb +1 -1
  92. data/template/ecs-service.rb +19 -7
  93. data/template/ecs-task-definition.rb +4 -4
  94. data/template/elasticache-cache-cluster.rb +1 -1
  95. data/template/elasticache-parameter-group.rb +1 -1
  96. data/template/elasticache-replication-group.rb +1 -1
  97. data/template/elasticache-subnet-group.rb +1 -1
  98. data/template/elasticbeanstalk-application-version.rb +1 -1
  99. data/template/elasticbeanstalk-application.rb +1 -1
  100. data/template/elasticbeanstalk-configuration-template.rb +1 -1
  101. data/template/elasticbeanstalk-environment.rb +1 -1
  102. data/template/elb-load-balancer.rb +2 -2
  103. data/template/emr-cluster.rb +3 -3
  104. data/template/emr-instance-group-config.rb +4 -2
  105. data/template/emr-security-configuration.rb +17 -0
  106. data/template/emr-step.rb +2 -2
  107. data/template/events-rule.rb +8 -8
  108. data/template/iam-group.rb +2 -2
  109. data/template/iam-instance-profile.rb +2 -2
  110. data/template/iam-managed-policy.rb +1 -1
  111. data/template/iam-policy.rb +1 -1
  112. data/template/iam-role.rb +17 -2
  113. data/template/iam-user.rb +4 -4
  114. data/template/kinesis-firehose-delivery-stream.rb +36 -0
  115. data/template/kinesis-stream.rb +21 -0
  116. data/template/kms-alias.rb +2 -2
  117. data/template/kms-key.rb +1 -1
  118. data/template/lambda-alias.rb +2 -2
  119. data/template/lambda-event-source-mapping.rb +4 -4
  120. data/template/lambda-function.rb +17 -17
  121. data/template/lambda-permission.rb +31 -10
  122. data/template/lambda-version.rb +4 -2
  123. data/template/logs-destination.rb +1 -1
  124. data/template/logs-log-group.rb +1 -1
  125. data/template/logs-log-stream.rb +4 -2
  126. data/template/logs-metric-filter.rb +1 -1
  127. data/template/logs-subscription_filter.rb +1 -1
  128. data/template/mappings-ec2.rb +114 -52
  129. data/template/output-arn.rb +12 -4
  130. data/template/output-certificate.rb +11 -0
  131. data/template/output-distribution.rb +11 -0
  132. data/template/output-domain-name.rb +11 -0
  133. data/template/output-ecr-repository.rb +16 -0
  134. data/template/output-eip.rb +11 -0
  135. data/template/output-lambda-function.rb +6 -0
  136. data/template/output-name.rb +7 -2
  137. data/template/output-origin-access-identity.rb +13 -0
  138. data/template/output-rds-cluster.rb +17 -0
  139. data/template/{output-rds.rb → output-rds-instance.rb} +1 -1
  140. data/template/output-redshift.rb +11 -0
  141. data/template/output-rest-api.rb +11 -0
  142. data/template/output-s3.rb +3 -0
  143. data/template/output-stage.rb +19 -0
  144. data/template/output-subnet.rb +6 -3
  145. data/template/output-trail.rb +14 -0
  146. data/template/output-user-pool-client.rb +14 -0
  147. data/template/output-user-pool.rb +17 -0
  148. data/template/output-vpc.rb +13 -3
  149. data/template/output.rb +3 -2
  150. data/template/parameter-ec2.rb +10 -4
  151. data/template/parameter-elasticache.rb +1 -1
  152. data/template/parameter-rds.rb +51 -4
  153. data/template/parameter-redshift.rb +31 -1
  154. data/template/parameter.rb +87 -7
  155. data/template/rds-db-cluster-parameter-group.rb +18 -4
  156. data/template/rds-db-cluster.rb +19 -7
  157. data/template/rds-db-instance.rb +55 -131
  158. data/template/rds-db-parameter-group.rb +29 -3
  159. data/template/rds-db-subnet-group.rb +1 -1
  160. data/template/rds-event-subscription.rb +2 -4
  161. data/template/rds-option-group.rb +28 -5
  162. data/template/redshift-cluster-parameter-group.rb +3 -1
  163. data/template/redshift-cluster-security-group.rb +17 -0
  164. data/template/redshift-cluster-subnet-group.rb +3 -1
  165. data/template/redshift-cluster.rb +15 -12
  166. data/template/s3-bucket.rb +10 -5
  167. data/template/sns-topic.rb +2 -2
  168. data/template/sqs-queue.rb +1 -1
  169. data/test/abstract_unit.rb +2 -9
  170. data/test/cloudfront_test.rb +57 -28
  171. data/test/codedeploy_test.rb +21 -0
  172. data/test/datapipeline_test.rb +0 -22
  173. data/test/ec2_test.rb +12 -52
  174. data/test/ecs_test.rb +30 -26
  175. data/test/emr_test.rb +101 -20
  176. data/test/events_test.rb +47 -0
  177. data/test/helper_test.rb +251 -281
  178. data/test/iam_test.rb +572 -57
  179. data/test/lambda_test.rb +1 -1
  180. data/test/s3_test.rb +49 -14
  181. data/test/template/alb-load-balancer_test.rb +4 -5
  182. data/test/template/alb-target-group_test.rb +1 -3
  183. data/test/template/api-gateway-account_test.rb +26 -0
  184. data/test/template/api-gateway-api-key_test.rb +33 -0
  185. data/test/template/api-gateway-authorizer_test.rb +62 -0
  186. data/test/template/api-gateway-base-path-mapping_test.rb +27 -0
  187. data/test/template/api-gateway-client-certificate_test.rb +21 -0
  188. data/test/template/api-gateway-deployment_test.rb +27 -0
  189. data/test/template/api-gateway-domain-name_test.rb +26 -0
  190. data/test/template/api-gateway-method_test.rb +29 -0
  191. data/test/template/api-gateway-model_test.rb +37 -0
  192. data/test/template/api-gateway-resource_test.rb +82 -0
  193. data/test/template/api-gateway-rest-api_test.rb +33 -0
  194. data/test/template/api-gateway-stage_test.rb +39 -0
  195. data/test/template/api-gateway-usage-plan-key_test.rb +25 -0
  196. data/test/template/api-gateway-usage-plan_test.rb +42 -0
  197. data/test/template/cloudfront-distribution_test.rb +41 -3
  198. data/test/template/cloudtrail_test.rb +13 -5
  199. data/test/template/cloudwatch-alarm_test.rb +14 -2
  200. data/test/template/codebuild-project_test.rb +2 -11
  201. data/test/template/codecommit-repository_test.rb +12 -1
  202. data/test/template/cognito-identity-pool_test.rb +32 -0
  203. data/test/template/cognito-identity-role-attachment_test.rb +38 -0
  204. data/test/template/cognito-user-pool-client_test.rb +36 -0
  205. data/test/template/cognito-user-pool-group_test.rb +36 -0
  206. data/test/template/cognito-user-pool-user-to-group-attachment_test.rb +29 -0
  207. data/test/template/cognito-user-pool-user_test.rb +38 -0
  208. data/test/template/cognito-user-pool_test.rb +99 -0
  209. data/test/template/datapipeline-pipeline_test.rb +45 -6
  210. data/test/template/dynamodb-table_test.rb +19 -1
  211. data/test/template/ec2-instance_test.rb +9 -1
  212. data/test/template/ec2-nat-gateway_test.rb +29 -1
  213. data/test/template/ec2-security-group-egress_test.rb +1 -0
  214. data/test/template/ec2-security-group-ingress_test.rb +1 -0
  215. data/test/template/ec2-security-group_test.rb +11 -1
  216. data/test/template/ec2-spot-fleet_test.rb +1 -1
  217. data/test/template/ec2-subnet_test.rb +62 -1
  218. data/test/template/ec2-vpc-cidr-block_test.rb +1 -1
  219. data/test/template/ec2-vpc-endpoint_test.rb +56 -0
  220. data/test/template/ecr-repository_test.rb +63 -11
  221. data/test/template/ecs-service_test.rb +13 -2
  222. data/test/template/ecs-task-definition_test.rb +86 -13
  223. data/test/template/elasticache-cache-cluster_test.rb +4 -6
  224. data/test/template/elasticache-replication-group_test.rb +1 -1
  225. data/test/template/elasticbeanstalk-application-version_test.rb +1 -0
  226. data/test/template/elasticbeanstalk-application_test.rb +2 -1
  227. data/test/template/elasticbeanstalk-configuration-template_test.rb +2 -1
  228. data/test/template/elasticbeanstalk-template_test.rb +1 -0
  229. data/test/template/elb-load-balancer_test.rb +1 -3
  230. data/test/template/emr-cluster_test.rb +2 -14
  231. data/test/template/emr-instance-group-config_test.rb +2 -4
  232. data/test/template/emr-security-configuration_test.rb +34 -0
  233. data/test/template/emr-step_test.rb +2 -6
  234. data/test/template/events-rule_test.rb +3 -3
  235. data/test/template/iam-group_test.rb +11 -1
  236. data/test/template/iam-instance-profile_test.rb +11 -1
  237. data/test/template/iam-managed-policy_test.rb +1 -0
  238. data/test/template/iam-policy_test.rb +1 -3
  239. data/test/template/iam-role_test.rb +12 -2
  240. data/test/template/iam-user_test.rb +11 -17
  241. data/test/template/kinesis-firehorse-delivery-stream_test.rb +68 -0
  242. data/test/template/kinesis-stream_test.rb +61 -0
  243. data/test/template/kms-key_test.rb +1 -0
  244. data/test/template/lambda-alias_test.rb +2 -3
  245. data/test/template/lambda-event-source-mapping_test.rb +1 -1
  246. data/test/template/lambda-function_test.rb +20 -32
  247. data/test/template/lambda-permission_test.rb +7 -4
  248. data/test/template/lambda-version_test.rb +5 -2
  249. data/test/template/logs-log-group_test.rb +1 -3
  250. data/test/template/logs-log-stream_test.rb +2 -6
  251. data/test/template/logs-metric-filter_test.rb +1 -3
  252. data/test/template/logs-subscription-filter_test.rb +1 -3
  253. data/test/template/mappings-ec2_test.rb +10 -3
  254. data/test/template/output-domain-name_test.rb +30 -0
  255. data/test/template/output-name_test.rb +9 -0
  256. data/test/template/{output-rds_test.rb → output-rds-instance_test.rb} +2 -2
  257. data/test/template/output-rest-api_test.rb +30 -0
  258. data/test/template/output-s3_test.rb +9 -0
  259. data/test/template/output-stage_test.rb +43 -0
  260. data/test/template/output-user-pool-client_test.rb +39 -0
  261. data/test/template/output-user-pool_test.rb +48 -0
  262. data/test/template/output_test.rb +3 -1
  263. data/test/template/parameter-ec2_test.rb +22 -24
  264. data/test/template/parameter-elasticache_test.rb +2 -1
  265. data/test/template/parameter-rds_test.rb +32 -3
  266. data/test/template/parameter-redshift_test.rb +31 -2
  267. data/test/template/parameter_test.rb +37 -4
  268. data/test/template/rds-db-cluster-parameter-group_test.rb +1 -1
  269. data/test/template/rds-db-cluster_test.rb +4 -20
  270. data/test/template/rds-db-instance_test.rb +3 -373
  271. data/test/template/rds-db-parameter-group_test.rb +1 -1
  272. data/test/template/rds-option-group_test.rb +2 -2
  273. data/test/template/redshift-cluster-parameter-group_test.rb +28 -0
  274. data/test/template/redshift-cluster-security-group_test.rb +49 -0
  275. data/test/template/redshift-cluster-subnet-group_test.rb +28 -0
  276. data/test/template/redshift-cluster_test.rb +33 -5
  277. data/test/template/s3-bucket_test.rb +6 -20
  278. metadata +130 -22
@@ -4,7 +4,7 @@ require 'kumogata/template/cloudfront'
4
4
  class CloudFrontTest < Minitest::Test
5
5
  def test_cloudfront_distribution_config
6
6
  template = <<-EOS
7
- Test _cloudfront_distribution_config({ origins: [{ domain: "test", id: "test", s3: {} }] })
7
+ Test _cloudfront_distribution_config({ origins: [{ domain: "test", id: "test", s3: "test" }] })
8
8
  EOS
9
9
  act_template = run_client_as_json(template)
10
10
  exp_template = <<-EOS
@@ -15,9 +15,19 @@ Test _cloudfront_distribution_config({ origins: [{ domain: "test", id: "test", s
15
15
  "HttpVersion": "http2",
16
16
  "Origins": [
17
17
  {
18
- "DomainName": "test",
18
+ "DomainName": "test.s3.#{DOMAIN}",
19
19
  "Id": "test",
20
20
  "S3OriginConfig": {
21
+ "OriginAccessIdentity": {
22
+ "Fn::Join": [
23
+ "/",
24
+ [
25
+ "origin-access-identity",
26
+ "cloudfront",
27
+ "test"
28
+ ]
29
+ ]
30
+ }
21
31
  }
22
32
  }
23
33
  ]
@@ -35,9 +45,12 @@ Test _cloudfront_cache_behavior({ forwarded: {}, path: "test", target: "test", v
35
45
  exp_template = <<-EOS
36
46
  {
37
47
  "Test": {
48
+ "DefaultTTL": "86400",
38
49
  "ForwardedValues": {
39
50
  "QueryString": "false"
40
51
  },
52
+ "MaxTTL": "31536000",
53
+ "MinTTL": "0",
41
54
  "PathPattern": "test",
42
55
  "TargetOriginId": "test",
43
56
  "ViewerProtocolPolicy": "redirect-to-https"
@@ -86,6 +99,7 @@ Test _cloudfront_custom_error({})
86
99
  exp_template = <<-EOS
87
100
  {
88
101
  "Test": {
102
+ "ErrorCachingMinTTL": "300",
89
103
  "ErrorCode": "404",
90
104
  "ResponseCode": "404",
91
105
  "ResponsePagePath": "/404.html"
@@ -104,6 +118,7 @@ Test _cloudfront_custom_errors([ {} ])
104
118
  {
105
119
  "Test": [
106
120
  {
121
+ "ErrorCachingMinTTL": "300",
107
122
  "ErrorCode": "404",
108
123
  "ResponseCode": "404",
109
124
  "ResponsePagePath": "/404.html"
@@ -131,15 +146,25 @@ Test _cloudfront_logging({ bucket: "test" })
131
146
 
132
147
  def test_cloudfront_origin
133
148
  template = <<-EOS
134
- Test _cloudfront_origin({ domain: "test", id: "test", s3: {} })
149
+ Test _cloudfront_origin({ domain: "test", id: "test", s3: 'test' })
135
150
  EOS
136
151
  act_template = run_client_as_json(template)
137
152
  exp_template = <<-EOS
138
153
  {
139
154
  "Test": {
140
- "DomainName": "test",
155
+ "DomainName": "test.s3.#{DOMAIN}",
141
156
  "Id": "test",
142
157
  "S3OriginConfig": {
158
+ "OriginAccessIdentity": {
159
+ "Fn::Join": [
160
+ "/",
161
+ [
162
+ "origin-access-identity",
163
+ "cloudfront",
164
+ "test"
165
+ ]
166
+ ]
167
+ }
143
168
  }
144
169
  }
145
170
  }
@@ -149,21 +174,21 @@ Test _cloudfront_origin({ domain: "test", id: "test", s3: {} })
149
174
 
150
175
  def test_cloudfront_origins
151
176
  template = <<-EOS
152
- Test _cloudfront_origins([ { domain: "test1", id: "test1", s3: {} },
153
- { domain: "test2", id: "test2", s3: {} } ])
177
+ Test _cloudfront_origins([ { domain: "test1", id: "test1" },
178
+ { domain: "test2", id: "test2" } ])
154
179
  EOS
155
180
  act_template = run_client_as_json(template)
156
181
  exp_template = <<-EOS
157
182
  {
158
183
  "Test": [
159
184
  {
160
- "DomainName": "test1",
185
+ "DomainName": "test1.s3.#{DOMAIN}",
161
186
  "Id": "test1",
162
187
  "S3OriginConfig": {
163
188
  }
164
189
  },
165
190
  {
166
- "DomainName": "test2",
191
+ "DomainName": "test2.s3.#{DOMAIN}",
167
192
  "Id": "test2",
168
193
  "S3OriginConfig": {
169
194
  }
@@ -174,20 +199,6 @@ Test _cloudfront_origins([ { domain: "test1", id: "test1", s3: {} },
174
199
  assert_equal exp_template.chomp, act_template
175
200
  end
176
201
 
177
- def test_cloudfront_custom_origin
178
- template = <<-EOS
179
- Test _cloudfront_custom_origin({})
180
- EOS
181
- act_template = run_client_as_json(template)
182
- exp_template = <<-EOS
183
- {
184
- "Test": {
185
- }
186
- }
187
- EOS
188
- assert_equal exp_template.chomp, act_template
189
- end
190
-
191
202
  def test_cloudfront_s3_origin
192
203
  template = <<-EOS
193
204
  Test _cloudfront_s3_origin({})
@@ -200,37 +211,54 @@ Test _cloudfront_s3_origin({})
200
211
  }
201
212
  EOS
202
213
  assert_equal exp_template.chomp, act_template
203
- end
204
214
 
205
- def test_cloudfront_custom_origin
206
215
  template = <<-EOS
207
- Test _cloudfront_custom_origin({})
216
+ Test _cloudfront_s3_origin({ ref_s3: 'test' })
208
217
  EOS
209
218
  act_template = run_client_as_json(template)
210
219
  exp_template = <<-EOS
211
220
  {
212
221
  "Test": {
222
+ "OriginAccessIdentity": {
223
+ "Fn::Join": [
224
+ "/",
225
+ [
226
+ "origin-access-identity",
227
+ "cloudfront",
228
+ {
229
+ "Ref": "TestOriginAccessIdentity"
230
+ }
231
+ ]
232
+ ]
233
+ }
213
234
  }
214
235
  }
215
236
  EOS
216
237
  assert_equal exp_template.chomp, act_template
217
238
  end
218
239
 
219
- def test_cloudfront_s3_origin
240
+ def test_cloudfront_custom_origin
220
241
  template = <<-EOS
221
- Test _cloudfront_s3_origin({})
242
+ Test _cloudfront_custom_origin({})
222
243
  EOS
223
244
  act_template = run_client_as_json(template)
224
245
  exp_template = <<-EOS
225
246
  {
226
247
  "Test": {
248
+ "HTTPPort": "80",
249
+ "HTTPSPort": "443",
250
+ "OriginKeepaliveTimeout": "5",
251
+ "OriginProtocolPolicy": "match-viewer",
252
+ "OriginReadTimeout": "30",
253
+ "OriginSSLProtocols": [
254
+ "TLSv1.1"
255
+ ]
227
256
  }
228
257
  }
229
258
  EOS
230
259
  assert_equal exp_template.chomp, act_template
231
260
  end
232
261
 
233
-
234
262
  def test_cloudfront_origin_headers
235
263
  template = <<-EOS
236
264
  Test _cloudfront_origin_headers({ name: "test", value: "test" })
@@ -256,6 +284,7 @@ Test _cloudfront_viewer_cert({ acm: "test" })
256
284
  {
257
285
  "Test": {
258
286
  "AcmCertificateArn": "test",
287
+ "MinimumProtocolVersion": "TLSv1.1_2016",
259
288
  "SslSupportMethod": "sni-only"
260
289
  }
261
290
  }
@@ -18,6 +18,27 @@ Test _codedeploy_minimum(type: "fleet_percent", value: "75")
18
18
  assert_equal exp_template.chomp, act_template
19
19
  end
20
20
 
21
+ def test_codedeploy_alarm
22
+ template = <<-EOS
23
+ Test _codedeploy_alarm(alarm: { alarms: [ "test" ] })
24
+ EOS
25
+ act_template = run_client_as_json(template)
26
+ exp_template = <<-EOS
27
+ {
28
+ "Test": {
29
+ "Alarms": [
30
+ {
31
+ "Name": "test"
32
+ }
33
+ ],
34
+ "Enabled": "true",
35
+ "IgnorePollAlarmFailure": "false"
36
+ }
37
+ }
38
+ EOS
39
+ assert_equal exp_template.chomp, act_template
40
+ end
41
+
21
42
  def test_codedeploy_deployment
22
43
  template = <<-EOS
23
44
  Test _codedeploy_deployment(description: "test", revision: { s3: { bucket: "test", key: "test", version: "test" } })
@@ -113,28 +113,6 @@ Test _datapipeline_pipeline_object_fields(fields: fields)
113
113
  "StringValue": "test1"
114
114
  }
115
115
  ]
116
- }
117
- EOS
118
- assert_equal exp_template.chomp, act_template
119
- end
120
-
121
- def test_datapipeline_pipeline_tags
122
- template = <<-EOS
123
- Test _datapipeline_pipeline_tags(tags: { test: "test", test1: "test1" })
124
- EOS
125
- act_template = run_client_as_json(template)
126
- exp_template = <<-EOS
127
- {
128
- "Test": [
129
- {
130
- "Key": "test",
131
- "Value": "test"
132
- },
133
- {
134
- "Key": "test1",
135
- "Value": "test1"
136
- }
137
- ]
138
116
  }
139
117
  EOS
140
118
  assert_equal exp_template.chomp, act_template
data/test/ec2_test.rb CHANGED
@@ -121,6 +121,7 @@ Test _ec2_security_group_egress_rules("egress", args)
121
121
  "Test": [
122
122
  {
123
123
  "CidrIp": "0.0.0.0/0",
124
+ "Description": "egress rule description",
124
125
  "FromPort": "80",
125
126
  "IpProtocol": "tcp",
126
127
  "ToPort": "80"
@@ -140,6 +141,7 @@ Test _ec2_security_group_egress_rules("egress", args)
140
141
  "Test": [
141
142
  {
142
143
  "CidrIp": "0.0.0.0/0",
144
+ "Description": "egress rule description",
143
145
  "FromPort": "80",
144
146
  "IpProtocol": "tcp",
145
147
  "ToPort": "80"
@@ -159,6 +161,7 @@ Test _ec2_security_group_egress_rule(to: 80)
159
161
  {
160
162
  "Test": {
161
163
  "CidrIp": "0.0.0.0/0",
164
+ "Description": "egress rule description",
162
165
  "FromPort": "80",
163
166
  "IpProtocol": "tcp",
164
167
  "ToPort": "80"
@@ -179,6 +182,7 @@ Test _ec2_security_group_ingress_rules("ingress", args)
179
182
  "Test": [
180
183
  {
181
184
  "CidrIp": "0.0.0.0/0",
185
+ "Description": "inbound rule description",
182
186
  "FromPort": "80",
183
187
  "IpProtocol": "tcp",
184
188
  "ToPort": "80"
@@ -198,12 +202,14 @@ Test _ec2_security_group_ingress_rules("ingress", args)
198
202
  "Test": [
199
203
  {
200
204
  "CidrIp": "0.0.0.0/0",
205
+ "Description": "inbound rule description",
201
206
  "FromPort": "22",
202
207
  "IpProtocol": "tcp",
203
208
  "ToPort": "22"
204
209
  },
205
210
  {
206
211
  "CidrIp": "0.0.0.0/0",
212
+ "Description": "inbound rule description",
207
213
  "FromPort": "80",
208
214
  "IpProtocol": "tcp",
209
215
  "ToPort": "80"
@@ -223,6 +229,7 @@ Test _ec2_security_group_ingress_rule(from: 80)
223
229
  {
224
230
  "Test": {
225
231
  "CidrIp": "0.0.0.0/0",
232
+ "Description": "inbound rule description",
226
233
  "FromPort": "80",
227
234
  "IpProtocol": "tcp",
228
235
  "ToPort": "80"
@@ -240,7 +247,7 @@ Test _ec2_block_device(ref_size: "test")
240
247
  exp_template = <<-EOS
241
248
  {
242
249
  "Test": {
243
- "DeviceName": "/dev/sda1",
250
+ "DeviceName": "/dev/sdb",
244
251
  "Ebs": {
245
252
  "DeleteOnTermination": "true",
246
253
  "VolumeSize": {
@@ -276,14 +283,14 @@ Test _ec2_network_interface_embedded(ref_subnet: "test")
276
283
 
277
284
  def test_ec2_image
278
285
  template = <<-EOS
279
- Test _ec2_image("test", {})
286
+ Test _ec2_image({ image: 'test', instance_type: 'test' })
280
287
  EOS
281
288
  act_template = run_client_as_json(template)
282
289
  exp_template = <<-EOS
283
290
  {
284
291
  "Test": {
285
292
  "Fn::FindInMap": [
286
- "AWSRegionArch2AMIAmazonLinuxOfficial",
293
+ "AWSRegionArch2AMITest",
287
294
  {
288
295
  "Ref": "AWS::Region"
289
296
  },
@@ -301,59 +308,12 @@ Test _ec2_image("test", {})
301
308
  assert_equal exp_template.chomp, act_template
302
309
 
303
310
  template = <<-EOS
304
- Test _ec2_image("test", { image_id: "test" })
311
+ Test _ec2_image({ image_id: "test" })
305
312
  EOS
306
313
  act_template = run_client_as_json(template)
307
314
  exp_template = <<-EOS
308
315
  {
309
316
  "Test": "test"
310
- }
311
- EOS
312
- assert_equal exp_template.chomp, act_template
313
-
314
- template = <<-EOS
315
- Test _ec2_image("test", { image_id: false })
316
- EOS
317
- act_template = run_client_as_json(template)
318
- exp_template = <<-EOS
319
- {
320
- "Test": {
321
- "Fn::FindInMap": [
322
- "AWSRegionArch2AMIAmazonLinuxOfficial",
323
- {
324
- "Ref": "AWS::Region"
325
- },
326
- {
327
- "Fn::FindInMap": [
328
- "AWSInstanceType2Arch",
329
- "test",
330
- "Arch"
331
- ]
332
- }
333
- ]
334
- }
335
-
336
- template = <<-EOS
337
- Test _ec2_image("test", { image_id: nil })
338
- EOS
339
- act_template = run_client_as_json(template)
340
- exp_template = <<-EOS
341
- {
342
- "Test": {
343
- "Fn::FindInMap": [
344
- "AWSRegionArch2AMIAmazonLinuxOfficial",
345
- {
346
- "Ref": "AWS::Region"
347
- },
348
- {
349
- "Fn::FindInMap": [
350
- "AWSInstanceType2Arch",
351
- "test",
352
- "Arch"
353
- ]
354
- }
355
- ]
356
- }
357
317
  }
358
318
  EOS
359
319
  assert_equal exp_template.chomp, act_template
@@ -434,7 +394,7 @@ Test _ec2_spot_fleet_launches({ block_devices: [ { ref_size: "test" } ], iam: "t
434
394
  "Test": {
435
395
  "BlockDeviceMappings": [
436
396
  {
437
- "DeviceName": "/dev/sda1",
397
+ "DeviceName": "/dev/sdb",
438
398
  "Ebs": {
439
399
  "DeleteOnTermination": "true",
440
400
  "VolumeSize": {
data/test/ecs_test.rb CHANGED
@@ -4,7 +4,7 @@ require 'kumogata/template/ecs'
4
4
  class EcsTest < Minitest::Test
5
5
  def test_ecs_load_balancers
6
6
  template = <<-EOS
7
- Test _ecs_load_balancers(load_balancers: [ { container_name: "test", container_port: 80, lb_name: "test" } ])
7
+ Test _ecs_load_balancers(load_balancers: [ { name: "test", port: 80, lb_name: "test" } ])
8
8
  EOS
9
9
  act_template = run_client_as_json(template)
10
10
  exp_template = <<-EOS
@@ -21,25 +21,40 @@ Test _ecs_load_balancers(load_balancers: [ { container_name: "test", container_p
21
21
  assert_equal exp_template.chomp, act_template
22
22
  end
23
23
 
24
- def test_ecs_container_definitions
24
+ def test_ecs_container
25
25
  template = <<-EOS
26
- Test _ecs_container_definitions(container_definitions: [ { name: "test", image: "test" } ])
26
+ Test _ecs_containers(containers: [ { name: "test", image: "test", port_mappings: [ { port: 80 } ] } ])
27
27
  EOS
28
28
  act_template = run_client_as_json(template)
29
29
  exp_template = <<-EOS
30
30
  {
31
31
  "Test": [
32
32
  {
33
- "Cpu": "10",
33
+ "Cpu": "1",
34
+ "DisableNetworking": "false",
34
35
  "Essential": "true",
36
+ "Hostname": {
37
+ "Fn::Join": [
38
+ "-",
39
+ [
40
+ {
41
+ "Ref": "Service"
42
+ },
43
+ "test"
44
+ ]
45
+ ]
46
+ },
35
47
  "Image": "test",
36
48
  "Memory": "300",
37
49
  "Name": "test",
38
50
  "PortMappings": [
39
51
  {
40
- "ContainerPort": "80"
52
+ "ContainerPort": "80",
53
+ "Protocol": "tcp"
41
54
  }
42
- ]
55
+ ],
56
+ "Privileged": "false",
57
+ "ReadonlyRootFilesystem": "false"
43
58
  }
44
59
  ]
45
60
  }
@@ -49,7 +64,7 @@ Test _ecs_container_definitions(container_definitions: [ { name: "test", image:
49
64
 
50
65
  def test_ecs_mount_points
51
66
  template = <<-EOS
52
- Test _ecs_mount_points(mount_points: [ { container_path: "/", source_volume: "/" } ])
67
+ Test _ecs_mount_points(mount_points: [ { path: "/", source: "/" } ])
53
68
  EOS
54
69
  act_template = run_client_as_json(template)
55
70
  exp_template = <<-EOS
@@ -68,14 +83,15 @@ Test _ecs_mount_points(mount_points: [ { container_path: "/", source_volume: "/"
68
83
 
69
84
  def test_ecs_port_mappings
70
85
  template = <<-EOS
71
- Test _ecs_port_mappings(port_mappings: [ { container_port: 80 } ])
86
+ Test _ecs_port_mappings(port_mappings: [ { port: 80 } ])
72
87
  EOS
73
88
  act_template = run_client_as_json(template)
74
89
  exp_template = <<-EOS
75
90
  {
76
91
  "Test": [
77
92
  {
78
- "ContainerPort": "80"
93
+ "ContainerPort": "80",
94
+ "Protocol": "tcp"
79
95
  }
80
96
  ]
81
97
  }
@@ -103,31 +119,19 @@ Test _ecs_volumes_from(volumes_from: [ { source: "test" } ])
103
119
 
104
120
  def test_ecs_volumes
105
121
  template = <<-EOS
106
- Test _ecs_volumes(volumes: [ { name: "test" } ])
122
+ Test _ecs_volumes(volumes: [ { test: "test1" } ])
107
123
  EOS
108
124
  act_template = run_client_as_json(template)
109
125
  exp_template = <<-EOS
110
126
  {
111
127
  "Test": [
112
128
  {
113
- "Name": "test"
129
+ "Name": "test",
130
+ "Host": {
131
+ "SourcePath": "test1"
132
+ }
114
133
  }
115
134
  ]
116
- }
117
- EOS
118
- assert_equal exp_template.chomp, act_template
119
- end
120
-
121
- def test_ecs_volumes_host
122
- template = <<-EOS
123
- Test _ecs_volumes_host(source_path: "test")
124
- EOS
125
- act_template = run_client_as_json(template)
126
- exp_template = <<-EOS
127
- {
128
- "Test": {
129
- "SourcePath": "test"
130
- }
131
135
  }
132
136
  EOS
133
137
  assert_equal exp_template.chomp, act_template
data/test/emr_test.rb CHANGED
@@ -134,7 +134,7 @@ Test _emr_ebs(ebs: [ { size: "test" } ])
134
134
  exp_template = <<-EOS
135
135
  {
136
136
  "Test": {
137
- "EbsBlockDeviceConfigs": [
137
+ "EbsBlockDeviceConfig": [
138
138
  {
139
139
  "VolumeSpecification": {
140
140
  "SizeInGB": "test",
@@ -184,7 +184,7 @@ Test _emr_ebs_volume({ size: "test" })
184
184
 
185
185
  def test_emr_job_flow
186
186
  template = <<-EOS
187
- Test _emr_job_flow(job: { core: { name: "test" }, master: { name: "test", ebs: [ { size: 42, type: "gp2" } ] } })
187
+ Test _emr_job_flow(job: { core: { name: "test" }, master: { name: "test" } })
188
188
  EOS
189
189
  act_template = run_client_as_json(template)
190
190
  exp_template = <<-EOS
@@ -197,16 +197,6 @@ Test _emr_job_flow(job: { core: { name: "test" }, master: { name: "test", ebs: [
197
197
  "Name": "test"
198
198
  },
199
199
  "MasterInstanceGroup": {
200
- "EbsConfiguration": {
201
- "EbsBlockDeviceConfigs": [
202
- {
203
- "VolumeSpecification": {
204
- "SizeInGB": "42",
205
- "VolumeType": "gp2"
206
- }
207
- }
208
- ]
209
- },
210
200
  "InstanceCount": "1",
211
201
  "InstanceType": "c4.large",
212
202
  "Market": "ON_DEMAND",
@@ -214,6 +204,64 @@ Test _emr_job_flow(job: { core: { name: "test" }, master: { name: "test", ebs: [
214
204
  },
215
205
  "TerminationProtected": "false"
216
206
  }
207
+ }
208
+ EOS
209
+ assert_equal exp_template.chomp, act_template
210
+
211
+ template = <<-EOS
212
+ Test _emr_job_flow(job: { core: { fleet: { name: "test", configs: [ { bid: 1 } ], on_demand: 1, spot: 2 } },
213
+ master: { fleet: { name: "test", configs: [ { bid: 1 } ], on_demand: 1, spot: 2 } } } )
214
+ EOS
215
+ act_template = run_client_as_json(template)
216
+ exp_template = <<-EOS
217
+ {
218
+ "Test": {
219
+ "CoreInstanceFleet": {
220
+ "InstanceTypeConfigs": [
221
+ {
222
+ "BidPrice": "1",
223
+ "InstanceType": "c4.large",
224
+ "WeightedCapacity": "1"
225
+ }
226
+ ],
227
+ "Name": {
228
+ "Fn::Join": [
229
+ "-",
230
+ [
231
+ {
232
+ "Ref": "Service"
233
+ },
234
+ "test"
235
+ ]
236
+ ]
237
+ },
238
+ "TargetOnDemandCapacity": "1",
239
+ "TargetSpotCapacity": "2"
240
+ },
241
+ "MasterInstanceFleet": {
242
+ "InstanceTypeConfigs": [
243
+ {
244
+ "BidPrice": "1",
245
+ "InstanceType": "c4.large",
246
+ "WeightedCapacity": "1"
247
+ }
248
+ ],
249
+ "Name": {
250
+ "Fn::Join": [
251
+ "-",
252
+ [
253
+ {
254
+ "Ref": "Service"
255
+ },
256
+ "test"
257
+ ]
258
+ ]
259
+ },
260
+ "TargetOnDemandCapacity": "1",
261
+ "TargetSpotCapacity": "2"
262
+ },
263
+ "TerminationProtected": "false"
264
+ }
217
265
  }
218
266
  EOS
219
267
  assert_equal exp_template.chomp, act_template
@@ -252,19 +300,52 @@ Test _emr_hadoop_jar_step_config(jar: "test")
252
300
  assert_equal exp_template.chomp, act_template
253
301
  end
254
302
 
255
- def test_emr_step_properties
303
+ def test_emr_instance_autoscaling
256
304
  template = <<-EOS
257
- Test _emr_step_properties(step_properties: [ { key: "test", value: "test" } ])
305
+ autoscaling = {
306
+ max: 1,
307
+ min: 0,
308
+ rules: [
309
+ { rule: "test1", type: "change", cool: 60, scaling: 1, operator: ">=", definition: "test2", threshold: 60, unit: "sec" },
310
+ ],
311
+ }
312
+ Test _emr_instance_autoscaling({ autoscaling: autoscaling })
258
313
  EOS
259
314
  act_template = run_client_as_json(template)
260
315
  exp_template = <<-EOS
261
316
  {
262
- "Test": [
263
- {
264
- "Key": "test",
265
- "Value": "test"
266
- }
267
- ]
317
+ "Test": {
318
+ "Constraints": {
319
+ "MaxCapacity": "1",
320
+ "MinCapacity": "0"
321
+ },
322
+ "Rules": [
323
+ {
324
+ "Action": {
325
+ "Market": "ON_DEMAND",
326
+ "SimpleScalingPolicyConfiguration": {
327
+ "AdjustmentType": "CHANGE_IN_CAPACITY",
328
+ "CoolDown": "60",
329
+ "ScalingAdjustment": "1"
330
+ }
331
+ },
332
+ "Description": "test1 instance autoscaling rules description",
333
+ "Name": "test1",
334
+ "Trigger": {
335
+ "CloudWatchAlarmDefinition": {
336
+ "ComparisonOperator": "GREATER_THAN_OR_EQUAL",
337
+ "EvaluationPeriods": "1",
338
+ "MetricName": "test2",
339
+ "Namespace": "AWS/ElasticMapReduce",
340
+ "Period": "300",
341
+ "Statistic": "AVERAGE",
342
+ "Threshold": "60",
343
+ "Unit": "Seconds"
344
+ }
345
+ }
346
+ }
347
+ ]
348
+ }
268
349
  }
269
350
  EOS
270
351
  assert_equal exp_template.chomp, act_template