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
@@ -5,171 +5,95 @@
5
5
  require 'kumogata/template/helper'
6
6
 
7
7
  name = _resource_name(args[:name], "db instance")
8
+ engine = _valid_values(args[:engine],
9
+ %w( mysql mariadb
10
+ oracle-se1 oracle-se oracle-ee
11
+ sqlserver-ee sqlserver-se sqlserver-ex sqlserver-web
12
+ postgres aurora aurora-mysql aurora-postgresql ),
13
+ RDS_DEFAULT_ENGINE)
8
14
  allocated = _ref_string_default("allocated", args, "", 5)
9
15
  allow = _bool("allow", args, true)
10
16
  auto = _bool("auto", args, true)
11
17
  az = _availability_zone(args, false)
12
- backup_retention = _ref_string_default("backup_retention", args, "", 7)
13
- character = _ref_string_default("character", args)
18
+ backup_retention = args[:backup_retention] || 7
19
+ character = args[:character] || ""
14
20
  copy_tags =
15
21
  if args.key? :copy_tags
16
22
  _bool("copy_tags", args, true)
17
23
  else
18
24
  ""
19
25
  end
20
- cluster = _ref_string_default("cluster", args, "db cluster")
21
- instance_class = _ref_string_default("instance_class", args, "db instance classes", RDS_DEFAULT_INSTANCE_CLASS)
22
- instance_class = _valid_values(instance_class, RDS_INSTANCE_CLASSES, RDS_DEFAULT_INSTANCE_CLASS) if instance_class.is_a? String
23
- instance_id = _ref_name("instance_id", args, "db instance id")
26
+ cluster = _ref_string("cluster", args, "db cluster")
27
+ is_cluster = cluster.empty? ? false : true
28
+ instance_class = _ref_string("instance_class", args, "db instance class")
29
+ instance_class = _valid_values(instance_class, RDS_INSTANCE_CLASSES, RDS_DEFAULT_INSTANCE_CLASS) unless instance_class.is_a? Hash
30
+ instance_id = _name("instance_id", args)
24
31
  db_name = _ref_string("db_name", args, "db name")
25
- db_name = _ref_string("database", args, "database") if _empty? db_name
26
- parameter = _ref_string("parameter", args, "db parameter group")
27
- # TODO support AWS::RDS::DBSecurityGroup
28
- # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-rds-security-group.html
29
- db_security_groups = _ref_array("db_security_groups", args, "db security group")
32
+ parameter = _ref_string_default("parameter", args, "db parameter group", "default.mysql5.7")
33
+ security = _ref_array("security_groups", args, "security group")
34
+ subnet_group = _ref_string("subnet_group", args, "db subnet group")
30
35
  snapshot = _ref_string("snapshot", args, "db snapshot")
31
- subnet = _ref_string("subnet", args, "db subnet group")
32
- domain = _ref_string("domain", args, "db domain")
33
- domain_iam = _ref_string("domain_iam", args, "db domain iam")
34
- # http://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateDBInstance.html
35
- engine = _valid_values(args[:engine],
36
- %w( aurora mariadb mysql
37
- oracle-ee oracle-se2 oracle-se1 oracle-se postgres
38
- sqlserver-ee sqlserver-se sqlserver-ex sqlserver-web ), RDS_DEFAULT_ENGINE)
36
+ domain = args[:domain] || ""
37
+ domain_iam = args[:domain_iam] || ""
39
38
  engine_version = _ref_string_default("engine_version", args, "db engine version", RDS_DEFAULT_ENGINE_VERSION[engine.to_sym])
40
- iops =
41
- if _ref_key?("iops", args, "db iops")
42
- _ref_string_default("iops", args, "db iops", 1000)
43
- else
44
- ""
45
- end
46
- kms = _ref_attr_string("kms", "Arn", args)
47
- license = _valid_values(args[:license], %w( license-included bring-your-own-license general-public-license ))
39
+ iops = args[:iops] || ""
48
40
  user_name = _ref_string("user_name", args, "db master user name")
49
41
  user_password = _ref_string("user_password", args, "db master user password")
50
- monitoring_interval = _ref_number("monitoring_interval", args, "db monitoring interval")
51
- monitoring_role_arn = _ref_string("monitoring_role_arn", args, "db monitoring role arn")
42
+ monitoring_interval = _valid_values(args[:monitoring_interval], %w( 0 1 5 10 15 30 60 ), 0)
43
+ monitoring_role = _ref_attr_string('monitoring_role', 'Arn', args, 'role')
52
44
  multi_az = _bool("multi_az", args, false)
53
45
  option = _ref_string("option", args, "db option group")
54
46
  port = _ref_string_default("port", args, "db port", PORT[engine.to_sym])
55
47
  backup_window = _window_time("rds", args[:backup_start] || DEFAULT_SNAPSHOT_TIME[:rds])
56
48
  maintenance = _maintenance_window("rds", args[:maintenance] || DEFAULT_MAINTENANCE_TIME[:rds])
57
49
  publicly = _bool("publicly", args, false)
58
- source_db = _ref_string("source_db", args, "db instance id")
59
- encrypted = _bool("encrypted", args, false)
50
+ source_db = _ref_string("source_db", args, "db source db")
51
+ storage_encrypted = _bool("encrypted", args, false)
60
52
  storage_type = _valid_values(args[:storage_type], %w( standard gp2 io1 ), "gp2")
61
53
  tags = _tags(args)
62
- timezone = _ref_string_default("timezone", args, "db timezone")
54
+ timezone = args[:timezone] || ""
63
55
  security_groups = _ref_array("security_groups", args, "security group")
64
- ## TODO use helper
65
- depends = _resource_name(args[:master_instance], "db instance") unless _empty? source_db
66
-
67
- allocated = "" unless _empty? cluster
68
- character = "" if engine =~ /aurora/
69
- parameter =
70
- if _empty? parameter
71
- if engine == "mysql" and engine_version =~ /5.7/
72
- "default.mysql5.7"
73
- elsif engine == "aurora" and engine_version =~ /5.6/
74
- "default.aurora5.6"
75
- elsif engine == "postgres" and engine_version =~ /9.4/
76
- "default.postgres9.4"
77
- elsif engine == "mariadb" and engine_version =~ /10.0/
78
- "default.mariadb10.0"
79
- else
80
- nil
81
- end
82
- else
83
- nil
84
- end
85
- instance_id = instance_id.downcase if instance_id.is_a? String
86
- if engine !~ /sqlserver/
87
- domain = ""
88
- domain_iam = ""
89
- end
90
- db_name = "" unless _empty? snapshot
91
- iops = "" if storage_type != "io1"
92
- multi_az = false unless _empty? az
93
- source_db = "" if engine !~ /(mysql|mariadb|postgres)/
94
- unless _empty? source_db
95
- multi_az = false
96
- snapshot = ""
97
- backup_retention = ""
98
- db_name = ""
99
- subnet = ""
100
- user_name = ""
101
- user_password = ""
102
- backup_window = ""
103
- end
104
- encrypted = true unless _empty? kms
105
- if encrypted
106
- cluster = ""
107
- snapshot = ""
108
- source_db = ""
109
- end
110
- security_groups = "" unless _empty? db_security_groups
111
- unless _empty? cluster
112
- allocated = ""
113
- backup_retention = ""
114
- character = ""
115
- db_security_groups = []
116
- db_name = ""
117
- subnet = ""
118
- user_name = ""
119
- user_password = ""
120
- multi_az = ""
121
- option = ""
122
- backup_window = ""
123
- maintenance = ""
124
- port = ""
125
- source_db = ""
126
- security_groups = []
127
- backup_window = ""
128
- maintenance = ""
129
- storage_type = ""
130
- end
131
56
 
132
57
  _(name) do
133
58
  Type "AWS::RDS::DBInstance"
134
59
  Properties do
135
- AllocatedStorage allocated unless _empty? allocated
60
+ AllocatedStorage allocated unless is_cluster
136
61
  AllowMajorVersionUpgrade allow
137
62
  AutoMinorVersionUpgrade auto
138
- AvailabilityZone az unless _empty? az
139
- BackupRetentionPeriod backup_retention unless _empty? backup_retention
140
- CharacterSetName character unless _empty? character
141
- CopyTagsToSnapshot copy_tags unless _empty? copy_tags
142
- DBClusterIdentifier cluster unless _empty? cluster
63
+ AvailabilityZone az if !multi_az and !is_cluster
64
+ BackupRetentionPeriod backup_retention if 0 < backup_retention and !is_cluster
65
+ CharacterSetName character if !character.empty? and engine =~ /^oracle.*$/
66
+ CopyTagsToSnapshot copy_tags unless copy_tags.empty?
67
+ DBClusterIdentifier cluster if is_cluster
143
68
  DBInstanceClass instance_class
144
- DBInstanceIdentifier instance_id unless _empty? instance_id
145
- DBName db_name unless _empty? db_name
146
- DBParameterGroupName parameter unless _empty? parameter
147
- DBSecurityGroups db_security_groups unless _empty? db_security_groups
148
- DBSnapshotIdentifier snapshot unless _empty? snapshot
149
- DBSubnetGroupName subnet unless _empty? subnet
150
- Domain domain unless _empty? domain
151
- DomainIAMRoleName domain_iam unless _empty? domain_iam
69
+ DBInstanceIdentifier instance_id
70
+ DBName db_name if snapshot.empty? and !is_cluster
71
+ DBParameterGroupName parameter unless parameter.empty?
72
+ DBSecurityGroups security unless !security_groups.empty? and !is_cluster
73
+ DBSnapshotIdentifier snapshot unless snapshot.empty?
74
+ DBSubnetGroupName subnet_group
75
+ Domain domain unless domain.empty? and engine !~ /sqlserver/
76
+ DomainIAMRoleName domain_iam unless domain_iam.empty? and engine !~ /sqlserver/
152
77
  Engine engine
153
78
  EngineVersion engine_version
154
- Iops iops unless _empty? iops
155
- KmsKeyId kms unless _empty? kms
156
- LicenseModel license unless _empty? license
157
- MasterUsername user_name unless _empty? user_name
158
- MasterUserPassword user_password unless _empty? user_password
159
- MonitoringInterval monitoring_interval unless _empty? monitoring_interval
160
- MonitoringRoleArn monitoring_role_arn unless _empty? monitoring_role_arn
161
- MultiAZ multi_az unless _empty? multi_az
162
- OptionGroupName option unless _empty? option
163
- Port port unless _empty? port
164
- PreferredBackupWindow backup_window unless _empty? backup_window
165
- PreferredMaintenanceWindow maintenance unless _empty? maintenance
79
+ Iops iops unless iops.empty?
80
+ #KmsKeyId
81
+ #LicenseModel
82
+ MasterUsername user_name unless is_cluster
83
+ MasterUserPassword user_password unless is_cluster
84
+ MonitoringInterval monitoring_interval
85
+ MonitoringRoleArn monitoring_role unless monitoring_role.empty?
86
+ MultiAZ multi_az
87
+ OptionGroupName option unless option.empty?
88
+ Port port unless is_cluster
89
+ PreferredBackupWindow backup_window unless is_cluster
90
+ PreferredMaintenanceWindow maintenance unless is_cluster
166
91
  PubliclyAccessible publicly
167
- SourceDBInstanceIdentifier source_db unless _empty? source_db
168
- StorageEncrypted encrypted unless _empty? kms
169
- StorageType storage_type unless _empty? storage_type
92
+ SourceDBInstanceIdentifier source_db unless source_db.empty?
93
+ StorageEncrypted storage_encrypted if storage_encrypted == true and !is_cluster
94
+ StorageType storage_type unless is_cluster
170
95
  Tags tags
171
- Timezone timezone unless _empty? timezone
172
- VPCSecurityGroups security_groups unless _empty? security_groups
96
+ Timezone timezone unless timezone.empty?
97
+ VPCSecurityGroups security_groups if !security_groups.empty? and !is_cluster
173
98
  end
174
- DependsOn depends unless _empty? depends
175
99
  end
@@ -3,13 +3,39 @@
3
3
  # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-rds-dbparametergroup.html
4
4
  #
5
5
  require 'kumogata/template/helper'
6
+ require 'kumogata/template/rds'
7
+
8
+ engine = _valid_values(args[:engine],
9
+ %w( mysql mariadb
10
+ oracle-se1 oracle-se oracle-ee
11
+ sqlserver-ee sqlserver-se sqlserver-ex sqlserver-web
12
+ postgresql aurora aurora-mysql aurora-postgresql ),
13
+ 'mysql')
14
+ default_family =
15
+ case engine
16
+ when 'mysql'
17
+ 'mysql5.7'
18
+ when 'mariadb'
19
+ 'mariadb10.2'
20
+ when 'postgresql'
21
+ 'postgres9.6'
22
+ when 'aurora'
23
+ 'aurora5.6'
24
+ when 'aurora-mysql'
25
+ 'aurora-mysql5.7'
26
+ when 'aurora-postgresql'
27
+ 'aurora-postgresql9.6'
28
+ end
6
29
 
7
30
  name = _resource_name(args[:name], "db parameter group")
8
- description = args[:description] || "#{args[:name]} db parameter group description"
9
- family = args[:family] || "mysql5.7"
10
- parameters = args[:parameters]
31
+ description = _ref_string_default("description", args, '',
32
+ "#{args[:name]} db parameter group description")
33
+ family = _ref_string_default("family", args, "db parameter group", default_family)
34
+ parameters = args[:parameters] || {}
11
35
  tags = _tags(args)
12
36
 
37
+ parameters = parameters.merge(_rds_to_parameter_charset(args[:charset])) if args.key? :charset
38
+
13
39
  _(name) do
14
40
  Type "AWS::RDS::DBParameterGroup"
15
41
  Properties do
@@ -5,7 +5,7 @@
5
5
  require 'kumogata/template/helper'
6
6
 
7
7
  name = _resource_name(args[:name], "db subnet group")
8
- description = args[:description] || "#{args[:name]} db subnet group description"
8
+ description = _ref_string_default("description", args, '', "#{args[:name]} db subnet group description")
9
9
  subnets = _ref_array("subnets", args, "subnet")
10
10
  tags = _tags(args)
11
11
 
@@ -3,6 +3,7 @@
3
3
  # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-rds-eventsubscription.html
4
4
  #
5
5
  require 'kumogata/template/helper'
6
+ require 'kumogata/template/rds'
6
7
 
7
8
  name = _resource_name(args[:name], "event subscription")
8
9
  enabled = _bool("enabled", args, true)
@@ -13,10 +14,7 @@ event_categories = args[:categories] ||
13
14
  sns = _ref_attr_string("sns", "Arn", args, "role")
14
15
  sns = _ref_string("sns_arn", args) if sns.empty?
15
16
  sources = _ref_array("sources", args, "db instance")
16
- source_type = _valid_values(args[:source_type],
17
- %w( db-instance db-parameter-group
18
- db-security-group db-snapshot ),
19
- "db-instance")
17
+ source_type = _rds_to_event_subscription_source(args[:source_type])
20
18
  source_prefix =
21
19
  case source_type
22
20
  when "db-instance"
@@ -3,12 +3,35 @@
3
3
  # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-rds-optiongroup.html
4
4
  #
5
5
  require 'kumogata/template/helper'
6
+ require 'kumogata/template/rds'
6
7
 
7
8
  name = _resource_name(args[:name], "option group")
8
- engine = args[:engine] || "mysql"
9
- major = args[:major] || "5.7"
10
- description = args[:description] || "#{args[:name]} option group description"
11
- configurations = args[:configurations]
9
+ engine = _valid_values(args[:engine],
10
+ %w( mysql mariadb
11
+ oracle-se1 oracle-se oracle-ee
12
+ sqlserver-ee sqlserver-se sqlserver-ex sqlserver-web
13
+ postgres aurora aurora-mysql aurora-postgresql ),
14
+ RDS_DEFAULT_ENGINE)
15
+ major =
16
+ case engine
17
+ when 'mysql'
18
+ '5.7'
19
+ when 'mariadb'
20
+ '10.0'
21
+ when 'postgres'
22
+ '9.6'
23
+ when 'aurora'
24
+ '5.6'
25
+ when 'aurora-mysql'
26
+ '5.7'
27
+ when 'aurora-postgresql'
28
+ '9.6'
29
+ else
30
+ args[:major] || ""
31
+ end
32
+ description = _ref_string_default("description", args, '',
33
+ "#{args[:name]} option group description")
34
+ configurations = _rds_option_group_configurations(args)
12
35
  tags = _tags(args)
13
36
 
14
37
  _(name) do
@@ -17,7 +40,7 @@ _(name) do
17
40
  EngineName engine
18
41
  MajorEngineVersion major
19
42
  OptionGroupDescription description
20
- OptionGroupConfigurations configurations
43
+ OptionConfigurations configurations
21
44
  Tags tags
22
45
  end
23
46
  end
@@ -6,9 +6,10 @@ require 'kumogata/template/helper'
6
6
  require 'kumogata/template/redshift'
7
7
 
8
8
  name = _resource_name(args[:name], "redshift cluster parameter group")
9
- description = args[:description] || "#{args[:name]} redshift cluster parameter group description"
9
+ description = _ref_string_default("description", args, '', "#{args[:name]} redshift cluster parameter group description")
10
10
  family = args[:family] || "redshift-1.0"
11
11
  parameters = _redshift_parameters(args)
12
+ tags = _tags(args)
12
13
 
13
14
  _(name) do
14
15
  Type "AWS::Redshift::ClusterParameterGroup"
@@ -16,5 +17,6 @@ _(name) do
16
17
  Description description
17
18
  ParameterGroupFamily family
18
19
  Parameters parameters
20
+ Tags tags
19
21
  end
20
22
  end
@@ -0,0 +1,17 @@
1
+ #
2
+ # Redshift ClusterSecurityGroup resource
3
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-redshift-clustersecuritygroup.html
4
+ #
5
+ require 'kumogata/template/helper'
6
+
7
+ name = _resource_name(args[:name], "redshift cluster security group")
8
+ description = _ref_string_default("description", args, '', "#{args[:name]} redshift cluster security group description")
9
+ tags = _tags(args)
10
+
11
+ _(name) do
12
+ Type "AWS::Redshift::ClusterSecurityGroup"
13
+ Properties do
14
+ Description description
15
+ Tags tags
16
+ end
17
+ end
@@ -5,13 +5,15 @@
5
5
  require 'kumogata/template/helper'
6
6
 
7
7
  name = _resource_name(args[:name], "redshift cluster subnet group")
8
- description = args[:description] || "#{args[:name]} redshift cluster subnet group description"
8
+ description = _ref_string_default("description", args, '', "#{args[:name]} redshift cluster subnet group description")
9
9
  subnets = _ref_array("subnets", args, "subnet")
10
+ tags = _tags(args)
10
11
 
11
12
  _(name) do
12
13
  Type "AWS::Redshift::ClusterSubnetGroup"
13
14
  Properties do
14
15
  Description description
15
16
  SubnetIds subnets
17
+ Tags tags
16
18
  end
17
19
  end
@@ -3,31 +3,32 @@
3
3
  # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-redshift-cluster.html
4
4
  #
5
5
  require 'kumogata/template/helper'
6
+ require 'kumogata/template/redshift'
6
7
 
7
8
  name = _resource_name(args[:name], "redshift cluster")
8
9
  allow = _bool("allow", args, true)
9
10
  snapshot_retention = args[:snapshot_retention] || DEFAULT_SNAPSHOT_NUM
10
- az = _availability_zone(args, false)
11
+ az = _availability_zone(args, false, "redshift cluster zone name")
11
12
  parameter = _ref_string("parameter", args, "redshift cluster parameter group")
12
13
  subnet = _ref_string("subnet", args, "redshift cluster subnet group")
13
- type = _valid_values(args[:type], [ "single-node", "multi-node" ], "single-node")
14
+ num = args[:num] || 1
15
+ type = (num == 1) ? "single-node" : "multi-node"
14
16
  version = args[:version] || ""
15
- db_name = _ref_string("db_name", args, "db name")
17
+ db_name = _ref_string("db_name", args, "redshift cluster db name")
16
18
  elastic = args[:elastic] || ""
17
19
  encrypted = _bool("encrypted", args, false)
18
- iam_role = args[:iam_role] || ""
19
- user_name = _ref_string("user_name", args, "cluster master user name")
20
- user_password = _ref_string("user_password", args, "cluster master user password")
21
- node = _ref_string("node", args, "redshift cluster node types")
22
- node = _valid_values(args[:node], REDSHIFT_NODE_TYPES, REDSHIFT_DEFAULT_NODE_TYPE) unless node.is_a? Hash
23
- num = args[:num] || 1
20
+ roles = _ref_array("roles", args, "role", "Arn")
21
+ logging = _redshift_logging(args)
22
+ user_name = _ref_string("user_name", args, "redshift cluster master user name")
23
+ user_password = _ref_string("user_password", args, "redshift cluster master user password")
24
+ node = _ref_string_default("node", args, "redshift cluster node types", REDSHIFT_DEFAULT_NODE_TYPE)
24
25
  owner = args[:owner] || ""
25
- port = _ref_string("port", args, "cluster port")
26
- port = PORT[:redshift] if port.empty?
26
+ port = _ref_string_default("port", args, "redshift cluster port", PORT[:redshift])
27
27
  maintenance = _maintenance_window("redshift", args[:maintenance] || DEFAULT_MAINTENANCE_TIME[:redshift])
28
28
  publicly = _bool("publicly", args, false)
29
29
  snapshot_cluster = args[:snapshot_cluster] || ""
30
30
  snapshot_id = args[:snapshot_id] || ""
31
+ tags = _tags(args)
31
32
  security_groups = _ref_array("security_groups", args, "security group")
32
33
 
33
34
  _(name) do
@@ -46,8 +47,9 @@ _(name) do
46
47
  Encrypted encrypted if encrypted == true
47
48
  #HsmClientCertificateIdentifie
48
49
  #HsmConfigurationIdentifier
49
- IamRoles iam_role unless iam_role.empty?
50
+ IamRoles roles unless roles .empty?
50
51
  #KmsKeyId
52
+ LoggingProperties logging unless logging.empty?
51
53
  MasterUsername user_name
52
54
  MasterUserPassword user_password
53
55
  NodeType node
@@ -58,6 +60,7 @@ _(name) do
58
60
  PubliclyAccessible publicly
59
61
  SnapshotClusterIdentifier snapshot_cluster unless snapshot_cluster.empty?
60
62
  SnapshotIdentifier snapshot_id unless snapshot_id.empty?
63
+ Tags tags
61
64
  VpcSecurityGroupIds security_groups unless security_groups.empty?
62
65
  end
63
66
  end
@@ -7,21 +7,25 @@ require 'kumogata/template/s3'
7
7
 
8
8
  name = _resource_name(args[:name], "bucket")
9
9
  access =
10
- if args.key? :website
11
- "PublicRead"
12
- else
10
+ if args.key? :access
13
11
  _s3_to_access(args[:access])
12
+ else
13
+ ''
14
14
  end
15
- bucket = _ref_name("bucket", args)
15
+ bucket = _name("bucket", args)
16
16
  cors = _s3_cors(args)
17
17
  lifecycle = _s3_lifecycle(args)
18
18
  logging = _s3_logging(args)
19
19
  notification = _s3_notification(args)
20
20
  replication = _s3_replication(args)
21
- tags = _tags(args)
21
+ tags = _tags(args, "bucket")
22
22
  versioning = _s3_versioning(args)
23
23
  website = _s3_website(args)
24
24
  deletion_policy = _s3_to_deletion_policy(args[:deletion_policy])
25
+ depends = _depends([ { ref_lambda_permission: 'lambda permission' } ], args)
26
+
27
+ access = "PublicRead" if !website.empty? and access == ''
28
+ access = "Private" if access.empty?
25
29
 
26
30
  _(name) do
27
31
  Type "AWS::S3::Bucket"
@@ -38,4 +42,5 @@ _(name) do
38
42
  WebsiteConfiguration website unless website.empty?
39
43
  end
40
44
  DeletionPolicy deletion_policy
45
+ DependsOn depends unless depends.empty?
41
46
  end
@@ -6,9 +6,9 @@ require 'kumogata/template/helper'
6
6
  require 'kumogata/template/sns'
7
7
 
8
8
  name = _resource_name(args[:name], "topic")
9
- display = _real_name("display", args)
9
+ display = _name("display", args)
10
10
  subscription = _sns_subscription_list(args)
11
- topic = _real_name("topic", args)
11
+ topic = _name("topic", args)
12
12
 
13
13
  _(name) do
14
14
  Type "AWS::SNS::Topic"
@@ -20,7 +20,7 @@ fifo =
20
20
  end
21
21
  max = args[:max] || 262144 # default 256KiB
22
22
  retention = args[:retention] || 345600 # default 4 days
23
- queue = _ref_name("queue", args)
23
+ queue = _name("queue", args)
24
24
  receive = args[:receive] || 0
25
25
  redrive = args[:redrive] || ""
26
26
  visibility = args[:visibility] || 30 # default 30 seconds
@@ -5,20 +5,13 @@ require 'kumogata2/plugin/ruby'
5
5
  require 'json'
6
6
  require 'tempfile'
7
7
  require 'yaml'
8
+ require 'kumogata/template/const'
8
9
 
9
10
  # for only test
10
11
  ENV['TZ'] = 'Asia/Tokyo'
11
12
 
12
- class Kumogata2::Client
13
- include Kumogata2::Logger::Helper
14
-
15
- def initialize(options)
16
- @options = options.kind_of?(Hashie::Mash) ? options : Hashie::Mash.new(options)
17
- @plugin_by_ext = {}
18
- end
19
- end
20
-
21
13
  class Kumogata2::Plugin::Ruby::Context
14
+ remove_method :define_template_func
22
15
  def define_template_func(scope, path_or_url)
23
16
  functions = ""
24
17
  Dir.glob("template/*.rb").all? do |file|