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
@@ -3,134 +3,299 @@
|
|
3
3
|
#
|
4
4
|
require 'kumogata/template/helper'
|
5
5
|
|
6
|
+
def _ecs_to_log_option(args)
|
7
|
+
option =
|
8
|
+
case args[:driver]
|
9
|
+
when "awslogs"
|
10
|
+
_ecs_to_log_option_awslogs(args)
|
11
|
+
when "fluentd"
|
12
|
+
_ecs_to_log_option_fluentd(args)
|
13
|
+
when "syslog"
|
14
|
+
_ecs_to_log_option_syslog(args)
|
15
|
+
when "json"
|
16
|
+
_ecs_to_log_option_syslog(args)
|
17
|
+
when "splunk"
|
18
|
+
_ecs_to_log_option_splunk(args)
|
19
|
+
when "gelf"
|
20
|
+
_ecs_to_log_option_gelf(args)
|
21
|
+
else
|
22
|
+
{}
|
23
|
+
end
|
24
|
+
option.merge(_ecs_to_log_option_common(args))
|
25
|
+
end
|
26
|
+
|
27
|
+
def _ecs_to_log_option_awslogs(args)
|
28
|
+
{
|
29
|
+
"awslogs-group": args[:group],
|
30
|
+
"awslogs-region": args[:region] || _region,
|
31
|
+
"awslogs-stream-prefix": args[:prefix] || "",
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
def _ecs_to_log_option_fluentd(args)
|
36
|
+
option = {
|
37
|
+
"fluentd-address": args[:address] || "localhost:24224",
|
38
|
+
"fluentd-retry-wait": args[:retry_wait] || 1,
|
39
|
+
"fluentd-max-retries": args[:max_retries] || 10,
|
40
|
+
}
|
41
|
+
option["fluentd-async-connect"] = true if args.key? :async
|
42
|
+
option["fluentd-buffer-limit"] = args[:buffer_limit] if args.key? :buffer_limit
|
43
|
+
option
|
44
|
+
end
|
45
|
+
|
46
|
+
def _ecs_to_log_option_syslog(args)
|
47
|
+
option = {
|
48
|
+
"syslog-address": args[:address],
|
49
|
+
}
|
50
|
+
option["syslog-facility"] = args[:facility] if args.key? :facility
|
51
|
+
option["syslog-tls-ca-cert"] = args[:ca_cert] if args.key? :ca_cert
|
52
|
+
option["syslog-tls-cert"] = args[:cert] if args.key? :cert
|
53
|
+
option["syslog-tls-key"] = args[:key] if args.key? :key
|
54
|
+
option["syslog-tls-skip-verify"] = true if args.key? :skip_verify
|
55
|
+
option["syslog-format"] = args[:format] if args.key? :format
|
56
|
+
option
|
57
|
+
end
|
58
|
+
|
59
|
+
def _ecs_to_log_option_json(args)
|
60
|
+
option = {
|
61
|
+
"max-size": args[:max_size] || "10m",
|
62
|
+
"max-file": args[:max_file] || 1,
|
63
|
+
}
|
64
|
+
option
|
65
|
+
end
|
66
|
+
|
67
|
+
def _ecs_to_log_option_splunk(args)
|
68
|
+
option = {
|
69
|
+
"splunk-token": args[:token],
|
70
|
+
"splunk-url": args[:url],
|
71
|
+
"splunk-verify-connection": _bool("veriy_connection", args, true),
|
72
|
+
"splunk-gzip": _bool("gzip", args, false),
|
73
|
+
}
|
74
|
+
option["splunk-source"] = args[:source] if args.key? :source
|
75
|
+
option["splunk-sourcetype"] = args[:source_type] if args.key? :source_type
|
76
|
+
option["splunk-index"] = args[:index] if args.key? :index
|
77
|
+
option["splunk-capath"] = args[:capath] if args.key? :capath
|
78
|
+
option["splunk-caname"] = args[:caname] if args.key? :caname
|
79
|
+
option["splunk-insecureskipverify"] = true if args.key? :skip_verify
|
80
|
+
option["splunk-format"] = args[:format] if args.key? :format
|
81
|
+
option["splunk-gzip-level"] = args[:gzip_level] if args.key? :gzip_label
|
82
|
+
option
|
83
|
+
end
|
84
|
+
|
85
|
+
def _ecs_to_log_option_gelf(args)
|
86
|
+
option = {
|
87
|
+
"gelf-address": args[:address],
|
88
|
+
"gelf-compression-type": args[:type] || "gzip",
|
89
|
+
}
|
90
|
+
option["gelf-compression-level"] = args[:level] if args.key? :level
|
91
|
+
option
|
92
|
+
end
|
93
|
+
|
94
|
+
def _ecs_to_log_option_common(args)
|
95
|
+
option = {}
|
96
|
+
option[:labels] = args[:labels].join(',') if args.key? :labels
|
97
|
+
option[:env] = args[:envs].join(',') if args.key? :envs
|
98
|
+
option["env-regex"] = args[:env_regex] if args.key? :env_regex
|
99
|
+
option[:tag] = args[:tag] if args.key? :tag
|
100
|
+
option
|
101
|
+
end
|
102
|
+
|
103
|
+
def _ecs_volumes(args)
|
104
|
+
(args[:volumes] || []).collect do |volume|
|
105
|
+
volume = { volume: "" } if volume.is_a? String
|
106
|
+
volume.map.collect do |name, source|
|
107
|
+
_{
|
108
|
+
Name name
|
109
|
+
Host do
|
110
|
+
SourcePath source
|
111
|
+
end unless source.empty?
|
112
|
+
}
|
113
|
+
end
|
114
|
+
end.flatten
|
115
|
+
end
|
116
|
+
|
6
117
|
def _ecs_load_balancers(args)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
118
|
+
(args[:load_balancers] || []).collect do |balancer|
|
119
|
+
target = _ref_string('target', balancer, 'target group')
|
120
|
+
|
121
|
+
_{
|
122
|
+
ContainerName _name("name", balancer)
|
123
|
+
ContainerPort balancer[:port] || 80
|
124
|
+
LoadBalancerName _name("lb_name", balancer) if target.empty?
|
125
|
+
TargetGroupArn target unless target.empty?
|
15
126
|
}
|
16
127
|
end
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
128
|
+
end
|
129
|
+
|
130
|
+
def _ecs_network(args)
|
131
|
+
vpc = args[:vpc] || []
|
132
|
+
return vpc if vpc.empty?
|
133
|
+
|
134
|
+
vpc = _ecs_vpc(vpc)
|
135
|
+
|
136
|
+
_{
|
137
|
+
AwsvpcConfiguration vpc
|
138
|
+
}
|
139
|
+
end
|
140
|
+
|
141
|
+
def _ecs_vpc(args)
|
142
|
+
assign_public = _bool('assign_public', args, false)
|
143
|
+
security_groups = _ref_array('security_groups', args, 'security group')
|
144
|
+
subnets = _ref_array('subnets', args, 'subnets')
|
145
|
+
|
146
|
+
_{
|
147
|
+
AssignPublicIp assign_public ? 'ENABLED' : 'DISABLED'
|
148
|
+
SecurityGroups security_groups unless security_groups.empty?
|
149
|
+
Subnets subnets
|
150
|
+
}
|
151
|
+
end
|
152
|
+
|
153
|
+
def _ecs_containers(args)
|
154
|
+
(args[:containers] || []).collect.with_index do |container, i|
|
155
|
+
container[:name] = "container-#{i + 1}" unless container.key? :name
|
156
|
+
|
157
|
+
command = _array(container[:command] || [])
|
158
|
+
cpu = container[:cpu] || 1
|
159
|
+
search_domains = _ref_array("search_domains", args)
|
160
|
+
servers = _ref_array("servers", args)
|
161
|
+
label = container[:label] || {}
|
162
|
+
security_options = _array(container[:security_options] || [])
|
163
|
+
entry_point = _array(container[:entry_point] || [])
|
164
|
+
environment = _pair_name_value(container, "environment")
|
165
|
+
extra_hosts = _ecs_extra_hosts(container)
|
166
|
+
host = _name("host", container)
|
167
|
+
image =
|
168
|
+
if container.key? :my_image
|
169
|
+
_join([ _account_id,
|
170
|
+
".dkr.ecr.",
|
171
|
+
_region,
|
172
|
+
".#{DOMAIN}/",
|
173
|
+
container[:my_image],
|
174
|
+
":",
|
175
|
+
container[:my_image_tag] || "latest"
|
176
|
+
], "")
|
37
177
|
else
|
38
|
-
|
178
|
+
container[:image] || "nginx:latest"
|
39
179
|
end
|
40
|
-
|
41
|
-
|
180
|
+
links = _array(container[:links] || [])
|
181
|
+
log_config = _ecs_log_configuration(container)
|
182
|
+
memory = container[:memory] || 300
|
183
|
+
memory_reservation = container[:memory_reservation] || 0
|
184
|
+
mount_points = _ecs_mount_points(container)
|
185
|
+
port_mappings = _ecs_port_mappings(container)
|
186
|
+
ulimits = _ecs_ulimits(container)
|
187
|
+
user = container[:user] || ""
|
188
|
+
volumes = _ecs_volumes_from(container)
|
189
|
+
working = container[:working] || ""
|
190
|
+
|
191
|
+
_{
|
42
192
|
Command command unless command.empty?
|
43
|
-
Cpu
|
193
|
+
Cpu cpu
|
194
|
+
DisableNetworking _bool("networking", container, false)
|
195
|
+
DnsSearchDomains search_domains unless search_domains.empty?
|
196
|
+
DnsServers servers unless servers.empty?
|
197
|
+
DockerLabels label unless label.empty?
|
198
|
+
DockerSecurityOptions security_options unless security_options.empty?
|
44
199
|
EntryPoint entry_point unless entry_point.empty?
|
45
200
|
Environment environment unless environment.empty?
|
46
|
-
Essential _bool("essential",
|
47
|
-
|
201
|
+
Essential _bool("essential", container, true)
|
202
|
+
ExtraHosts extra_hosts unless extra_hosts.empty?
|
203
|
+
Hostname host
|
204
|
+
Image image
|
48
205
|
Links links unless links.empty?
|
49
|
-
|
206
|
+
LogConfiguration log_config unless log_config.empty?
|
207
|
+
Memory memory
|
208
|
+
MemoryReservation memory_reservation if 0 < memory_reservation
|
50
209
|
MountPoints mount_points unless mount_points.empty?
|
51
|
-
Name _ref_string("name",
|
210
|
+
Name _ref_string("name", container)
|
52
211
|
PortMappings port_mappings unless port_mappings.empty?
|
53
|
-
|
212
|
+
Privileged _bool("privileged", container, false)
|
213
|
+
ReadonlyRootFilesystem _bool("read_only", container, false)
|
214
|
+
Ulimits ulimits unless ulimits.empty?
|
215
|
+
User user unless user.empty?
|
216
|
+
VolumesFrom volumes unless volumes.empty?
|
217
|
+
WorkingDirectory working unless working.empty?
|
218
|
+
}
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
def _ecs_extra_hosts(args)
|
223
|
+
(args[:extra_hosts] || []).collect do |host|
|
224
|
+
_{
|
225
|
+
HostName host[:name]
|
226
|
+
IpAddress host[:ip]
|
54
227
|
}
|
55
228
|
end
|
56
|
-
|
229
|
+
end
|
230
|
+
|
231
|
+
def _ecs_log_configuration(args)
|
232
|
+
configuration = args[:log] || []
|
233
|
+
return configuration if configuration.empty?
|
234
|
+
|
235
|
+
driver = _valid_values(configuration[:driver],
|
236
|
+
%w( json-file syslog journald gelf fluentd awslogs splunk), "awslogs")
|
237
|
+
option = _ecs_to_log_option(configuration)
|
238
|
+
_{
|
239
|
+
LogDriver driver
|
240
|
+
Options option unless option.empty?
|
241
|
+
}
|
57
242
|
end
|
58
243
|
|
59
244
|
def _ecs_mount_points(args)
|
60
|
-
mount_points
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
ContainerPath point[:container_path]
|
65
|
-
SourceVolume point[:source_volume]
|
245
|
+
(args[:mount_points] || args[:mounts] || []).collect do |point|
|
246
|
+
_{
|
247
|
+
ContainerPath point[:path]
|
248
|
+
SourceVolume point[:source]
|
66
249
|
ReadOnly _bool("read_only", point, false)
|
67
250
|
}
|
68
251
|
end
|
69
|
-
array
|
70
252
|
end
|
71
253
|
|
72
254
|
def _ecs_port_mappings(args)
|
73
|
-
port_mappings
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
ContainerPort _ref_string("container_port", point, "container port")
|
80
|
-
HostPort host_port unless host_port.empty?
|
255
|
+
(args[:port_mappings] || args[:ports] || []).collect do |port|
|
256
|
+
host = _ref_string("host", port, 'host port')
|
257
|
+
_{
|
258
|
+
ContainerPort _ref_string("port", port, 'container port')
|
259
|
+
HostPort host unless host.empty?
|
260
|
+
Protocol _valid_values(port[:protocol], %w( tcp udp ), 'tcp')
|
81
261
|
}
|
82
262
|
end
|
83
|
-
array
|
84
263
|
end
|
85
264
|
|
86
|
-
def
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
SourceContainer _ref_string("source", volume)
|
93
|
-
ReadOnly _bool("read_only", volume, false)
|
265
|
+
def _ecs_ulimits(args)
|
266
|
+
(args[:ulimits] || []).collect do |ulimit|
|
267
|
+
_{
|
268
|
+
HardLimit ulimit[:hard]
|
269
|
+
Name _name("name", ulimit)
|
270
|
+
SoftLimit ulimit[:hard] || ulimit[:soft]
|
94
271
|
}
|
95
272
|
end
|
96
|
-
array
|
97
273
|
end
|
98
274
|
|
99
|
-
def
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
host = _ecs_volumes_host(volume[:host])
|
105
|
-
array << _{
|
106
|
-
Name volume[:name]
|
107
|
-
Host host unless host.empty?
|
275
|
+
def _ecs_volumes_from(args)
|
276
|
+
(args[:volumes_from] || args[:volumes] || []).collect do |volume|
|
277
|
+
_{
|
278
|
+
SourceContainer _ref_string("source", volume)
|
279
|
+
ReadOnly _bool("read_only", volume, false)
|
108
280
|
}
|
109
281
|
end
|
110
|
-
array
|
111
|
-
end
|
112
|
-
|
113
|
-
def _ecs_volumes_host(args)
|
114
|
-
return {} if args.nil? or !args.key? :source_path
|
115
|
-
|
116
|
-
_{
|
117
|
-
SourcePath args[:source_path]
|
118
|
-
}
|
119
282
|
end
|
120
283
|
|
121
284
|
def _ecs_deployment(args)
|
122
|
-
return "" unless args.key? :
|
285
|
+
return "" unless args.key? :deployment
|
286
|
+
|
287
|
+
deployment = args[:deployment]
|
123
288
|
|
124
289
|
_{
|
125
|
-
MaximumPercent
|
126
|
-
MinimumHealthyPercent
|
290
|
+
MaximumPercent deployment[:max] || 200
|
291
|
+
MinimumHealthyPercent deployment[:min] || 50
|
127
292
|
}
|
128
293
|
end
|
129
294
|
|
130
|
-
def _ecs_placement_definition(args)
|
131
|
-
|
295
|
+
def _ecs_placement_definition(args, key = 'placement')
|
296
|
+
placement = args[key.to_sym] || []
|
297
|
+
return placement if placement.empty?
|
132
298
|
|
133
|
-
placement = args[:placement]
|
134
299
|
type = _valid_values(placement[:type], %w( distinctInstance memberOf), "distinctInstance")
|
135
300
|
expression = placement[:expression] || ""
|
136
301
|
|
@@ -140,15 +305,15 @@ def _ecs_placement_definition(args)
|
|
140
305
|
}
|
141
306
|
end
|
142
307
|
|
143
|
-
def
|
144
|
-
|
308
|
+
def _ecs_placement_strategies(args, key = 'placement')
|
309
|
+
placement = args[key.to_sym] || []
|
310
|
+
return placement if placement.empty?
|
145
311
|
|
146
|
-
placement = args[:placement]
|
147
312
|
type = _valid_values(placement[:type], %w( random spread binpack ), "random")
|
148
313
|
field =
|
149
314
|
case type
|
150
315
|
when "binpack"
|
151
|
-
_valid_values(
|
316
|
+
_valid_values(placement[:field], %w( cpu memory ), "cpu")
|
152
317
|
when "spread"
|
153
318
|
args[:field] || ""
|
154
319
|
else
|
@@ -241,7 +241,7 @@ def _elasticbeanstalk_to_option_vpc(args)
|
|
241
241
|
array << {
|
242
242
|
name: "aws:ec2:vpc",
|
243
243
|
option: "VpcId",
|
244
|
-
value:
|
244
|
+
value: _ref_string("vpc", args, "vpc"),
|
245
245
|
}
|
246
246
|
array << {
|
247
247
|
name: "aws:ec2:vpc",
|
@@ -282,15 +282,13 @@ def _elasticbeanstalk_to_option_application(args)
|
|
282
282
|
end
|
283
283
|
|
284
284
|
def _elasticbeanstalk_to_option_application_environment(args)
|
285
|
-
|
286
|
-
|
287
|
-
array << {
|
285
|
+
args.collect do |k, v|
|
286
|
+
{
|
288
287
|
name: "aws:elasticbeanstalk:application:environment",
|
289
288
|
option: k,
|
290
289
|
value: v,
|
291
290
|
}
|
292
291
|
end
|
293
|
-
array
|
294
292
|
end
|
295
293
|
|
296
294
|
def _elasticbeanstalk_to_option_logs(args)
|
@@ -927,15 +925,13 @@ def _elasticbeanstalk_to_option_rds_db_instance(args)
|
|
927
925
|
end
|
928
926
|
|
929
927
|
def _elasticbeanstalk_options(options)
|
930
|
-
|
931
|
-
|
932
|
-
array << _{
|
928
|
+
options.collect do |option|
|
929
|
+
_{
|
933
930
|
Namespace option[:name]
|
934
931
|
OptionName option[:option]
|
935
932
|
Value option[:value]
|
936
933
|
}
|
937
934
|
end
|
938
|
-
array
|
939
935
|
end
|
940
936
|
|
941
937
|
def _elasticbeanstalk_configuration(configuration)
|
@@ -959,6 +955,7 @@ def _elasticbeanstalk_tier(tier)
|
|
959
955
|
end
|
960
956
|
|
961
957
|
name = _valid_values(tier[:name], %w( WebServer Worker ), "WebServer")
|
958
|
+
|
962
959
|
_{
|
963
960
|
Name name
|
964
961
|
Type (name == "WebServer") ? "Standard" : "SQS/HTTP"
|
@@ -16,16 +16,12 @@ def _elb_access_logging_policy(args)
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def _elb_app_cookie_stickiness_policy(args)
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
apps.each do |app|
|
23
|
-
array << _{
|
19
|
+
(args[:app_cookie] || []).collect do |app|
|
20
|
+
_{
|
24
21
|
CookieName app[:cookie]
|
25
22
|
PolicyName app[:policy]
|
26
|
-
|
23
|
+
}
|
27
24
|
end
|
28
|
-
array
|
29
25
|
end
|
30
26
|
|
31
27
|
def _elb_connection_draining_policy(args)
|
@@ -65,24 +61,19 @@ def _elb_health_check(args)
|
|
65
61
|
end
|
66
62
|
|
67
63
|
def _elb_cookie_stickiness_policy(args)
|
68
|
-
|
69
|
-
|
70
|
-
array = []
|
71
|
-
cookies.each do |cookie|
|
72
|
-
array << _{
|
64
|
+
(args[:cookie_stickiness] || []).collect do |cookie|
|
65
|
+
_{
|
73
66
|
CookieExpirationPeriod cookie[:expiration]
|
74
67
|
PolicyName cookie[:policy]
|
75
68
|
}
|
76
69
|
end
|
77
|
-
array
|
78
70
|
end
|
79
71
|
|
80
72
|
def _elb_listeners(args)
|
81
73
|
listeners = args[:listeners] || []
|
82
74
|
listeners = [ { protocol: "http" } ] if listeners.empty?
|
83
75
|
|
84
|
-
|
85
|
-
listeners.each do |listener|
|
76
|
+
listeners.collect do |listener|
|
86
77
|
proto = listener[:protocol] || "http"
|
87
78
|
protocol = _valid_values(proto, %w( http https tcp ssl ), "http")
|
88
79
|
lb_port =
|
@@ -108,7 +99,7 @@ def _elb_listeners(args)
|
|
108
99
|
end
|
109
100
|
ssl = _ref_string("ssl", listener)
|
110
101
|
|
111
|
-
|
102
|
+
_{
|
112
103
|
InstancePort instance_port
|
113
104
|
InstanceProtocol instance_protocol.upcase
|
114
105
|
LoadBalancerPort lb_port
|
@@ -117,22 +108,17 @@ def _elb_listeners(args)
|
|
117
108
|
SSLCertificateId ssl if protocol == "https"
|
118
109
|
}
|
119
110
|
end
|
120
|
-
array
|
121
111
|
end
|
122
112
|
|
123
113
|
def _elb_policy_types(args)
|
124
|
-
|
125
|
-
return [] if policies.empty?
|
126
|
-
|
127
|
-
array = []
|
128
|
-
policies.each do |policy|
|
114
|
+
(args[:policy] || []).collect do |policy|
|
129
115
|
attributes = []
|
130
116
|
instance_ports = []
|
131
117
|
lb_ports = []
|
132
118
|
policy_name = policy[:name]
|
133
119
|
policy_type = policy[:type]
|
134
120
|
|
135
|
-
|
121
|
+
_{
|
136
122
|
Attributes attributes unless attributes.empty?
|
137
123
|
InstancePorts instance_ports unless instance_ports.empty?
|
138
124
|
LoadBalancerPorts lb_ports unless lb_ports.empty?
|
@@ -140,5 +126,4 @@ def _elb_policy_types(args)
|
|
140
126
|
PolicyType policy_type
|
141
127
|
}
|
142
128
|
end
|
143
|
-
array
|
144
129
|
end
|