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
@@ -2,22 +2,26 @@
2
2
  # AWS Constants
3
3
  #
4
4
 
5
+ DOMAIN = 'amazonaws.com'
6
+
5
7
  # http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#concepts-available-regions
6
8
  AWS_REGION = {
7
- virginia: "us-east-1",
8
- ohio: "us-east-2",
9
- california: "us-west-1",
10
- oregon: "us-west-2",
11
- canada: "ca-central-1",
12
- ireland: "eu-west-1",
13
- frankfurt: "eu-central-1",
14
- london: "eu-west-2",
15
- tokyo: "ap-northeast-1",
16
- seoul: "ap-northeast-2",
17
- singapore: "ap-southeast-1",
18
- sydney: "ap-southeast-2",
19
- mumbai: "ap-south-1",
20
- saopaulo: "sa-east-1",
9
+ virginia: "us-east-1",
10
+ ohio: "us-east-2",
11
+ california: "us-west-1",
12
+ oregon: "us-west-2",
13
+ canada: "ca-central-1",
14
+ frankfurt: "eu-central-1",
15
+ ireland: "eu-west-1",
16
+ london: "eu-west-2",
17
+ paris: "eu-west-3",
18
+ tokyo: "ap-northeast-1",
19
+ seoul: "ap-northeast-2",
20
+ osaka_local: "ap-northeast-3",
21
+ singapore: "ap-southeast-1",
22
+ sydney: "ap-southeast-2",
23
+ mumbai: "ap-south-1",
24
+ saopaulo: "sa-east-1",
21
25
  }
22
26
 
23
27
  PORT = {
@@ -27,8 +31,9 @@ PORT = {
27
31
  memcached: 11211,
28
32
  mysql: 3306,
29
33
  mariadb: 3306,
30
- aurora: 3306,
34
+ "aurora-mysql": 3306,
31
35
  postgres: 5432,
36
+ "aurora-postgres": 5432,
32
37
  redis: 6379,
33
38
  redshift: 5439,
34
39
  }
@@ -47,7 +52,7 @@ DEFAULT_SNAPSHOT_TIME = {
47
52
 
48
53
  EC2_DEFAULT_IMAGE = "amazon linux official"
49
54
 
50
- # https://aws.amazon.com/ec2/pricing/
55
+ # https://aws.amazon.com/ec2/instance-types/
51
56
  EC2_INSTANCE_TYPES =
52
57
  [
53
58
  # Model vCPU CPU(Credits/hour) Mem(GiB) Storage
@@ -75,6 +80,15 @@ EC2_INSTANCE_TYPES =
75
80
  # c4.8xlarge 36 60 EBS-Only 4,000
76
81
  "c4.large", "c4.xlarge", "c4.2xlarge", "c4.4xlarge", "c4.8xlarge",
77
82
 
83
+ # Model vCPU Mem(GiB) Storage EBS(Mbps)
84
+ # c5.large 2 4 EBS-Only Up to 2,250
85
+ # c5.xlarge 4 8 EBS-Only Up to 2,250
86
+ # c5.2xlarge 8 16 EBS-Only Up to 2,250
87
+ # c5.4xlarge 16 32 EBS-Only 2,250
88
+ # c5.9xlarge 36 72 EBS-Only 4,500
89
+ # c5.18xlarge 72 144 EBS-Only 9,000
90
+ 'c5.large', 'c5.xlarge', 'c5.2xlarge', 'c5.4xlarge', 'c5.9xlarge', 'c5.18xlarge',
91
+
78
92
  # Model vCPU Mem(GiB) SSD Storage(GB)
79
93
  # r3.large 2 15.25 1 x 32
80
94
  # r3.xlarge 4 30.5 1 x 80
@@ -83,6 +97,15 @@ EC2_INSTANCE_TYPES =
83
97
  # r3.8xlarge 32 244 2 x 320
84
98
  "r3.large", "r3.xlarge", "r3.2xlarge", "r3.4xlarge", "r3.8xlarge",
85
99
 
100
+ # Model vCPU Mem (GiB) Networking Perf. SSD Storage (GB)
101
+ # r4.large 2 15.25 Up to 10 Gigabit EBS-Only
102
+ # r4.xlarge 4 30.5 Up to 10 Gigabit EBS-Only
103
+ # r4.2xlarge 8 61 Up to 10 Gigabit EBS-Only
104
+ # r4.4xlarge 16 122 Up to 10 Gigabit EBS-Only
105
+ # r4.8xlarge 32 244 10 Gigabit EBS-Only
106
+ # r4.16xlarge 64 488 25 Gigabit EBS-Only
107
+ 'r4.large', 'r4.2xlarge', 'r4.4xlarge', 'r4.8xlarge', 'r4.16xlarge',
108
+
86
109
  # Model vCPU Mem(GiB) SSD Storage(GB)
87
110
  # i2.xlarge 4 30.5 1 x 800
88
111
  # i2.2xlarge 8 61 2 x 800
@@ -94,13 +117,24 @@ EC2_INSTANCE_TYPES =
94
117
  # x1.16xlarge 64 174.5 1 x 1,920 SSD 10
95
118
  # x1.32xlarge 128 1,952 2 x 1,902 SSD 10
96
119
  "x1.16xlarge", "x1.32xlarge",
120
+
121
+ # Model vCPU Mem(GiB) Storage(GB) Network(Gbps)
122
+ # x1e.32xlarge 128 3,904 2 x 1,920 14,000
123
+ # x1e.16xlarge 64 1,952 1 x 1,920 7,000
124
+ # x1e.8xlarge 32 976 1 x 960 3,500
125
+ # x1e.4xlarge 16 488 1 x 480 1,750
126
+ # x1e.2xlarge 8 244 1 x 240 1,000
127
+ # x1e.xlarge 4 122 1 x 120 500
128
+ 'x1e.32xlarge', 'x1e.16xlarge', 'x1e.8xlarge', 'x1e.4xlarge', 'x1e.2xlarge', 'x1e.xlarge',
97
129
  ]
98
130
  EC2_DEFAULT_INSTANCE_TYPE = "t2.micro"
99
131
 
100
132
  ELASTICACHE_DEFAULT_ENGINE = "redis"
133
+ # aws --region <REGION> elasticache describe-cache-engine-versions \
134
+ # | jq -r '.CacheEngineVersions[] | select(.Engine == "<ENGINE>") | .EngineVersion'
101
135
  ELASTICACHE_DEFAULT_ENGINE_VERSION = {
102
- memcached: "1.4.24",
103
- redis: "2.8.24",
136
+ memcached: "1.4.5",
137
+ redis: "2.8.6",
104
138
  }
105
139
  # https://aws.amazon.com/elasticache/pricing/
106
140
  ELASTICACHE_NODE_TYPES =
@@ -109,31 +143,34 @@ ELASTICACHE_NODE_TYPES =
109
143
  # cache.t2.micro 1 0.555 Low to Moderate
110
144
  # cache.t2.small 1 1.55 Low to Moderate
111
145
  # cache.t2.medium 2 3.22 Low to Moderate
146
+ "cache.t2.micro", "cache.t2.small", "cache.t2.medium",
147
+
148
+ # Cache Node Type vCPU Mem (GiB) Network Performance
112
149
  # cache.m3.medium 1 2.78 Moderate
113
150
  # cache.m3.large 2 6.05 Moderate
114
151
  # cache.m3.xlarge 4 13.3 High
115
152
  # cache.m3.2xlarge 8 27.9 High
116
- # cache.r3.large 2 13.5 Moderate
117
- # cache.r3.xlarge 4 28.4 Moderate
118
- # cache.r3.2xlarge 8 58.2 High
119
- # cache.r3.4xlarge 16 118 High
120
- # cache.r3.8xlarge 32 237 10 Gigabit
153
+ "cache.m3.medium", "cache.m3.large", "cache.m3.xlarge", "cache.m3.2xlarge",
154
+
121
155
  # cache.m4.large 2 6.42 Moderate
122
156
  # cache.m4.xlarge 4 14.28 High
123
157
  # cache.m4.2xlarge 8 29.70 High
124
158
  # cache.m4.4xlarge 16 60.78 High
125
159
  # cache.m4.10xlarge 40 154.64 10 Gigabit
126
- "cache.t2.micro", "cache.t2.small", "cache.t2.medium",
127
- "cache.m3.medium", "cache.m3.large", "cache.m3.xlarge",
128
- "cache.m3.2xlarge", "cache.r3.large", "cache.r3.xlarge",
160
+ "cache.m4.large", "cache.m4.xlarge",
161
+ "cache.m4.2xlarge", "cache.m4.4xlarge", "cache.m4.10xlarge",
162
+
163
+ # cache.r3.large 2 13.5 Moderate
164
+ # cache.r3.xlarge 4 28.4 Moderate
165
+ # cache.r3.2xlarge 8 58.2 High
166
+ # cache.r3.4xlarge 16 118 High
167
+ # cache.r3.8xlarge 32 237 10 Gigabit
168
+ "cache.r3.large", "cache.r3.xlarge",
129
169
  "cache.r3.2xlarge", "cache.r3.4xlarge", "cache.r3.8xlarge",
130
- "cache.m4.large", "cache.m4.xlarge", "cache.m4.2xlarge",
131
- "cache.m4.4xlarge", "cache.m4.10xlarge",
132
170
  ]
133
171
  ELASTICACHE_DEFAULT_NODE_TYPE = "cache.t2.medium"
134
172
 
135
173
  # https://aws.amazon.com/rds/pricing/
136
- # http://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateDBInstance.html
137
174
  RDS_INSTANCE_CLASSES =
138
175
  [
139
176
  # Instance Class vCPU ECU Memory (GB) EBS Optimized Network Performance
@@ -142,41 +179,60 @@ RDS_INSTANCE_CLASSES =
142
179
  # db.m4.2xlarge 8 25.5 32 1000 Mbps High
143
180
  # db.m4.4xlarge 16 53.5 64 2000 Mbps High
144
181
  # db.m4.10xlarge 40 124.5 160 4000 Mbps 10 GBps
182
+ "db.m4.large", "db.m4.xlarge", "db.m4.2xlarge", "db.m4.4xlarge", "db.m4.10xlarge",
183
+
184
+ # Instance Class vCPU ECU Memory (GB) EBS Optimized Network Performance
145
185
  # db.r3.large 2 6.5 15 No Moderate
146
186
  # db.r3.xlarge 4 13 30.5 500 Mbps Moderate
147
187
  # db.r3.2xlarge 8 26 61 1000 Mbps High
148
188
  # db.r3.4xlarge 16 52 122 2000 Mbps High
149
189
  # db.r3.8xlarge 32 104 244 No 10 Gbps
190
+ "db.r3.large", "db.r3.xlarge", "db.r3.2xlarge", "db.r3.4xlarge", "db.r3.8xlarge",
191
+
192
+ # Instance Class vCPU ECU Memory (GB) EBS Optimized Network Performance
150
193
  # db.t2.micro 1 1 1 No Low
151
194
  # db.t2.small 1 1 2 No Low
152
195
  # db.t2.medium 2 2 4 No Moderate
153
196
  # db.t2.large 2 2 8 No Moderate
154
- "db.m4.large", "db.m4.xlarge", "db.m4.2xlarge", "db.m4.4xlarge", "db.m4.10xlarge",
155
- "db.r3.large", "db.r3.xlarge", "db.r3.2xlarge", "db.r3.4xlarge", "db.r3.8xlarge",
156
197
  "db.t2.micro", "db.t2.small", "db.t2.medium", "db.t2.large",
157
198
  ]
158
199
  RDS_DEFAULT_INSTANCE_CLASS = "db.t2.medium"
200
+
201
+ RDS_AURORA_INSTANCE_CLASSES =
202
+ [
203
+ "db.t2.small", "db.t2.medium", "db.t2.large",
204
+ "db.r3.large", "db.r3.xlarge", "db.r3.2xlarge", "db.r3.4xlarge", "db.r3.8xlarge",
205
+ ]
206
+ RDS_AURORA_DEFAULT_INSTANCE_CLASS = "db.t2.medium"
207
+
159
208
  RDS_DEFAULT_ENGINE = "mysql"
209
+ RDS_DEFAULT_CLUSTER_ENGINE = 'aurora-mysql'
210
+ # aws --region <REGION> rds describe-db-engine-versions --query "DBEngineVersions[] | [?Engine == 'mysql'].EngineVersion"
160
211
  RDS_DEFAULT_ENGINE_VERSION = {
161
- mysql: "5.7.17",
162
- mariadb: "10.1.23",
163
212
  aurora: "5.6.10a",
164
- postgres: "9.6.2",
213
+ "aurora-mysql": "5.7.12",
214
+ "aurora-postgresql": "9.6.3",
215
+ mariadb: "10.1.26",
216
+ mysql: "5.7.19",
217
+ postgres: "9.6.6",
165
218
  }
166
219
 
167
220
  # https://aws.amazon.com/redshift/pricing/
168
221
  REDSHIFT_NODE_TYPES =
169
222
  [
170
- # Node Size vCPU ECU RAM (GiB) Slices Per Node Storage Per Node Node Range Total Capacity
171
- # ds1.xlarge 2 4.4 15 2 2 TB HDD 1–32 64 TB
172
- # ds1.8xlarge 16 35 120 16 16 TB HDD 2128 2 PB
173
- # ds2.xlarge 4 13 31 2 2 TB HDD 132 64 TB
174
- # ds2.8xlarge 36 119 244 16 16 TB HDD 2–128 2 PB
175
- # dc1.large 2 7 15 2 160 GB SSD 1–32 5.12 TB
176
- # dc1.8xlarge 32 104 244 32 2.56 TB SSD 2–128 326 TB
177
- "ds1.xlarge", "ds1.8xlarge", "ds2.xlarge", "ds2.8xlarge", "dc1.large", "dc1.8xlarge",
223
+ # Dense Compute
224
+ # Node Size vCPU ECU RAM(GiB) Slices Per Node Storage Per Node Node Range Total Capacity
225
+ # dc2.large 2 7 15.25 2 160 GB NVMe-SSD 132 5.12 TB
226
+ # dc2.8xlarge 32 99 244 16 2.56 TB NVMe-SSD 2128 326 TB
227
+ "dc2.large", "dc2.8xlarge",
228
+
229
+ # Dense Storage
230
+ # Node Size vCPU ECU RAM(GiB) Slices Per Node Storage Per Node Node Range Total Capacity
231
+ # ds2.xlarge 4 13 31 2 2 TB HDD 1–32 64 TB
232
+ # ds2.8xlarge 36 119 244 16 16 TB HDD 2–128 2 PB
233
+ "ds2.xlarge", "ds2.8xlarge",
178
234
  ]
179
- REDSHIFT_DEFAULT_NODE_TYPE = "ds1.xlarge"
235
+ REDSHIFT_DEFAULT_NODE_TYPE = "dc2.large"
180
236
 
181
237
  # https://aws.amazon.com/elasticmapreduce/pricing/
182
238
  EMR_INSTANCE_TYPES =
@@ -192,14 +248,20 @@ EMR_DEFAULT_RELEASE = "emr-4.6.0"
192
248
 
193
249
  ELB_ACCESS_LOG_ACCOUNT_ID = {
194
250
  "us-east-1": "127311923021",
195
- "us-west-2": "797873946194",
251
+ "us-east-2": "033677994240",
196
252
  "us-west-1": "027434742980",
197
- "eu-west-1": "156460612806",
253
+ "us-west-2": "797873946194",
254
+ "ca-central-1": "985666609251",
198
255
  "eu-central-1": "054676820928",
199
- "ap-southeast-1": "114774131450",
256
+ "eu-west-1": "156460612806",
257
+ "eu-west-2": "652711504416",
258
+ "eu-west-3": "009996457667",
200
259
  "ap-northeast-1": "582318560864",
201
- "ap-southeast-2": "783225319266",
202
260
  "ap-northeast-2": "600734575887",
261
+ "ap-northeast-3": "383597477331",
262
+ "ap-southeast-1": "114774131450",
263
+ "ap-southeast-2": "783225319266",
264
+ "ap-south-1": "718504428378",
203
265
  "sa-east-1": "507241528517",
204
266
  }
205
267
 
@@ -4,87 +4,56 @@
4
4
  require 'kumogata/template/helper'
5
5
 
6
6
  def _datapipeline_parameter_objects(args)
7
- objects = args[:parameter_objects] || []
8
-
9
- array = []
10
- objects.each do |object|
11
- object.each do |id, value|
7
+ (args[:parameter_objects] || []).collect do |object|
8
+ object.collect do |id, value|
12
9
  attributes = _datapipeline_parameter_objects_attributes(value)
13
- array << _{
10
+
11
+ _{
14
12
  Attributes attributes
15
13
  Id id
16
14
  }
17
15
  end
18
- end
19
- array
16
+ end.flatten
20
17
  end
21
18
 
22
19
  def _datapipeline_parameter_objects_attributes(args)
23
- attributes = args[:attributes] || {}
24
-
25
- array = []
26
- attributes.each do |key, value|
27
- array << _{
20
+ (args[:attributes] || {}).collect do |key, value|
21
+ _{
28
22
  Key key
29
23
  StringValue value
30
24
  }
31
25
  end
32
- array
33
26
  end
34
27
 
35
28
  def _datapipeline_parameter_values(args)
36
- values = args[:parameter_values] || {}
37
-
38
- array = []
39
- values.each do |id, val|
40
- array << _{
29
+ (args[:parameter_values] || {}).collect do |id, value|
30
+ _{
41
31
  Id id
42
- StringValue val
32
+ StringValue value
43
33
  }
44
34
  end
45
- array
46
35
  end
47
36
 
48
37
  def _datapipeline_pipeline_objects(args)
49
- objects = args[:objects] || []
50
-
51
- array = []
52
- objects.each do |object|
53
- object.each do |id, value|
38
+ (args[:objects] || []).collect do |object|
39
+ object.collect do |id, value|
54
40
  fields = _datapipeline_pipeline_object_fields(value)
55
- array << _{
41
+ _{
56
42
  Fields fields
57
43
  Id id
58
44
  Name value[:name]
59
45
  }
60
46
  end
61
- end
62
- array
47
+ end.flatten
63
48
  end
64
49
 
65
50
  def _datapipeline_pipeline_object_fields(args)
66
- fields = args[:fields] || {}
67
-
68
- array = []
69
- fields.each do |key, value|
70
- array << _{
51
+ (args[:fields] || {}).collect do |key, value|
52
+ _{
71
53
  Key key
72
54
  RefValue value[:ref] if value.key? :ref
73
55
  StringValue value[:string] if value.key? :string
74
56
  }
75
57
  end
76
- array
77
58
  end
78
59
 
79
- def _datapipeline_pipeline_tags(args)
80
- tags = args[:tags] || {}
81
-
82
- array = []
83
- tags.each do |key, value|
84
- array << _{
85
- Key key
86
- Value value
87
- }
88
- end
89
- array
90
- end
@@ -13,8 +13,7 @@ def _dynamodb_attribute(args)
13
13
  end
14
14
  end
15
15
 
16
- array = []
17
- attributes.each do |attribute|
16
+ attributes.collect do |attribute|
18
17
  type =
19
18
  case attribute[:type].to_sym
20
19
  when :binary
@@ -24,12 +23,11 @@ def _dynamodb_attribute(args)
24
23
  else
25
24
  "S"
26
25
  end
27
- array << _{
26
+ _{
28
27
  AttributeName attribute[:value]
29
28
  AttributeType type
30
29
  }
31
30
  end
32
- array
33
31
  end
34
32
 
35
33
  def _dynamodb_key_schema(args)
@@ -42,8 +40,7 @@ def _dynamodb_key_schema(args)
42
40
  end
43
41
  end
44
42
 
45
- array = []
46
- schemas.each do |schema|
43
+ schemas.collect do |schema|
47
44
  type =
48
45
  case schema[:type].to_sym
49
46
  when :range
@@ -51,12 +48,11 @@ def _dynamodb_key_schema(args)
51
48
  else
52
49
  "hash"
53
50
  end
54
- array << _{
51
+ _{
55
52
  AttributeName schema[:value]
56
53
  KeyType type.upcase
57
54
  }
58
55
  end
59
- array
60
56
  end
61
57
 
62
58
  def _dynamodb_projection(args)
@@ -109,3 +105,16 @@ def _dynamodb_local(args)
109
105
  Projection projection
110
106
  }
111
107
  end
108
+
109
+ def _dynamodb_ttl(args)
110
+ ttl = args[:ttl] || {}
111
+ return ttl if ttl.empty?
112
+
113
+ attr = args[:attr] || ""
114
+ enabled = _bool("enabled", args, true)
115
+
116
+ _{
117
+ AttributeName attr unless attr.empty?
118
+ Enabled enabled
119
+ }
120
+ end
@@ -3,6 +3,27 @@
3
3
  #
4
4
  require 'kumogata/template/helper'
5
5
 
6
+ def _ec2_to_block_device_ecs(args)
7
+ root_device = {
8
+ device: "/dev/xvda",
9
+ delete: _bool("root_delete", args, true),
10
+ size: args[:root_size] || 8,
11
+ type: "gp2",
12
+ }
13
+ root_device[:ref_size] = "#{args[:ref_root_size]} root" if _ref_key? "root_size", args, '', false
14
+
15
+ # /dev/xvdcz is Docker's use storage
16
+ data_device = {
17
+ device: "/dev/xvdcz",
18
+ delete: _bool("data_delete", args, true),
19
+ size: args[:data_size],
20
+ type: "gp2",
21
+ }
22
+ data_device[:ref_size] = "#{args[:ref_data_size]} data" if _ref_key? "data_size", args, '', false
23
+
24
+ [ root_device, data_device ]
25
+ end
26
+
6
27
  def _ec2_tags(args)
7
28
  if args.key? :tags_append
8
29
  tags_append = {}
@@ -33,6 +54,7 @@ def _ec2_security_group_egress_rule(args)
33
54
  cidr = args[:cidr] || "0.0.0.0/0"
34
55
  cidr_ipv6 = args[:cidr_ipv6] || ""
35
56
  dest_security = _ref_string("dest_security", args, "security group")
57
+ description = _ref_string_default("description", args, '', "egress rule description")
36
58
  from = _ref_string("from", args)
37
59
  ip = args[:ip] || "tcp"
38
60
  dest_prefix = _ref_string("dest_prefix", args, "vpc endpoint")
@@ -43,6 +65,7 @@ def _ec2_security_group_egress_rule(args)
43
65
  CidrIp cidr if dest_security.empty?
44
66
  CidrIpv6 cidr_ipv6 unless cidr_ipv6.empty?
45
67
  DestinationPrefixListId dest_prefix unless dest_prefix.empty?
68
+ Description description
46
69
  FromPort from unless ip == "icmp"
47
70
  IpProtocol ip
48
71
  DestinationSecurityGroupId dest_security unless dest_security.empty?
@@ -69,18 +92,20 @@ end
69
92
  def _ec2_security_group_ingress_rule(args)
70
93
  cidr = args[:cidr] || "0.0.0.0/0"
71
94
  cidr_ipv6 = args[:cidr_ipv6] || ""
95
+ description = _ref_string_default("description", args, '', "inbound rule description")
72
96
  from = _ref_string("from", args)
73
97
  ip = args[:ip] || "tcp"
74
98
  source_group_name = _ref_string("source_group_name", args, "security group")
75
99
  source_group_id = _ref_string("source_group_id", args, "security group")
76
100
  source_group_owner_id = _ref_string("source_group_owner_id", args, "account id")
77
101
  to = _ref_string("to", args)
78
- to = from if to.empty?
102
+ to = from.clone if to.empty?
79
103
  ip = -1 and from = 0 and to = 65535 if ip == "all"
80
104
 
81
105
  _{
82
106
  CidrIp cidr if source_group_name.empty? and source_group_id.empty?
83
107
  CidrIpv6 cidr_ipv6 unless cidr_ipv6.empty?
108
+ Description description
84
109
  FromPort from unless ip == "icmp"
85
110
  IpProtocol ip
86
111
  SourceSecurityGroupName source_group_name unless source_group_name.empty?
@@ -91,7 +116,7 @@ def _ec2_security_group_ingress_rule(args)
91
116
  end
92
117
 
93
118
  def _ec2_block_device(args)
94
- device = args[:device] || "/dev/sda1"
119
+ device = args[:device] || "/dev/sdb"
95
120
  delete = _bool("delete", args, true)
96
121
  encrypted = _bool("encrypted", args, false)
97
122
  iops = args[:iops] || 300
@@ -147,12 +172,17 @@ def _ec2_network_interface_embedded(args, is_spot = false)
147
172
  }
148
173
  end
149
174
 
150
- def _ec2_image(instance_type, args)
151
- image_id = args[:image_id] || false
152
- return args[:image_id] if image_id
175
+ def _ec2_image(args)
176
+ return args[:image_id] if args.key? :image_id
153
177
 
154
- resource_image = _resource_name(args[:image] || EC2_DEFAULT_IMAGE)
155
- _find_in_map("AWSRegionArch2AMI#{resource_image}",
178
+ image =
179
+ if args.key? :ecs
180
+ "ecs official"
181
+ else
182
+ args[:image] || EC2_DEFAULT_IMAGE
183
+ end
184
+ instance_type = _ref_string("instance_type", args, "instance type")
185
+ _find_in_map("AWSRegionArch2AMI#{_resource_name(image)}",
156
186
  _region,
157
187
  _find_in_map("AWSInstanceType2Arch", instance_type, "Arch"))
158
188
  end
@@ -179,12 +209,33 @@ def _ec2_protocol_number(protocol)
179
209
  end
180
210
 
181
211
  def _ec2_user_data(args)
182
- user_data = _ref_string("user_data", args, "user data")
183
- return "" if user_data.empty?
212
+ if args.key? :user_data
213
+ user_data = args[:user_data]
214
+ else
215
+ user_data = _ref_string("user_data", args, "user data")
216
+ end
217
+
218
+ return '' if user_data.empty?
184
219
 
185
220
  if user_data.is_a? Hash
186
221
  _base64(user_data)
187
222
  else
223
+ if user_data.is_a? String
224
+ if user_data.nil? or user_data.empty?
225
+ user_data = []
226
+ else
227
+ user_data = [ user_data ]
228
+ end
229
+ end
230
+ if args.key? :ecs
231
+ # http://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-config.html
232
+ ecs_user_data =<<"EOS"
233
+ cat <<'EOF' >> /etc/ecs/ecs.config
234
+ ECS_CLUSTER=#{_name("ecs", args)}
235
+ EOF
236
+ EOS
237
+ user_data = user_data.insert(0, ecs_user_data)
238
+ end
188
239
  _base64_shell(user_data)
189
240
  end
190
241
  end
@@ -229,7 +280,7 @@ def _ec2_spot_fleet_launches(args)
229
280
  iam = _ref_string("iam", args, "iam instance profile")
230
281
  iam = _ref_attr_string("iam", "Arn", args, "iam instance profile") if iam.empty?
231
282
  instance_type = _ref_string("instance_type", args, "instance type")
232
- image =_ec2_image(instance_type, args)
283
+ image = _ec2_image(args)
233
284
  kernel = args[:kernel] || ""
234
285
  key_name = _ref_string("key_name", args, "key name")
235
286
  monitoring = _bool("monitoring", args, false)
@@ -5,15 +5,17 @@ require 'kumogata/template/helper'
5
5
  require 'kumogata/template/iam'
6
6
 
7
7
  def _ecr_policy(name, args)
8
- action = args[name.to_sym][:action] || []
9
- user = args[name.to_sym][:user] || []
10
- account = args[name.to_sym][:account]
11
- principal = { account: account }
12
- policy = {
13
- service: "ecr",
14
- action: action,
15
- principal: principal,
8
+ policy = args[name.to_sym] || {}
9
+ return policy if policy.empty?
10
+
11
+ iam_policy = {
12
+ service: 'ecr',
16
13
  no_resource: true,
17
14
  }
18
- _iam_policy_document("policy", { policy: [ policy ] })
15
+ iam_policy[:sid] = policy[:sid] if policy.key? :sid
16
+ iam_policy[:principal] = policy[:principal] if policy.key? :principal
17
+ iam_policy[:actions] = policy[:actions] if policy.key? :actions
18
+ iam_policy[:action] = policy[:action] if policy.key? :action
19
+
20
+ _iam_policy_document('policy', { policy: [ iam_policy ] })
19
21
  end