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.
- checksums.yaml +5 -5
- data/.travis.yml +4 -2
- data/Gemfile +1 -1
- data/Rakefile +1 -1
- data/kumogata-template.gemspec +4 -4
- data/lib/kumogata/template/alb.rb +48 -34
- data/lib/kumogata/template/api-gateway.rb +262 -0
- data/lib/kumogata/template/autoscaling.rb +17 -44
- data/lib/kumogata/template/certificate.rb +11 -8
- data/lib/kumogata/template/cloudfront.rb +67 -60
- data/lib/kumogata/template/cloudwatch.rb +7 -12
- data/lib/kumogata/template/codebuild.rb +4 -8
- data/lib/kumogata/template/codecommit.rb +2 -6
- data/lib/kumogata/template/codedeploy.rb +15 -0
- data/lib/kumogata/template/cognito.rb +203 -0
- data/lib/kumogata/template/const.rb +109 -47
- data/lib/kumogata/template/datapipeline.rb +16 -47
- data/lib/kumogata/template/dynamodb.rb +17 -8
- data/lib/kumogata/template/ec2.rb +61 -10
- data/lib/kumogata/template/ecr.rb +11 -9
- data/lib/kumogata/template/ecs.rb +256 -91
- data/lib/kumogata/template/elasticbeanstalk.rb +6 -9
- data/lib/kumogata/template/elb.rb +9 -24
- data/lib/kumogata/template/emr.rb +184 -51
- data/lib/kumogata/template/events.rb +22 -10
- data/lib/kumogata/template/ext/kumogata.rb +7 -7
- data/lib/kumogata/template/helper.rb +189 -130
- data/lib/kumogata/template/iam.rb +556 -146
- data/lib/kumogata/template/kinesis.rb +282 -0
- data/lib/kumogata/template/lambda.rb +43 -2
- data/lib/kumogata/template/logs.rb +2 -6
- data/lib/kumogata/template/nlb.rb +10 -0
- data/lib/kumogata/template/pinpoint.rb +83 -0
- data/lib/kumogata/template/rds.rb +52 -0
- data/lib/kumogata/template/redshift.rb +15 -6
- data/lib/kumogata/template/role.rb +425 -0
- data/lib/kumogata/template/s3.rb +120 -80
- data/lib/kumogata/template/sns.rb +2 -6
- data/lib/kumogata/template/version.rb +1 -1
- data/lib/kumogata/template.rb +9 -1
- data/template/_template.rb +2 -2
- data/template/alb-load-balancer.rb +5 -4
- data/template/alb-target-group.rb +8 -9
- data/template/api-gateway-account.rb +15 -0
- data/template/api-gateway-api-key.rb +22 -0
- data/template/api-gateway-authorizer.rb +38 -0
- data/template/api-gateway-base-path-mapping.rb +23 -0
- data/template/api-gateway-client-certificate.rb +16 -0
- data/template/api-gateway-deployment.rb +24 -0
- data/template/api-gateway-domain-name.rb +17 -0
- data/template/api-gateway-method.rb +71 -0
- data/template/api-gateway-model.rb +23 -0
- data/template/api-gateway-resource.rb +32 -0
- data/template/api-gateway-rest-api.rb +29 -0
- data/template/api-gateway-stage.rb +33 -0
- data/template/api-gateway-usage-plan-key.rb +19 -0
- data/template/api-gateway-usage-plan.rb +24 -0
- data/template/autoscaling-group.rb +2 -2
- data/template/autoscaling-launch-configuration.rb +7 -4
- data/template/autoscaling-scheduled-action.rb +0 -1
- data/template/certificate.rb +2 -2
- data/template/cloudfront-distribution.rb +4 -0
- data/template/cloudfront-origin-access-identity.rb +19 -0
- data/template/cloudtrail.rb +6 -4
- data/template/cloudwatch-alarm.rb +9 -3
- data/template/codebuild-project.rb +3 -3
- data/template/codecommit-repository.rb +2 -2
- data/template/codedeploy-application.rb +1 -1
- data/template/codedeploy-deployment-config.rb +1 -1
- data/template/codedeploy-deployment-group.rb +2 -0
- data/template/cognito-identity-pool.rb +34 -0
- data/template/cognito-identity-role-attachment.rb +22 -0
- data/template/cognito-user-pool-client.rb +28 -0
- data/template/cognito-user-pool-group.rb +24 -0
- data/template/cognito-user-pool-user-to-group-attachment.rb +20 -0
- data/template/cognito-user-pool-user.rb +28 -0
- data/template/cognito-user-pool.rb +45 -0
- data/template/datapipeline-pipeline.rb +4 -4
- data/template/dynamodb-table.rb +5 -1
- data/template/ec2-eip-association.rb +1 -1
- data/template/ec2-instance.rb +4 -1
- data/template/ec2-nat-gateway.rb +4 -0
- data/template/ec2-route.rb +4 -0
- data/template/ec2-security-group-ingress.rb +1 -1
- data/template/ec2-security-group.rb +2 -2
- data/template/ec2-subnet.rb +8 -4
- data/template/ec2-volume.rb +1 -2
- data/template/ec2-vpc-cidr-block.rb +4 -2
- data/template/ec2-vpc-endpoint.rb +5 -2
- data/template/ecr-repository.rb +2 -2
- data/template/ecs-cluster.rb +1 -1
- data/template/ecs-service.rb +19 -7
- data/template/ecs-task-definition.rb +4 -4
- data/template/elasticache-cache-cluster.rb +1 -1
- data/template/elasticache-parameter-group.rb +1 -1
- data/template/elasticache-replication-group.rb +1 -1
- data/template/elasticache-subnet-group.rb +1 -1
- data/template/elasticbeanstalk-application-version.rb +1 -1
- data/template/elasticbeanstalk-application.rb +1 -1
- data/template/elasticbeanstalk-configuration-template.rb +1 -1
- data/template/elasticbeanstalk-environment.rb +1 -1
- data/template/elb-load-balancer.rb +2 -2
- data/template/emr-cluster.rb +3 -3
- data/template/emr-instance-group-config.rb +4 -2
- data/template/emr-security-configuration.rb +17 -0
- data/template/emr-step.rb +2 -2
- data/template/events-rule.rb +8 -8
- data/template/iam-group.rb +2 -2
- data/template/iam-instance-profile.rb +2 -2
- data/template/iam-managed-policy.rb +1 -1
- data/template/iam-policy.rb +1 -1
- data/template/iam-role.rb +17 -2
- data/template/iam-user.rb +4 -4
- data/template/kinesis-firehose-delivery-stream.rb +36 -0
- data/template/kinesis-stream.rb +21 -0
- data/template/kms-alias.rb +2 -2
- data/template/kms-key.rb +1 -1
- data/template/lambda-alias.rb +2 -2
- data/template/lambda-event-source-mapping.rb +4 -4
- data/template/lambda-function.rb +17 -17
- data/template/lambda-permission.rb +31 -10
- data/template/lambda-version.rb +4 -2
- data/template/logs-destination.rb +1 -1
- data/template/logs-log-group.rb +1 -1
- data/template/logs-log-stream.rb +4 -2
- data/template/logs-metric-filter.rb +1 -1
- data/template/logs-subscription_filter.rb +1 -1
- data/template/mappings-ec2.rb +114 -52
- data/template/output-arn.rb +12 -4
- data/template/output-certificate.rb +11 -0
- data/template/output-distribution.rb +11 -0
- data/template/output-domain-name.rb +11 -0
- data/template/output-ecr-repository.rb +16 -0
- data/template/output-eip.rb +11 -0
- data/template/output-lambda-function.rb +6 -0
- data/template/output-name.rb +7 -2
- data/template/output-origin-access-identity.rb +13 -0
- data/template/output-rds-cluster.rb +17 -0
- data/template/{output-rds.rb → output-rds-instance.rb} +1 -1
- data/template/output-redshift.rb +11 -0
- data/template/output-rest-api.rb +11 -0
- data/template/output-s3.rb +3 -0
- data/template/output-stage.rb +19 -0
- data/template/output-subnet.rb +6 -3
- data/template/output-trail.rb +14 -0
- data/template/output-user-pool-client.rb +14 -0
- data/template/output-user-pool.rb +17 -0
- data/template/output-vpc.rb +13 -3
- data/template/output.rb +3 -2
- data/template/parameter-ec2.rb +10 -4
- data/template/parameter-elasticache.rb +1 -1
- data/template/parameter-rds.rb +51 -4
- data/template/parameter-redshift.rb +31 -1
- data/template/parameter.rb +87 -7
- data/template/rds-db-cluster-parameter-group.rb +18 -4
- data/template/rds-db-cluster.rb +19 -7
- data/template/rds-db-instance.rb +55 -131
- data/template/rds-db-parameter-group.rb +29 -3
- data/template/rds-db-subnet-group.rb +1 -1
- data/template/rds-event-subscription.rb +2 -4
- data/template/rds-option-group.rb +28 -5
- data/template/redshift-cluster-parameter-group.rb +3 -1
- data/template/redshift-cluster-security-group.rb +17 -0
- data/template/redshift-cluster-subnet-group.rb +3 -1
- data/template/redshift-cluster.rb +15 -12
- data/template/s3-bucket.rb +10 -5
- data/template/sns-topic.rb +2 -2
- data/template/sqs-queue.rb +1 -1
- data/test/abstract_unit.rb +2 -9
- data/test/cloudfront_test.rb +57 -28
- data/test/codedeploy_test.rb +21 -0
- data/test/datapipeline_test.rb +0 -22
- data/test/ec2_test.rb +12 -52
- data/test/ecs_test.rb +30 -26
- data/test/emr_test.rb +101 -20
- data/test/events_test.rb +47 -0
- data/test/helper_test.rb +251 -281
- data/test/iam_test.rb +572 -57
- data/test/lambda_test.rb +1 -1
- data/test/s3_test.rb +49 -14
- data/test/template/alb-load-balancer_test.rb +4 -5
- data/test/template/alb-target-group_test.rb +1 -3
- data/test/template/api-gateway-account_test.rb +26 -0
- data/test/template/api-gateway-api-key_test.rb +33 -0
- data/test/template/api-gateway-authorizer_test.rb +62 -0
- data/test/template/api-gateway-base-path-mapping_test.rb +27 -0
- data/test/template/api-gateway-client-certificate_test.rb +21 -0
- data/test/template/api-gateway-deployment_test.rb +27 -0
- data/test/template/api-gateway-domain-name_test.rb +26 -0
- data/test/template/api-gateway-method_test.rb +29 -0
- data/test/template/api-gateway-model_test.rb +37 -0
- data/test/template/api-gateway-resource_test.rb +82 -0
- data/test/template/api-gateway-rest-api_test.rb +33 -0
- data/test/template/api-gateway-stage_test.rb +39 -0
- data/test/template/api-gateway-usage-plan-key_test.rb +25 -0
- data/test/template/api-gateway-usage-plan_test.rb +42 -0
- data/test/template/cloudfront-distribution_test.rb +41 -3
- data/test/template/cloudtrail_test.rb +13 -5
- data/test/template/cloudwatch-alarm_test.rb +14 -2
- data/test/template/codebuild-project_test.rb +2 -11
- data/test/template/codecommit-repository_test.rb +12 -1
- data/test/template/cognito-identity-pool_test.rb +32 -0
- data/test/template/cognito-identity-role-attachment_test.rb +38 -0
- data/test/template/cognito-user-pool-client_test.rb +36 -0
- data/test/template/cognito-user-pool-group_test.rb +36 -0
- data/test/template/cognito-user-pool-user-to-group-attachment_test.rb +29 -0
- data/test/template/cognito-user-pool-user_test.rb +38 -0
- data/test/template/cognito-user-pool_test.rb +99 -0
- data/test/template/datapipeline-pipeline_test.rb +45 -6
- data/test/template/dynamodb-table_test.rb +19 -1
- data/test/template/ec2-instance_test.rb +9 -1
- data/test/template/ec2-nat-gateway_test.rb +29 -1
- data/test/template/ec2-security-group-egress_test.rb +1 -0
- data/test/template/ec2-security-group-ingress_test.rb +1 -0
- data/test/template/ec2-security-group_test.rb +11 -1
- data/test/template/ec2-spot-fleet_test.rb +1 -1
- data/test/template/ec2-subnet_test.rb +62 -1
- data/test/template/ec2-vpc-cidr-block_test.rb +1 -1
- data/test/template/ec2-vpc-endpoint_test.rb +56 -0
- data/test/template/ecr-repository_test.rb +63 -11
- data/test/template/ecs-service_test.rb +13 -2
- data/test/template/ecs-task-definition_test.rb +86 -13
- data/test/template/elasticache-cache-cluster_test.rb +4 -6
- data/test/template/elasticache-replication-group_test.rb +1 -1
- data/test/template/elasticbeanstalk-application-version_test.rb +1 -0
- data/test/template/elasticbeanstalk-application_test.rb +2 -1
- data/test/template/elasticbeanstalk-configuration-template_test.rb +2 -1
- data/test/template/elasticbeanstalk-template_test.rb +1 -0
- data/test/template/elb-load-balancer_test.rb +1 -3
- data/test/template/emr-cluster_test.rb +2 -14
- data/test/template/emr-instance-group-config_test.rb +2 -4
- data/test/template/emr-security-configuration_test.rb +34 -0
- data/test/template/emr-step_test.rb +2 -6
- data/test/template/events-rule_test.rb +3 -3
- data/test/template/iam-group_test.rb +11 -1
- data/test/template/iam-instance-profile_test.rb +11 -1
- data/test/template/iam-managed-policy_test.rb +1 -0
- data/test/template/iam-policy_test.rb +1 -3
- data/test/template/iam-role_test.rb +12 -2
- data/test/template/iam-user_test.rb +11 -17
- data/test/template/kinesis-firehorse-delivery-stream_test.rb +68 -0
- data/test/template/kinesis-stream_test.rb +61 -0
- data/test/template/kms-key_test.rb +1 -0
- data/test/template/lambda-alias_test.rb +2 -3
- data/test/template/lambda-event-source-mapping_test.rb +1 -1
- data/test/template/lambda-function_test.rb +20 -32
- data/test/template/lambda-permission_test.rb +7 -4
- data/test/template/lambda-version_test.rb +5 -2
- data/test/template/logs-log-group_test.rb +1 -3
- data/test/template/logs-log-stream_test.rb +2 -6
- data/test/template/logs-metric-filter_test.rb +1 -3
- data/test/template/logs-subscription-filter_test.rb +1 -3
- data/test/template/mappings-ec2_test.rb +10 -3
- data/test/template/output-domain-name_test.rb +30 -0
- data/test/template/output-name_test.rb +9 -0
- data/test/template/{output-rds_test.rb → output-rds-instance_test.rb} +2 -2
- data/test/template/output-rest-api_test.rb +30 -0
- data/test/template/output-s3_test.rb +9 -0
- data/test/template/output-stage_test.rb +43 -0
- data/test/template/output-user-pool-client_test.rb +39 -0
- data/test/template/output-user-pool_test.rb +48 -0
- data/test/template/output_test.rb +3 -1
- data/test/template/parameter-ec2_test.rb +22 -24
- data/test/template/parameter-elasticache_test.rb +2 -1
- data/test/template/parameter-rds_test.rb +32 -3
- data/test/template/parameter-redshift_test.rb +31 -2
- data/test/template/parameter_test.rb +37 -4
- data/test/template/rds-db-cluster-parameter-group_test.rb +1 -1
- data/test/template/rds-db-cluster_test.rb +4 -20
- data/test/template/rds-db-instance_test.rb +3 -373
- data/test/template/rds-db-parameter-group_test.rb +1 -1
- data/test/template/rds-option-group_test.rb +2 -2
- data/test/template/redshift-cluster-parameter-group_test.rb +28 -0
- data/test/template/redshift-cluster-security-group_test.rb +49 -0
- data/test/template/redshift-cluster-subnet-group_test.rb +28 -0
- data/test/template/redshift-cluster_test.rb +33 -5
- data/test/template/s3-bucket_test.rb +6 -20
- metadata +130 -22
@@ -2,7 +2,7 @@
|
|
2
2
|
# Helper - EMR
|
3
3
|
#
|
4
4
|
require 'kumogata/template/helper'
|
5
|
-
|
5
|
+
require 'kumogata/template/cloudwatch'
|
6
6
|
|
7
7
|
def _emr_to_configurations_default_hadoop_spark(max_age: 14)
|
8
8
|
_emr_to_configurations_default_hadoop | _emr_to_configurations_default_spark(max_age: max_age)
|
@@ -45,25 +45,22 @@ end
|
|
45
45
|
def _emr_applications(args)
|
46
46
|
applications = args[:applications] || []
|
47
47
|
|
48
|
-
|
49
|
-
applications.each do |application|
|
48
|
+
applications.collect do |application|
|
50
49
|
args = application[:args] || []
|
51
|
-
|
50
|
+
_{
|
52
51
|
#AdditionalInfo
|
53
52
|
Args args unless args.empty?
|
54
53
|
Name application[:name].capitalize
|
55
54
|
Version application[:version] if application.key? :version
|
56
55
|
}
|
57
56
|
end
|
58
|
-
array
|
59
57
|
end
|
60
58
|
|
61
59
|
def _emr_bootstraps(args)
|
62
60
|
actions = args[:bootstraps] || []
|
63
61
|
|
64
|
-
|
65
|
-
|
66
|
-
array << _{
|
62
|
+
actions.collect do |action|
|
63
|
+
_{
|
67
64
|
Name action[:name]
|
68
65
|
ScriptBootstrapAction _{
|
69
66
|
Args action[:script_args] if action.key? :script_args
|
@@ -71,50 +68,31 @@ def _emr_bootstraps(args)
|
|
71
68
|
}
|
72
69
|
}
|
73
70
|
end
|
74
|
-
array
|
75
71
|
end
|
76
72
|
|
77
73
|
def _emr_configurations(args)
|
78
74
|
configurations = args[:configurations] || []
|
79
75
|
|
80
|
-
|
81
|
-
configurations.each do |configuration|
|
76
|
+
configurations.collect do |configuration|
|
82
77
|
classification = configuration[:classification] || ""
|
83
78
|
properties = configuration[:properties] || {}
|
84
|
-
|
85
|
-
|
79
|
+
configurations = _emr_configurations(configuration)
|
80
|
+
_{
|
86
81
|
Classification classification unless classification.empty?
|
87
82
|
ConfigurationProperties properties
|
88
|
-
Configurations
|
83
|
+
Configurations configurations
|
89
84
|
}
|
90
85
|
end
|
91
|
-
array
|
92
|
-
end
|
93
|
-
|
94
|
-
def _emr_configuring(args)
|
95
|
-
configurations = args[:configurations] || []
|
96
|
-
|
97
|
-
array = []
|
98
|
-
configurations.each do |configuration|
|
99
|
-
classification = configuration[:classification] || ""
|
100
|
-
properties = configuration[:properties] || {}
|
101
|
-
array << _{
|
102
|
-
Classification classification unless classification.empty?
|
103
|
-
ConfigurationProperties properties
|
104
|
-
Configurations []
|
105
|
-
}
|
106
|
-
end
|
107
|
-
array
|
108
86
|
end
|
109
87
|
|
110
88
|
def _emr_ebs(args)
|
111
89
|
ebs = args[:ebs] || []
|
112
90
|
return '' if ebs.empty?
|
113
|
-
|
91
|
+
block_devices = ebs.collect{|v| _emr_ebs_block_device(v) }
|
114
92
|
|
115
93
|
_{
|
116
|
-
|
117
|
-
|
94
|
+
EbsBlockDeviceConfig block_devices
|
95
|
+
EbsOptimized true if args.key? :ebs_optimized
|
118
96
|
}
|
119
97
|
end
|
120
98
|
|
@@ -145,13 +123,15 @@ def _emr_job_flow(args)
|
|
145
123
|
|
146
124
|
add_master_security_groups = _ref_array("add_master_security_groups", job, "security group")
|
147
125
|
add_slave_security_groups = _ref_array("add_slave_security_groups", job, "security group")
|
126
|
+
core_instance_fleet = _emr_instance_fleet(job[:core])
|
148
127
|
core_instance_group = _emr_instance_group(job[:core])
|
149
128
|
key_name = _ref_string("key_name", job, "key name")
|
150
129
|
subnet = _ref_string("subnet", job, "subnet")
|
151
130
|
emr_master_security_group = _ref_string("emr_master_security_group", job, "security group")
|
152
131
|
emr_slave_security_group = _ref_string("emr_slave_security_group", job, "security group")
|
153
132
|
hadoop_version = _valid_values("hadoop", %w( 1.0.3 2.2.0 2.4.0 ))
|
154
|
-
|
133
|
+
master_instance_fleet = _emr_instance_fleet(job[:master])
|
134
|
+
master_instance_group = _emr_instance_group(job[:master])
|
155
135
|
placement = job[:placement] || ""
|
156
136
|
service_access_security_group = _ref_string("service_access_security_group", job, "security group")
|
157
137
|
termination = _bool("termination", job, false)
|
@@ -159,13 +139,15 @@ def _emr_job_flow(args)
|
|
159
139
|
_{
|
160
140
|
AdditionalMasterSecurityGroups add_master_security_groups unless add_master_security_groups.empty?
|
161
141
|
AdditionalSlaveSecurityGroups add_slave_security_groups unless add_slave_security_groups.empty?
|
162
|
-
|
142
|
+
CoreInstanceFleet core_instance_fleet unless core_instance_fleet.empty?
|
143
|
+
CoreInstanceGroup core_instance_group if core_instance_fleet.empty?
|
163
144
|
Ec2KeyName key_name unless key_name.empty?
|
164
145
|
Ec2SubnetId subnet unless subnet.empty?
|
165
146
|
EmrManagedMasterSecurityGroup emr_master_security_group unless emr_master_security_group.empty?
|
166
147
|
EmrManagedSlaveSecurityGroup emr_slave_security_group unless emr_slave_security_group.empty?
|
167
148
|
HadoopVersion hadoop_version unless hadoop_version.nil?
|
168
|
-
|
149
|
+
MasterInstanceFleet master_instance_fleet unless master_instance_fleet.empty?
|
150
|
+
MasterInstanceGroup master_instance_group if master_instance_fleet.empty?
|
169
151
|
Placement _{
|
170
152
|
AvailabilityZone placement
|
171
153
|
} unless placement.empty?
|
@@ -174,20 +156,81 @@ def _emr_job_flow(args)
|
|
174
156
|
}
|
175
157
|
end
|
176
158
|
|
159
|
+
def _emr_instance_fleet(args)
|
160
|
+
fleet = args[:fleet] || ""
|
161
|
+
return fleet if fleet.empty?
|
162
|
+
|
163
|
+
configs = _emr_instance_fleet_type_config(fleet)
|
164
|
+
launch = _emr_instance_fleet_launch(fleet)
|
165
|
+
name = _name("fleet", fleet)
|
166
|
+
on_demand = fleet[:on_demand] || 1
|
167
|
+
spot = fleet[:spot] || 1
|
168
|
+
|
169
|
+
_{
|
170
|
+
InstanceTypeConfigs configs
|
171
|
+
LaunchSpecifications do
|
172
|
+
SpotSpecification launch
|
173
|
+
end unless launch.empty?
|
174
|
+
Name name
|
175
|
+
TargetOnDemandCapacity on_demand
|
176
|
+
TargetSpotCapacity spot
|
177
|
+
}
|
178
|
+
end
|
179
|
+
|
180
|
+
def _emr_instance_fleet_type_config(args)
|
181
|
+
(args[:configs] || []).collect do |config|
|
182
|
+
bid = config[:bid] || 0
|
183
|
+
bid_percent = config[:bid_percent] || ""
|
184
|
+
configurations = _emr_configurations(config)
|
185
|
+
ebs = _emr_ebs(config)
|
186
|
+
instance_type = _ref_string_default("instance_type", args, "instance type", EMR_DEFAULT_INSTANCE_TYPE)
|
187
|
+
weighted = config[:weighted] || 1
|
188
|
+
|
189
|
+
_{
|
190
|
+
BidPrice bid if 0 < bid
|
191
|
+
BidPriceAsPercentageOfOnDemandPrice bid_percent unless bid_percent.empty?
|
192
|
+
Configurations configurations unless configurations.empty?
|
193
|
+
EbsConfiguration ebs unless ebs.empty?
|
194
|
+
InstanceType instance_type
|
195
|
+
WeightedCapacity weighted
|
196
|
+
}
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
def _emr_instance_fleet_launch(args)
|
201
|
+
launch = args[:launch] || ""
|
202
|
+
return launch if launch.empty?
|
203
|
+
|
204
|
+
block = _valid_values(launch[:block], %w( 60 120 180 240 300 360 ), "")
|
205
|
+
timeout_action =
|
206
|
+
case launch[:timeout_action]
|
207
|
+
when "switch"
|
208
|
+
"SWITCH_TO_ON_DEMAND"
|
209
|
+
when "terminate"
|
210
|
+
"TERMINATE_CLUSTER"
|
211
|
+
else
|
212
|
+
"SWITCH_TO_ON_DEMAND"
|
213
|
+
end
|
214
|
+
timeout_duration = launch[:timeout_duration] || 5
|
215
|
+
|
216
|
+
_{
|
217
|
+
BlockDurationMinutes block unless block.empty?
|
218
|
+
TimeoutAction timeout_action.upcase
|
219
|
+
TimeoutDurationMinutes timeout_duration
|
220
|
+
}
|
221
|
+
end
|
222
|
+
|
177
223
|
def _emr_instance_group(args)
|
178
224
|
bid = args[:bid] || ""
|
179
225
|
configurations = _emr_configurations(args)
|
180
|
-
ebs_configuration = _emr_ebs(args)
|
181
226
|
instance_count = args[:instance_count] || 1
|
182
|
-
instance_type =
|
183
|
-
instance_type = EMR_DEFAULT_INSTANCE_TYPE if instance_type.empty?
|
227
|
+
instance_type = _ref_string_default("instance_type", args, "instance type", EMR_DEFAULT_INSTANCE_TYPE)
|
184
228
|
market = _valid_values("market", %w( on_demand, spot), "on_demand")
|
185
|
-
name =
|
229
|
+
name = _ref_string("name", args)
|
186
230
|
|
187
231
|
_{
|
188
232
|
BidPrice bid unless bid.empty?
|
189
233
|
Configurations configurations unless configurations.empty?
|
190
|
-
EbsConfiguration ebs_configuration unless ebs_configuration.empty?
|
191
234
|
InstanceCount instance_count
|
192
235
|
InstanceType instance_type
|
193
236
|
Market market.upcase
|
@@ -199,7 +242,7 @@ def _emr_hadoop_jar_step_config(args)
|
|
199
242
|
config_args = args[:args] || []
|
200
243
|
jar = args[:jar]
|
201
244
|
main_class = args[:main_class] || ""
|
202
|
-
step_properties =
|
245
|
+
step_properties = _pair_value(args, "step")
|
203
246
|
|
204
247
|
_{
|
205
248
|
Args config_args unless config_args.empty?
|
@@ -209,15 +252,105 @@ def _emr_hadoop_jar_step_config(args)
|
|
209
252
|
}
|
210
253
|
end
|
211
254
|
|
212
|
-
def
|
213
|
-
|
255
|
+
def _emr_instance_autoscaling(args)
|
256
|
+
autoscaling = args[:autoscaling] || ""
|
257
|
+
return "" if autoscaling.empty?
|
214
258
|
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
259
|
+
rules = _emr_instance_autoscaling_rules(autoscaling)
|
260
|
+
|
261
|
+
_{
|
262
|
+
Constraints do
|
263
|
+
MaxCapacity autoscaling[:max]
|
264
|
+
MinCapacity autoscaling[:min]
|
265
|
+
end
|
266
|
+
Rules rules
|
267
|
+
}
|
268
|
+
end
|
269
|
+
|
270
|
+
def _emr_instance_autoscaling_rules(args)
|
271
|
+
rules = args[:rules] || []
|
272
|
+
|
273
|
+
rules.collect do |rule|
|
274
|
+
action = _emr_instance_autoscaling_rule_action(rule)
|
275
|
+
name = _name("rule", rule)
|
276
|
+
description = _ref_string_default("description", rule, '', "#{name} instance autoscaling rules description")
|
277
|
+
trigger = _emr_instance_autoscaling_rule_trigger(rule)
|
278
|
+
_{
|
279
|
+
Action action
|
280
|
+
Description description
|
281
|
+
Name name
|
282
|
+
Trigger trigger
|
220
283
|
}
|
221
284
|
end
|
222
|
-
|
285
|
+
end
|
286
|
+
|
287
|
+
def _emr_instance_autoscaling_rule_action(args)
|
288
|
+
market = _valid_values(args[:market] || "", %w( on_demand, spot), "on_demand")
|
289
|
+
simple = _emr_instance_autoscaling_rule_action_simple(args)
|
290
|
+
|
291
|
+
_{
|
292
|
+
Market market.upcase
|
293
|
+
SimpleScalingPolicyConfiguration simple
|
294
|
+
}
|
295
|
+
end
|
296
|
+
|
297
|
+
def _emr_instance_autoscaling_rule_action_simple(args)
|
298
|
+
adjustment =
|
299
|
+
case args[:type]
|
300
|
+
when "change"
|
301
|
+
"CHANGE_IN_CAPACITY"
|
302
|
+
when "percent"
|
303
|
+
"PERCENT_CHANGE_IN_CAPACITY"
|
304
|
+
when "exact"
|
305
|
+
"EXACT_CAPACITY"
|
306
|
+
else
|
307
|
+
"CHANGE_IN_CAPACITY"
|
308
|
+
end
|
309
|
+
cool = args[:cool] || 0
|
310
|
+
scaling = args[:scaling]
|
311
|
+
|
312
|
+
_{
|
313
|
+
AdjustmentType adjustment
|
314
|
+
CoolDown cool
|
315
|
+
ScalingAdjustment scaling
|
316
|
+
}
|
317
|
+
end
|
318
|
+
|
319
|
+
def _emr_instance_autoscaling_rule_trigger(args)
|
320
|
+
operator =
|
321
|
+
case args[:operator]
|
322
|
+
when ">="
|
323
|
+
"GREATER_THAN_OR_EQUAL"
|
324
|
+
when ">"
|
325
|
+
"GREATER_THAN"
|
326
|
+
when "<"
|
327
|
+
"LESS_THAN"
|
328
|
+
when "<="
|
329
|
+
"LESS_THAN_OR_EQUAL"
|
330
|
+
else
|
331
|
+
"GREATER_THAN_OR_EQUAL"
|
332
|
+
end
|
333
|
+
dimensions = _pair_value(args, "dimensions")
|
334
|
+
evaluation = args[:evaluation] || 1
|
335
|
+
name = _name("definition", args)
|
336
|
+
ns = args[:ns] || "AWS/ElasticMapReduce"
|
337
|
+
period = args[:period] || 300
|
338
|
+
statistic = _valid_values(args[:statistic],
|
339
|
+
%w( sample_count average sum minimum maximum ), "average")
|
340
|
+
threshold = args[:threshold]
|
341
|
+
unit = _cloudwatch_to_unit(args[:unit])
|
342
|
+
|
343
|
+
_{
|
344
|
+
CloudWatchAlarmDefinition do
|
345
|
+
ComparisonOperator operator
|
346
|
+
Dimensions dimensions unless dimensions.empty?
|
347
|
+
EvaluationPeriods evaluation
|
348
|
+
MetricName name
|
349
|
+
Namespace ns
|
350
|
+
Period period
|
351
|
+
Statistic statistic.upcase
|
352
|
+
Threshold threshold
|
353
|
+
Unit unit
|
354
|
+
end
|
355
|
+
}
|
223
356
|
end
|
@@ -3,23 +3,35 @@
|
|
3
3
|
#
|
4
4
|
require 'kumogata/template/helper'
|
5
5
|
|
6
|
-
def
|
7
|
-
|
8
|
-
|
6
|
+
def _events_to_schedule_expression(args)
|
7
|
+
schedule = args || '5 minutes'
|
8
|
+
if schedule =~ /^(\d+) (minute|minutes|hour|hours|day|days)/
|
9
|
+
"rate(#{$1} #{$2})"
|
10
|
+
else
|
11
|
+
"cron(#{schedule})"
|
12
|
+
end
|
13
|
+
end
|
9
14
|
|
15
|
+
def _events_pattern(args)
|
16
|
+
# http://docs.aws.amazon.com/AmazonCloudWatch/latest/events/CloudWatchEventsandEventPatterns.html#CloudWatchEventsPatterns
|
17
|
+
args[:pattern] || {}
|
10
18
|
end
|
11
19
|
|
12
20
|
def _events_targets(args)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
Arn target
|
21
|
+
## FIXME
|
22
|
+
## https://docs.aws.amazon.com/AmazonCloudWatchEvents/latest/APIReference/API_PutTargets.html
|
23
|
+
(args[:targets] || []).collect do |target|
|
24
|
+
role = _ref_attr_string("role", "Arn", target, "role")
|
25
|
+
_{
|
26
|
+
Arn _ref_attr_string("arn", "Arn", target)
|
19
27
|
Id target[:id]
|
20
28
|
Input target[:input] if target.key? :input
|
21
29
|
InputPath target[:path] if target.key? :path
|
30
|
+
RoleArn role unless role.empty?
|
31
|
+
EcsParameters _{
|
32
|
+
TaskCount target[:ecs_parameters][:task_count] if target[:ecs_parameters].key? :task_count
|
33
|
+
TaskDefinitionArn _ref_string("task_definition", target[:ecs_parameters], "ecs task definition", "arn")
|
34
|
+
} if target.key? :ecs_parameters
|
22
35
|
}
|
23
36
|
end
|
24
|
-
array
|
25
37
|
end
|
@@ -54,13 +54,13 @@ end
|
|
54
54
|
|
55
55
|
class Kumogata2::Plugin::Ruby::Context
|
56
56
|
def template(&block)
|
57
|
-
key_converter = proc do |
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
57
|
+
key_converter = proc do |k|
|
58
|
+
k = k.to_s
|
59
|
+
k.gsub!('____', '-')
|
60
|
+
k.gsub!('___', '.')
|
61
|
+
k.gsub!('__', '::')
|
62
|
+
k.gsub!('_', ':')
|
63
|
+
k
|
64
64
|
end
|
65
65
|
|
66
66
|
value_converter = proc do |v|
|