kumogata-template 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (241) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +54 -0
  3. data/.travis.yml +8 -0
  4. data/Gemfile +4 -0
  5. data/Gemfile.lock +75 -0
  6. data/README.md +204 -0
  7. data/Rakefile +23 -0
  8. data/bin/kumogata-template +9 -0
  9. data/kumogata-template.gemspec +26 -0
  10. data/lib/kumogata/template.rb +17 -0
  11. data/lib/kumogata/template/autoscaling.rb +77 -0
  12. data/lib/kumogata/template/cloudwatch.rb +28 -0
  13. data/lib/kumogata/template/codedeploy.rb +85 -0
  14. data/lib/kumogata/template/const.rb +175 -0
  15. data/lib/kumogata/template/datapipeline.rb +90 -0
  16. data/lib/kumogata/template/dynamodb.rb +111 -0
  17. data/lib/kumogata/template/ec2.rb +165 -0
  18. data/lib/kumogata/template/ecs.rb +119 -0
  19. data/lib/kumogata/template/elasticbeanstalk.rb +33 -0
  20. data/lib/kumogata/template/elb.rb +132 -0
  21. data/lib/kumogata/template/emr.rb +166 -0
  22. data/lib/kumogata/template/events.rb +25 -0
  23. data/lib/kumogata/template/ext/argument_parser.rb +8 -0
  24. data/lib/kumogata/template/ext/kumogata.rb +103 -0
  25. data/lib/kumogata/template/helper.rb +211 -0
  26. data/lib/kumogata/template/iam.rb +96 -0
  27. data/lib/kumogata/template/lambda.rb +34 -0
  28. data/lib/kumogata/template/s3.rb +223 -0
  29. data/lib/kumogata/template/sns.rb +25 -0
  30. data/lib/kumogata/template/version.rb +1 -0
  31. data/template/_template.rb +25 -0
  32. data/template/autoscaling-group.rb +47 -0
  33. data/template/autoscaling-launch-configuration.rb +54 -0
  34. data/template/autoscaling-lifecycle-hook.rb +27 -0
  35. data/template/autoscaling-scaling-policy.rb +33 -0
  36. data/template/autoscaling-scheduled-action.rb +37 -0
  37. data/template/cloudtrail.rb +39 -0
  38. data/template/cloudwatch-alarm.rb +45 -0
  39. data/template/codedeploy-application.rb +15 -0
  40. data/template/codedeploy-deployment-config.rb +23 -0
  41. data/template/codedeploy-deployment-group.rb +35 -0
  42. data/template/datapipeline-pipeline.rb +28 -0
  43. data/template/dynamodb-table.rb +33 -0
  44. data/template/ec2-eip-association.rb +23 -0
  45. data/template/ec2-eip.rb +17 -0
  46. data/template/ec2-instance.rb +65 -0
  47. data/template/ec2-internet-gateway.rb +15 -0
  48. data/template/ec2-nat-gateway.rb +17 -0
  49. data/template/ec2-network-acl-entry.rb +30 -0
  50. data/template/ec2-network-acl.rb +17 -0
  51. data/template/ec2-route-table.rb +17 -0
  52. data/template/ec2-route.rb +27 -0
  53. data/template/ec2-security-group.rb +24 -0
  54. data/template/ec2-subnet-network-acl-association.rb +17 -0
  55. data/template/ec2-subnet-route-table-association.rb +17 -0
  56. data/template/ec2-subnet.rb +23 -0
  57. data/template/ec2-volume-attachment.rb +19 -0
  58. data/template/ec2-volume.rb +31 -0
  59. data/template/ec2-vpc-endpoint.rb +23 -0
  60. data/template/ec2-vpc-gateway-attachment.rb +19 -0
  61. data/template/ec2-vpc.rb +24 -0
  62. data/template/ecs-cluster.rb +11 -0
  63. data/template/ecs-service.rb +24 -0
  64. data/template/ecs-task-definition.rb +18 -0
  65. data/template/elasticache-cache-cluster.rb +63 -0
  66. data/template/elasticache-parameter-group.rb +20 -0
  67. data/template/elasticache-replication-group.rb +58 -0
  68. data/template/elasticache-subnet-group.rb +17 -0
  69. data/template/elasticbeanstalk-application-version.rb +24 -0
  70. data/template/elasticbeanstalk-application.rb +17 -0
  71. data/template/elasticbeanstalk-configuration-template.rb +31 -0
  72. data/template/elasticbeanstalk-environment.rb +44 -0
  73. data/template/elb-loadbalancer.rb +46 -0
  74. data/template/emr-cluster.rb +39 -0
  75. data/template/emr-instance-group-config.rb +33 -0
  76. data/template/emr-step.rb +22 -0
  77. data/template/events-rule.rb +28 -0
  78. data/template/iam-access-key.rb +19 -0
  79. data/template/iam-group.rb +20 -0
  80. data/template/iam-instance-profile.rb +17 -0
  81. data/template/iam-managed-policy.rb +28 -0
  82. data/template/iam-policy.rb +26 -0
  83. data/template/iam-role.rb +21 -0
  84. data/template/iam-user-to-group-addition.rb +17 -0
  85. data/template/iam-user.rb +24 -0
  86. data/template/lambda-alias.rb +21 -0
  87. data/template/lambda-event-source-mapping.rb +24 -0
  88. data/template/lambda-function.rb +34 -0
  89. data/template/lambda-permission.rb +26 -0
  90. data/template/lambda-version.rb +19 -0
  91. data/template/mappings-ec2.rb +85 -0
  92. data/template/output-access-key.rb +6 -0
  93. data/template/output-arn.rb +6 -0
  94. data/template/output-autoscaling.rb +6 -0
  95. data/template/output-az.rb +6 -0
  96. data/template/output-dynamodb.rb +6 -0
  97. data/template/output-ec2.rb +8 -0
  98. data/template/output-elasticache.rb +30 -0
  99. data/template/output-elb.rb +12 -0
  100. data/template/output-emr.rb +6 -0
  101. data/template/output-rds.rb +10 -0
  102. data/template/output-redshift.rb +10 -0
  103. data/template/output-s3.rb +8 -0
  104. data/template/output-security-group.rb +5 -0
  105. data/template/output-sqs.rb +5 -0
  106. data/template/output-topic.rb +6 -0
  107. data/template/output-vpc.rb +10 -0
  108. data/template/output.rb +29 -0
  109. data/template/parameter-ec2.rb +22 -0
  110. data/template/parameter-elasticache.rb +9 -0
  111. data/template/parameter-rds.rb +9 -0
  112. data/template/parameter-redshift.rb +9 -0
  113. data/template/parameter.rb +20 -0
  114. data/template/rds-db-cluster-parameter-group.rb +22 -0
  115. data/template/rds-db-cluster.rb +47 -0
  116. data/template/rds-db-instance.rb +82 -0
  117. data/template/rds-db-parameter-group.rb +21 -0
  118. data/template/rds-db-subnet-group.rb +19 -0
  119. data/template/rds-event-subscription.rb +42 -0
  120. data/template/rds-option-group.rb +23 -0
  121. data/template/redshift-cluster-parameter-group.rb +19 -0
  122. data/template/redshift-cluster-subnet-group.rb +17 -0
  123. data/template/redshift-cluster.rb +60 -0
  124. data/template/s3-bucket-policy.rb +20 -0
  125. data/template/s3-bucket.rb +42 -0
  126. data/template/sns-topic.rb +20 -0
  127. data/template/sqs-queue.rb +27 -0
  128. data/test/_template.rb +26 -0
  129. data/test/abstract_unit.rb +101 -0
  130. data/test/autoscaling_test.rb +109 -0
  131. data/test/codedeploy_test.rb +117 -0
  132. data/test/datapipeline_test.rb +142 -0
  133. data/test/dynamodb_test.rb +184 -0
  134. data/test/ec2_test.rb +286 -0
  135. data/test/ecs_test.rb +135 -0
  136. data/test/elasticbeanstalk_test.rb +56 -0
  137. data/test/elb_test.rb +147 -0
  138. data/test/emr_test.rb +193 -0
  139. data/test/events_test.rb +22 -0
  140. data/test/helper_test.rb +547 -0
  141. data/test/iam_test.rb +93 -0
  142. data/test/lambda_test.rb +41 -0
  143. data/test/s3_test.rb +195 -0
  144. data/test/sns_test.rb +27 -0
  145. data/test/template/autoscaling-group_test.rb +177 -0
  146. data/test/template/autoscaling-launch-configuration_test.rb +117 -0
  147. data/test/template/autoscaling-lifecycle-hook_test.rb +33 -0
  148. data/test/template/autoscaling-scaling-policy_test.rb +26 -0
  149. data/test/template/autoscaling-scheduled-action_test.rb +26 -0
  150. data/test/template/cloudtrail_test.rb +55 -0
  151. data/test/template/cloudwatch-alarm_test.rb +38 -0
  152. data/test/template/codedeploy-application_test.rb +21 -0
  153. data/test/template/codedeploy-deployment-config_test.rb +26 -0
  154. data/test/template/codedeploy-deployment-group_test.rb +48 -0
  155. data/test/template/datapipeline-pipeline_test.rb +358 -0
  156. data/test/template/dynamodb-table_test.rb +94 -0
  157. data/test/template/ec2-eip-association_test.rb +22 -0
  158. data/test/template/ec2-eip_test.rb +21 -0
  159. data/test/template/ec2-instance_test.rb +95 -0
  160. data/test/template/ec2-internet-gateway_test.rb +48 -0
  161. data/test/template/ec2-nat-gateway_test.rb +22 -0
  162. data/test/template/ec2-network-acl-entry_test.rb +61 -0
  163. data/test/template/ec2-network-acl_test.rb +51 -0
  164. data/test/template/ec2-route-table_test.rb +49 -0
  165. data/test/template/ec2-route_test.rb +21 -0
  166. data/test/template/ec2-security-group_test.rb +50 -0
  167. data/test/template/ec2-subnet-netwokr-acl-association_test.rb +26 -0
  168. data/test/template/ec2-subnet-route-table-association_test.rb +22 -0
  169. data/test/template/ec2-subnet_test.rb +51 -0
  170. data/test/template/ec2-volume-attachment_test.rb +24 -0
  171. data/test/template/ec2-volume_test.rb +52 -0
  172. data/test/template/ec2-vpc-gateway-attachment_test.rb +23 -0
  173. data/test/template/ec2-vpc_test.rb +102 -0
  174. data/test/template/ecs-cluster_test.rb +18 -0
  175. data/test/template/ecs-service_test.rb +29 -0
  176. data/test/template/ecs-task-definition_test.rb +143 -0
  177. data/test/template/elasticache-cache-cluster_test.rb +77 -0
  178. data/test/template/elasticache-parameter-group_test.rb +25 -0
  179. data/test/template/elasticache-replication-group_test.rb +45 -0
  180. data/test/template/elasticache-subnet-group_test.rb +26 -0
  181. data/test/template/elasticbeanstalk-application-version_test.rb +27 -0
  182. data/test/template/elasticbeanstalk-application_test.rb +21 -0
  183. data/test/template/elasticbeanstalk-configuration-template_test.rb +23 -0
  184. data/test/template/elasticbeanstalk-environment_test.rb +56 -0
  185. data/test/template/elasticbeanstalk-template_test.rb +33 -0
  186. data/test/template/elb-loadbalancer_test.rb +94 -0
  187. data/test/template/emr-cluster_test.rb +147 -0
  188. data/test/template/emr-instance-group-config_test.rb +65 -0
  189. data/test/template/emr-step_test.rb +82 -0
  190. data/test/template/events-rule_test.rb +34 -0
  191. data/test/template/iam-access-key_test.rb +22 -0
  192. data/test/template/iam-group_test.rb +21 -0
  193. data/test/template/iam-instance-profile_test.rb +24 -0
  194. data/test/template/iam-managed-policy_test.rb +35 -0
  195. data/test/template/iam-policy_test.rb +52 -0
  196. data/test/template/iam-role_test.rb +37 -0
  197. data/test/template/iam-user-to-group-addition_test.rb +24 -0
  198. data/test/template/iam-user_test.rb +21 -0
  199. data/test/template/lambda-alias_test.rb +46 -0
  200. data/test/template/lambda-event-source-mapping_test.rb +36 -0
  201. data/test/template/lambda-function_test.rb +34 -0
  202. data/test/template/lambda-permission_test.rb +32 -0
  203. data/test/template/lambda-version_test.rb +27 -0
  204. data/test/template/mappings-ec2_test.rb +92 -0
  205. data/test/template/output-access-key_test.rb +30 -0
  206. data/test/template/output-arn_test.rb +30 -0
  207. data/test/template/output-autoscaling_test.rb +27 -0
  208. data/test/template/output-az_test.rb +31 -0
  209. data/test/template/output-dynamodb_test.rb +21 -0
  210. data/test/template/output-ec2_test.rb +82 -0
  211. data/test/template/output-elasticache_test.rb +107 -0
  212. data/test/template/output-elb_test.rb +48 -0
  213. data/test/template/output-emr_test.rb +30 -0
  214. data/test/template/output-rds_test.rb +39 -0
  215. data/test/template/output-redshift_test.rb +39 -0
  216. data/test/template/output-s3_test.rb +52 -0
  217. data/test/template/output-security-group_test.rb +21 -0
  218. data/test/template/output-sqs_test.rb +21 -0
  219. data/test/template/output-topic_test.rb +30 -0
  220. data/test/template/output-vpc_test.rb +48 -0
  221. data/test/template/output_test.rb +87 -0
  222. data/test/template/parameter-ec2_test.rb +44 -0
  223. data/test/template/parameter-elasticache_test.rb +30 -0
  224. data/test/template/parameter-rds_test.rb +30 -0
  225. data/test/template/parameter-redshift_test.rb +30 -0
  226. data/test/template/parameter_test.rb +40 -0
  227. data/test/template/rds-db-cluster-parameter-group_test.rb +53 -0
  228. data/test/template/rds-db-cluster_test.rb +84 -0
  229. data/test/template/rds-db-instance_test.rb +93 -0
  230. data/test/template/rds-db-parameter-group_test.rb +53 -0
  231. data/test/template/rds-db-subnet-group.rb +54 -0
  232. data/test/template/rds-event-subscription_test.rb +48 -0
  233. data/test/template/rds-option-group_test.rb +56 -0
  234. data/test/template/redshift-cluster-parameter-group_test.rb +28 -0
  235. data/test/template/redshift-cluster-subnet-group_test.rb +26 -0
  236. data/test/template/redshift-cluster_test.rb +47 -0
  237. data/test/template/s3-bucket-policy_test.rb +40 -0
  238. data/test/template/s3-bucket_test.rb +127 -0
  239. data/test/template/sns-topic_test.rb +42 -0
  240. data/test/template/sqs-queue_test.rb +25 -0
  241. metadata +468 -0
@@ -0,0 +1,28 @@
1
+ #
2
+ # Helper - CloudWatch
3
+ #
4
+
5
+ def _cloudwatch_convert_operator(operator)
6
+ case operator
7
+ when ">="
8
+ "GreaterThanOrEqualToThreshold"
9
+ when ">"
10
+ "GreaterThanThreshold"
11
+ when "<="
12
+ "LessThanThreshold"
13
+ when "<"
14
+ "LessThanOrEqualToThreshold"
15
+ else
16
+ _valid_values(operator,
17
+ %w( GreaterThanOrEqualToThreshold GreaterThanThreshold
18
+ LessThanThreshold LessThanOrEqualToThreshold ),
19
+ "GreaterThanThreshold")
20
+ end
21
+ end
22
+
23
+ def _cloudwatch_dimension(args)
24
+ _{
25
+ Name args[:name]
26
+ Value _ref_string("value", args)
27
+ }
28
+ end
@@ -0,0 +1,85 @@
1
+ #
2
+ # Helper - CodeDeploy
3
+ #
4
+ require 'kumogata/template/helper'
5
+
6
+ def _codedeploy_minimum(args)
7
+ type = _valid_values(args[:type], %w( host_count fleet_percent ), "fleet_percent")
8
+ value = args[:value]
9
+
10
+ _{
11
+ Type type.upcase
12
+ Value value
13
+ }
14
+ end
15
+
16
+ def _codedeploy_deployment(args)
17
+ description = args[:description] || ""
18
+ ignore = _bool("ignore", args, true)
19
+ revision = _codedeploy_revision(args[:revision])
20
+
21
+ _{
22
+ Description description unless description.empty?
23
+ IgnoreApplicationStopFailures ignore
24
+ Revision revision
25
+ }
26
+ end
27
+
28
+ def _codedeploy_revision(args)
29
+ github =
30
+ if args.key? :github
31
+ _codedeploy_github(args[:github])
32
+ else
33
+ ""
34
+ end
35
+ s3 =
36
+ if args.key? :s3
37
+ _codedeploy_s3(args[:s3])
38
+ else
39
+ ""
40
+ end
41
+
42
+ _{
43
+ GitHubLocation github unless github.empty?
44
+ RevisionType github.empty? ? "S3" : "GitHub"
45
+ S3Location s3 unless s3.empty?
46
+ }
47
+ end
48
+
49
+ def _codedeploy_github(args)
50
+ commit = args[:commit] || ""
51
+ repository = args[:repository] || ""
52
+
53
+ _{
54
+ CommitId commit
55
+ Repository repository
56
+ }
57
+ end
58
+
59
+ def _codedeploy_s3(args)
60
+ bucket = _ref_string("bucket", args, "bucket")
61
+ key = _ref_string("key", args)
62
+ bundle = _valid_values(args[:bundle], %w( tar zip ), "zip")
63
+ etag = _ref_string("etag", args)
64
+ version = _ref_string("version", args)
65
+
66
+ _{
67
+ Bucket bucket
68
+ Key key
69
+ BundleType bundle.capitalize
70
+ ETag etag unless etag.empty?
71
+ Version version
72
+ }
73
+ end
74
+
75
+ def _codedeploy_tag_filters(args)
76
+ key = args[:key] || ""
77
+ type = _valid_values(args[:type], %w( key_only value_only key_and_value ), "key_and_value")
78
+ value = args[:value] || ""
79
+
80
+ _{
81
+ Key key
82
+ Type type.upcase
83
+ Value value
84
+ }
85
+ end
@@ -0,0 +1,175 @@
1
+ #
2
+ # AWS Constants
3
+ #
4
+
5
+ AWS_REGION = {
6
+ virginia: "us-east-1",
7
+ oregon: "us-west-2",
8
+ california: "us-west-1",
9
+ ireland: "eu-west-1",
10
+ frankfurt: "eu-central-1",
11
+ singapore: "ap-southeast-1",
12
+ tokyo: "ap-northeast-1",
13
+ sydney: "ap-southeast-2",
14
+ seoul: "ap-northeast-2",
15
+ saopaulo: "sa-east-1",
16
+ }
17
+
18
+ PORT = {
19
+ ssh: 22,
20
+ http: 80,
21
+ https: 443,
22
+ memcached: 11211,
23
+ mysql: 3306,
24
+ mariadb: 3306,
25
+ aurora: 3306,
26
+ postgres: 5432,
27
+ redis: 6379,
28
+ redshift: 5439,
29
+ }
30
+
31
+ DEFAULT_MAINTENANCE_TIME = {
32
+ elasticache: Time.local(2016, 4, 1, 5, 15),
33
+ rds: Time.local(2016, 4, 1, 5, 30),
34
+ redshift: Time.local(2016, 4, 1, 5, 45),
35
+ }
36
+
37
+ DEFAULT_SNAPSHOT_NUM = 10
38
+ DEFAULT_SNAPSHOT_TIME = {
39
+ elasticache: Time.local(2016, 4, 1, 6, 15),
40
+ rds: Time.local(2016, 4, 1, 6, 30),
41
+ }
42
+
43
+ EC2_DEFAULT_IMAGE = "amazon linux official"
44
+
45
+ # https://aws.amazon.com/ec2/pricing/
46
+ EC2_INSTANCE_TYPES =
47
+ [
48
+ # Model vCPU CPU Credits/hour Mem(GiB) Storage
49
+ # t2.nano 1 3 0.5 EBS-Only
50
+ # t2.micro 1 6 1 EBS-Only
51
+ # t2.small 1 12 2 EBS-Only
52
+ # t2.medium 2 24 4 EBS-Only
53
+ # t2.large 2 36 8 EBS-Only
54
+ "t2.nano", "t2.micro", "t2.small", "t2.medium", "t2.large",
55
+
56
+ # Model vCPU Mem(GiB) Storage Dedicated EBS Throughput(Mbps)
57
+ # m4.large 2 8 EBS-only 450
58
+ # m4.xlarge 4 16 EBS-only 750
59
+ # m4.2xlarge 8 32 EBS-only 1,000
60
+ # m4.4xlarge 16 64 EBS-only 2,000
61
+ # m4.10xlarge 40 160 EBS-only 4,000
62
+ "m4.large", "m4.xlarge", "m4.2xlarge", "m4.4xlarge", "m4.10xlarge",
63
+
64
+ # Model vCPU Mem(GiB) Storage Dedicated EBS Throughput(Mbps)
65
+ # c4.large 2 3.75 EBS-Only 500
66
+ # c4.xlarge 4 7.5 EBS-Only 750
67
+ # c4.2xlarge 8 15 EBS-Only 1,000
68
+ # c4.4xlarge 16 30 EBS-Only 2,000
69
+ # c4.8xlarge 36 60 EBS-Only 4,000
70
+ "c4.large", "c4.xlarge", "c4.2xlarge", "c4.4xlarge", "c4.8xlarge",
71
+
72
+ # Model vCPU Mem(GiB) SSD Storage (GB)
73
+ # r3.large 2 15.25 1 x 32
74
+ # r3.xlarge 4 30.5 1 x 80
75
+ # r3.2xlarge 8 61 1 x 160
76
+ # r3.4xlarge 16 122 1 x 320
77
+ # r3.8xlarge 32 244 2 x 320
78
+ "r3.large", "r3.xlarge", "r3.2xlarge", "r3.4xlarge", "r3.8xlarge",
79
+
80
+ # Model vCPU Mem (GiB) SSD Storage (GB)
81
+ # i2.xlarge 4 30.5 1 x 800
82
+ # i2.2xlarge 8 61 2 x 800
83
+ # i2.4xlarge 16 122 4 x 800
84
+ # i2.8xlarge 32 244 8 x 800
85
+ "i2.xlarge", "i2.2xlarge", "i2.4xlarge", "i2.8xlarge",
86
+ ]
87
+ EC2_DEFAULT_INSTANCE_TYPE = "t2.medium"
88
+
89
+ ELASTICACHE_DEFAULT_ENGINE = "redis"
90
+ ELASTICACHE_DEFAULT_ENGINE_VERSION = {
91
+ memcached: "1.4.24",
92
+ redis: "2.8.24",
93
+ }
94
+ # https://aws.amazon.com/elasticache/pricing/
95
+ ELASTICACHE_NODE_TYPES =
96
+ [
97
+ # Cache Node Type vCPU Mem (GiB) Network Performance
98
+ # cache.t2.micro 1 0.555 Low to Moderate
99
+ # cache.t2.small 1 1.55 Low to Moderate
100
+ # cache.t2.medium 2 3.22 Low to Moderate
101
+ # cache.m3.medium 1 2.78 Moderate
102
+ # cache.m3.large 2 6.05 Moderate
103
+ # cache.m3.xlarge 4 13.3 High
104
+ # cache.m3.2xlarge 8 27.9 High
105
+ # cache.r3.large 2 13.5 Moderate
106
+ # cache.r3.xlarge 4 28.4 Moderate
107
+ # cache.r3.2xlarge 8 58.2 High
108
+ # cache.r3.4xlarge 16 118 High
109
+ # cache.r3.8xlarge 32 237 10 Gigabit
110
+ "cache.t2.micro", "cache.t2.small", "cache.t2.medium",
111
+ "cache.m3.medium", "cache.m3.large", "cache.m3.xlarge",
112
+ "cache.m3.2xlarge", "cache.r3.large", "cache.r3.xlarge",
113
+ "cache.r3.2xlarge", "cache.r3.4xlarge", "cache.r3.8xlarge",
114
+ ]
115
+ ELASTICACHE_DEFAULT_NODE_TYPE = "cache.t2.medium"
116
+
117
+ # https://aws.amazon.com/rds/pricing/
118
+ RDS_INSTANCE_CLASSES =
119
+ [
120
+ # Instance Class vCPU ECU Memory (GB) EBS Optimized Network Performance
121
+ # db.t1.micro 1 1 .615 No Very Low
122
+ # db.m1.small 1 1 1.7 No Very Low
123
+ # db.m4.large 2 6.5 8 450 Mbps Moderate
124
+ # db.m4.xlarge 4 13 16 750 Mbps High
125
+ # db.m4.2xlarge 8 25.5 32 1000 Mbps High
126
+ # db.m4.4xlarge 16 53.5 64 2000 Mbps High
127
+ # db.m4.10xlarge 40 124.5 160 4000 Mbps 10 GBps
128
+ # db.r3.large 2 6.5 15 No Moderate
129
+ # db.r3.xlarge 4 13 30.5 500 Mbps Moderate
130
+ # db.r3.2xlarge 8 26 61 1000 Mbps High
131
+ # db.r3.4xlarge 16 52 122 2000 Mbps High
132
+ # db.r3.8xlarge 32 104 244 No 10 Gbps
133
+ # db.t2.micro 1 1 1 No Low
134
+ # db.t2.small 1 1 2 No Low
135
+ # db.t2.medium 2 2 4 No Moderate
136
+ # db.t2.large 2 2 8 No Moderate
137
+ "db.t1.micro",
138
+ "db.m1.small", "db.m4.large", "db.m4.xlarge", "db.m4.2xlarge", "db.m4.4xlarge", "db.m4.10xlarge",
139
+ "db.r3.large", "db.r3.xlarge", "db.r3.2xlarge", "db.r3.4xlarge", "db.r3.8xlarge",
140
+ "db.t2.micro", "db.t2.small", "db.t2.medium", "db.t2.large"
141
+ ]
142
+ RDS_DEFAULT_INSTANCE_CLASS = "db.t2.medium"
143
+ RDS_DEFAULT_ENGINE = "mysql"
144
+ RDS_DEFAULT_ENGINE_VERSION = {
145
+ mysql: "5.7.10",
146
+ mariadb: "10.0.17",
147
+ aurora: "5.6.10a",
148
+ postgres: "9.4.5",
149
+ }
150
+
151
+ # https://aws.amazon.com/redshift/pricing/
152
+ REDSHIFT_NODE_TYPES =
153
+ [
154
+ # Node Size vCPU ECU RAM (GiB) Slices Per Node Storage Per Node Node Range Total Capacity
155
+ # ds1.xlarge 2 4.4 15 2 2 TB HDD 1–32 64 TB
156
+ # ds1.8xlarge 16 35 120 16 16 TB HDD 2–128 2 PB
157
+ # ds2.xlarge 4 13 31 2 2 TB HDD 1–32 64 TB
158
+ # ds2.8xlarge 36 119 244 16 16 TB HDD 2–128 2 PB
159
+ # dc1.large 2 7 15 2 160 GB SSD 1–32 5.12 TB
160
+ # dc1.8xlarge 32 104 244 32 2.56 TB SSD 2–128 326 TB
161
+ "ds1.xlarge", "ds1.8xlarge", "ds2.xlarge", "ds2.8xlarge", "dc1.large", "dc1.8xlarge",
162
+ ]
163
+ REDSHIFT_DEFAULT_NODE_TYPE = "ds1.xlarge"
164
+
165
+ # https://aws.amazon.com/elasticmapreduce/pricing/
166
+ EMR_INSTANCE_TYPES =
167
+ [
168
+ "c4.large", "c4.xlarge", "c4.2xlarge", "c4.4xlarge", "c4.8xlarge",
169
+ "m4.large", "m4.xlarge", "m4.2xlarge", "m4.4xlarge", "m4.10xlarge",
170
+ "i2.xlarge", "i2.2xlarge", "i2.4xlarge", "i2.8xlarge",
171
+ ]
172
+ EMR_DEFAULT_INSTANCE_TYPE = "c4.large"
173
+
174
+ # http://docs.aws.amazon.com/ElasticMapReduce/latest/ReleaseGuide/emr-whatsnew.html
175
+ EMR_DEFAULT_RELEASE = "emr-4.6.0"
@@ -0,0 +1,90 @@
1
+ #
2
+ # Helper - DataPipeline
3
+ #
4
+ require 'kumogata/template/helper'
5
+
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|
12
+ attributes = _datapipeline_parameter_objects_attributes(value)
13
+ array << _{
14
+ Attributes attributes
15
+ Id id
16
+ }
17
+ end
18
+ end
19
+ array
20
+ end
21
+
22
+ def _datapipeline_parameter_objects_attributes(args)
23
+ attributes = args[:attributes] || {}
24
+
25
+ array = []
26
+ attributes.each do |key, value|
27
+ array << _{
28
+ Key key
29
+ StringValue value
30
+ }
31
+ end
32
+ array
33
+ end
34
+
35
+ def _datapipeline_parameter_values(args)
36
+ values = args[:parameter_values] || {}
37
+
38
+ array = []
39
+ values.each do |id, val|
40
+ array << _{
41
+ Id id
42
+ StringValue val
43
+ }
44
+ end
45
+ array
46
+ end
47
+
48
+ def _datapipeline_pipeline_objects(args)
49
+ objects = args[:objects] || []
50
+
51
+ array = []
52
+ objects.each do |object|
53
+ object.each do |id, value|
54
+ fields = _datapipeline_pipeline_object_fields(value)
55
+ array << _{
56
+ Fields fields
57
+ Id id
58
+ Name value[:name]
59
+ }
60
+ end
61
+ end
62
+ array
63
+ end
64
+
65
+ def _datapipeline_pipeline_object_fields(args)
66
+ fields = args[:fields] || {}
67
+
68
+ array = []
69
+ fields.each do |key, value|
70
+ array << _{
71
+ Key key
72
+ RefValue value[:ref] if value.key? :ref
73
+ StringValue value[:string] if value.key? :string
74
+ }
75
+ end
76
+ array
77
+ end
78
+
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
@@ -0,0 +1,111 @@
1
+ #
2
+ # Helper - DynamoDB
3
+ #
4
+ require 'kumogata/template/helper'
5
+
6
+ def _dynamodb_attribute(args)
7
+ attributes = []
8
+ _array(args).each do |arg|
9
+ if arg.is_a? String
10
+ attributes << { type: "string", value: arg }
11
+ elsif arg.is_a? Hash
12
+ arg.each_pair.collect{|type, value| attributes << { type: type, value: value } }
13
+ end
14
+ end
15
+
16
+ array = []
17
+ attributes.each do |attribute|
18
+ type =
19
+ case attribute[:type].to_sym
20
+ when :binary
21
+ "B"
22
+ when :integer
23
+ "N"
24
+ else
25
+ "S"
26
+ end
27
+ array << _{
28
+ AttributeName attribute[:value]
29
+ AttributeType type
30
+ }
31
+ end
32
+ array
33
+ end
34
+
35
+ def _dynamodb_key_schema(args)
36
+ schemas = []
37
+ _array(args).each do |arg|
38
+ if arg.is_a? String
39
+ schemas << { type: "hash", value: arg }
40
+ elsif arg.is_a? Hash
41
+ arg.each_pair.collect{|type, value| schemas << { type: type, value: value } }
42
+ end
43
+ end
44
+
45
+ array = []
46
+ schemas.each do |schema|
47
+ type =
48
+ case schema[:type].to_sym
49
+ when :range
50
+ "range"
51
+ else
52
+ "hash"
53
+ end
54
+ array << _{
55
+ AttributeName schema[:value]
56
+ KeyType type.upcase
57
+ }
58
+ end
59
+ array
60
+ end
61
+
62
+ def _dynamodb_projection(args)
63
+ non_key = args[:non_key] || []
64
+ type = _valid_values(args[:type], %w( keys_only include all ), "include")
65
+
66
+ _{
67
+ NonKeyAttributes non_key unless non_key.empty?
68
+ ProjectionType type.upcase unless type.empty?
69
+ }
70
+ end
71
+
72
+ def _dynamodb_provisioned(args)
73
+ _{
74
+ ReadCapacityUnits args[:read] || 5
75
+ WriteCapacityUnits args[:write] || args[:read] || 5
76
+ }
77
+ end
78
+
79
+ def _dynamodb_stream(args)
80
+ stream = args[:stream] || ""
81
+
82
+ _{
83
+ StreamViewType stream
84
+ }
85
+ end
86
+
87
+ def _dynamodb_global(args)
88
+ index = args[:index]
89
+ key_schema = _dynamodb_key_schema(args[:key_schema])
90
+ projection = _dynamodb_projection(args[:projection])
91
+ provisioned = _dynamodb_provisioned(args[:provisioned])
92
+
93
+ _{
94
+ IndexName index
95
+ KeySchema key_schema
96
+ Projection projection
97
+ ProvisionedThroughput provisioned
98
+ }
99
+ end
100
+
101
+ def _dynamodb_local(args)
102
+ index = args[:index]
103
+ key_schema = _dynamodb_key_schema(args[:key_schema])
104
+ projection = _dynamodb_projection(args[:projection])
105
+
106
+ _{
107
+ IndexName index
108
+ KeySchema key_schema
109
+ Projection projection
110
+ }
111
+ end