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
@@ -5,9 +5,9 @@ require 'kumogata/template/helper'
|
|
5
5
|
|
6
6
|
def _cloudfront_distribution_config(args)
|
7
7
|
aliases = args[:aliases] || []
|
8
|
-
|
9
|
-
if args.key? :
|
10
|
-
|
8
|
+
behaivors =
|
9
|
+
if args.key? :behaivors
|
10
|
+
args[:behaivors].collect{|v| _cloudfront_cache_behavior(v) }
|
11
11
|
else
|
12
12
|
""
|
13
13
|
end
|
@@ -20,10 +20,10 @@ def _cloudfront_distribution_config(args)
|
|
20
20
|
end
|
21
21
|
default_cache =
|
22
22
|
if args.key? :default_cache
|
23
|
-
_cloudfront_cache_behavior(args[:default_cache], true)
|
23
|
+
_cloudfront_cache_behavior(args[:default_cache], args[:origins], true)
|
24
24
|
else
|
25
25
|
""
|
26
|
-
|
26
|
+
end
|
27
27
|
default_root = args[:default_root] || "index.html"
|
28
28
|
enabled = _bool("enabled", args, true)
|
29
29
|
http = _valid_values(args[:http], %w( http1.1 http2 ), "http2")
|
@@ -46,7 +46,7 @@ def _cloudfront_distribution_config(args)
|
|
46
46
|
|
47
47
|
_{
|
48
48
|
Aliases aliases unless aliases.empty?
|
49
|
-
CacheBehaviors
|
49
|
+
CacheBehaviors behaivors unless behaivors.empty?
|
50
50
|
Comment comment unless comment.empty?
|
51
51
|
CustomErrorResponses custom_errors unless custom_errors.empty?
|
52
52
|
DefaultCacheBehavior default_cache unless default_cache.empty?
|
@@ -62,7 +62,7 @@ def _cloudfront_distribution_config(args)
|
|
62
62
|
}
|
63
63
|
end
|
64
64
|
|
65
|
-
def _cloudfront_cache_behavior(args, default = false)
|
65
|
+
def _cloudfront_cache_behavior(args, origins = [], default = false)
|
66
66
|
allowed_methods =
|
67
67
|
if args.key? :allowed_methods
|
68
68
|
case args[:allowed_methods]
|
@@ -93,23 +93,20 @@ def _cloudfront_cache_behavior(args, default = false)
|
|
93
93
|
else
|
94
94
|
""
|
95
95
|
end
|
96
|
-
default_ttl = args[:default_ttl] ||
|
97
|
-
forwarded_values =
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
""
|
102
|
-
end
|
103
|
-
max_ttl = args[:max_ttl] || ""
|
104
|
-
min_ttl = args[:min_ttl] || ""
|
96
|
+
default_ttl = args[:default_ttl] || 86400
|
97
|
+
forwarded_values = _cloudfront_forwarded_values(args[:forwarded] || {})
|
98
|
+
lambda = (args[:lambda_functions] || []).collect{|v| _cloudfront_lambda(v) }
|
99
|
+
max_ttl = args[:max_ttl] || 31536000
|
100
|
+
min_ttl = args[:min_ttl] || 0
|
105
101
|
path = args[:path]
|
106
102
|
smooth =
|
107
103
|
if args.key? :smooth
|
108
|
-
_bool(args
|
104
|
+
_bool("smooth", args, false)
|
109
105
|
else
|
110
106
|
""
|
111
107
|
end
|
112
|
-
target = args[:target]
|
108
|
+
target = args[:target] || ""
|
109
|
+
target = origins[0][:id] if target.empty? and (origins[0] and origins[0].is_a? Hash and origins[0][:id])
|
113
110
|
trusted = args[:trusted] || ""
|
114
111
|
viewer = _valid_values(args[:viewer], %w( allow-all redirect-to-https https-only ), "redirect-to-https")
|
115
112
|
|
@@ -119,8 +116,9 @@ def _cloudfront_cache_behavior(args, default = false)
|
|
119
116
|
Compress compress unless compress.empty?
|
120
117
|
DefaultTTL default_ttl unless default_ttl.nil?
|
121
118
|
ForwardedValues forwarded_values
|
122
|
-
|
123
|
-
|
119
|
+
LambdaFunctionAssociations lambda unless lambda.empty?
|
120
|
+
MaxTTL max_ttl unless max_ttl.nil?
|
121
|
+
MinTTL min_ttl unless min_ttl.nil?
|
124
122
|
PathPattern path if default == false
|
125
123
|
SmoothStreaming smooth unless smooth.empty?
|
126
124
|
TargetOriginId target
|
@@ -158,8 +156,22 @@ def _cloudfront_forwarded_values(args)
|
|
158
156
|
}
|
159
157
|
end
|
160
158
|
|
159
|
+
def _cloudfront_lambda(args)
|
160
|
+
return '' if args.empty?
|
161
|
+
|
162
|
+
event = _valid_values(args[:envet],
|
163
|
+
%w( viewer-request origin-request origin-response viewer-response ),
|
164
|
+
'viewer-request')
|
165
|
+
function = _ref_string('version', args, 'lambda version')
|
166
|
+
|
167
|
+
_{
|
168
|
+
EventType event
|
169
|
+
LambdaFunctionARN function
|
170
|
+
}
|
171
|
+
end
|
172
|
+
|
161
173
|
def _cloudfront_custom_error(args)
|
162
|
-
error_min_ttl = args[:error_min_ttl] ||
|
174
|
+
error_min_ttl = args[:error_min_ttl] || 300
|
163
175
|
error_code = args[:error_code] || 404
|
164
176
|
response_code =
|
165
177
|
if args.key? :response_code
|
@@ -175,21 +187,15 @@ def _cloudfront_custom_error(args)
|
|
175
187
|
end
|
176
188
|
|
177
189
|
_{
|
178
|
-
ErrorCachingMinTTL error_min_ttl
|
190
|
+
ErrorCachingMinTTL error_min_ttl
|
179
191
|
ErrorCode error_code
|
180
|
-
ResponseCode response_code
|
181
|
-
ResponsePagePath response_page
|
192
|
+
ResponseCode response_code
|
193
|
+
ResponsePagePath response_page
|
182
194
|
}
|
183
195
|
end
|
184
196
|
|
185
197
|
def _cloudfront_custom_errors(args)
|
186
|
-
|
187
|
-
|
188
|
-
array = []
|
189
|
-
errors.each do |error|
|
190
|
-
array << _cloudfront_custom_error(error)
|
191
|
-
end
|
192
|
-
array
|
198
|
+
(args || []).collect{|error| _cloudfront_custom_error(error) }
|
193
199
|
end
|
194
200
|
|
195
201
|
def _cloudfront_logging(args)
|
@@ -214,7 +220,7 @@ def _cloudfront_origin(args)
|
|
214
220
|
if args.key? :custom
|
215
221
|
_cloudfront_custom_origin(args[:custom])
|
216
222
|
else
|
217
|
-
|
223
|
+
{}
|
218
224
|
end
|
219
225
|
domain = _ref_attr_string("domain", "DomainName", args, "bucket")
|
220
226
|
id = args[:id]
|
@@ -224,50 +230,49 @@ def _cloudfront_origin(args)
|
|
224
230
|
else
|
225
231
|
""
|
226
232
|
end
|
227
|
-
path = args[:
|
228
|
-
s3 =
|
229
|
-
if args.key? :s3
|
230
|
-
_cloudfront_s3_origin(args[:s3])
|
231
|
-
else
|
232
|
-
nil
|
233
|
-
end
|
233
|
+
path = args[:path] || ""
|
234
|
+
s3 = _cloudfront_s3_origin(args)
|
234
235
|
|
235
236
|
_{
|
236
|
-
CustomOriginConfig custom if s3.
|
237
|
-
DomainName domain
|
237
|
+
CustomOriginConfig custom if s3.empty? and !custom.empty?
|
238
|
+
DomainName "#{domain}.s3.#{DOMAIN}"
|
238
239
|
Id id
|
239
240
|
OriginCustomHeaders headers unless headers.empty?
|
240
241
|
OriginPath path unless path.empty?
|
241
|
-
S3OriginConfig s3 if custom.
|
242
|
+
S3OriginConfig s3 if custom.empty?
|
242
243
|
}
|
243
244
|
end
|
244
245
|
|
245
246
|
def _cloudfront_origins(args)
|
246
|
-
|
247
|
-
|
248
|
-
array = []
|
249
|
-
origins.each do |origin|
|
250
|
-
array << _cloudfront_origin(origin)
|
251
|
-
end
|
252
|
-
array
|
247
|
+
(args || []).collect{|origin| _cloudfront_origin(origin) }
|
253
248
|
end
|
254
249
|
|
255
250
|
def _cloudfront_custom_origin(args)
|
256
|
-
http_port = args[:
|
257
|
-
https_port = args[:
|
258
|
-
|
259
|
-
|
251
|
+
http_port = args[:http] || 80
|
252
|
+
https_port = args[:https] || 443
|
253
|
+
keepalive = args[:keepalive] || 5
|
254
|
+
protocol = _valid_values(args[:protocol],
|
255
|
+
%w( https-only http-only match-viewer ), "match-viewer")
|
256
|
+
read_timeout = args[:read_timeout] || 30
|
257
|
+
ssl_protocols = (_array(args[:ssl_protocols]) || [ '' ] ).collect{|v|
|
258
|
+
_valid_values(v, %w( SSLv3 TLSv1 TLSv1.1 TLSv1.2 ), "TLSv1.1")
|
259
|
+
}
|
260
260
|
|
261
261
|
_{
|
262
|
-
HTTPPort http_port
|
263
|
-
HTTPSPort https_port
|
264
|
-
|
265
|
-
|
262
|
+
HTTPPort http_port
|
263
|
+
HTTPSPort https_port
|
264
|
+
OriginKeepaliveTimeout keepalive
|
265
|
+
OriginProtocolPolicy protocol
|
266
|
+
OriginReadTimeout read_timeout
|
267
|
+
OriginSSLProtocols ssl_protocols
|
266
268
|
}
|
267
269
|
end
|
268
270
|
|
269
271
|
def _cloudfront_s3_origin(args)
|
270
|
-
|
272
|
+
s3 = _ref_string("s3", args, 'origin access identity')
|
273
|
+
return {} if s3.empty?
|
274
|
+
|
275
|
+
origin = _join([ 'origin-access-identity', 'cloudfront', s3 ], '/')
|
271
276
|
|
272
277
|
_{
|
273
278
|
OriginAccessIdentity origin unless origin.empty?
|
@@ -293,12 +298,14 @@ def _cloudfront_viewer_cert(args)
|
|
293
298
|
""
|
294
299
|
end
|
295
300
|
iam = args[:iam] || ""
|
296
|
-
min_protocol = args[:min_protocol]
|
301
|
+
min_protocol = _valid_values(args[:min_protocol],
|
302
|
+
%w( SSLv3 | TLSv1 | TLSv1_2016 | TLSv1.1_2016 | TLSv1.2_2018 ),
|
303
|
+
"TLSv1.1_2016")
|
297
304
|
ssl = _valid_values(args[:ssl], %w( vip sni-only ), "sni-only")
|
298
305
|
|
299
306
|
_{
|
300
307
|
AcmCertificateArn acm unless acm.empty?
|
301
|
-
CloudFrontDefaultCertificate
|
308
|
+
CloudFrontDefaultCertificate default unless default.empty?
|
302
309
|
IamCertificateId iam unless iam.empty?
|
303
310
|
MinimumProtocolVersion min_protocol unless min_protocol.empty?
|
304
311
|
SslSupportMethod ssl unless acm.empty? and iam.empty?
|
@@ -153,7 +153,7 @@ def _cloudwatch_to_namespace(value)
|
|
153
153
|
"WAF"
|
154
154
|
when "work spaces", "ws"
|
155
155
|
"WorkSpaces"
|
156
|
-
|
156
|
+
end
|
157
157
|
"AWS/#{value}"
|
158
158
|
end
|
159
159
|
|
@@ -249,20 +249,15 @@ def _cloudwatch_dimension(args)
|
|
249
249
|
end
|
250
250
|
|
251
251
|
def _cloudwatch_actions(args)
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
array = []
|
256
|
-
actions.each do |v|
|
257
|
-
if v =~ /ec2 (\w)/
|
258
|
-
array << _cloudwatch_to_ec2_action($1)
|
252
|
+
(args[:actions] || args[:ref_actions] || []).collect do |action|
|
253
|
+
if action =~ /ec2 (\w)/
|
254
|
+
_cloudwatch_to_ec2_action($1)
|
259
255
|
else
|
260
|
-
if
|
261
|
-
|
256
|
+
if args.key? :ref_actions
|
257
|
+
_ref_string("action", { ref_action: action })
|
262
258
|
else
|
263
|
-
|
259
|
+
action
|
264
260
|
end
|
265
261
|
end
|
266
262
|
end
|
267
|
-
array
|
268
263
|
end
|
@@ -61,16 +61,12 @@ def _codebuild_environement(args)
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def _codebuild_environement_hash(args)
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
array << _{
|
69
|
-
Name k
|
70
|
-
Value v
|
64
|
+
(args || {}).collect do |name, value|
|
65
|
+
_{
|
66
|
+
Name name
|
67
|
+
Value value
|
71
68
|
}
|
72
69
|
end
|
73
|
-
array
|
74
70
|
end
|
75
71
|
|
76
72
|
def _codebuild_source(args)
|
@@ -4,11 +4,8 @@
|
|
4
4
|
require 'kumogata/template/helper'
|
5
5
|
|
6
6
|
def _codecommit_triggers(args)
|
7
|
-
|
8
|
-
|
9
|
-
array = []
|
10
|
-
triggers.each do |trigger|
|
11
|
-
array << _{
|
7
|
+
(args[:trigger] || []).each do |trigger|
|
8
|
+
_{
|
12
9
|
Branches trigger[:branchs] || []
|
13
10
|
CustomData trigger[:custom] || ""
|
14
11
|
DestinationArn trigger[:dest] || ""
|
@@ -16,5 +13,4 @@ def _codecommit_triggers(args)
|
|
16
13
|
Name trigger[:name] || ""
|
17
14
|
}
|
18
15
|
end
|
19
|
-
array
|
20
16
|
end
|
@@ -13,6 +13,21 @@ def _codedeploy_minimum(args)
|
|
13
13
|
}
|
14
14
|
end
|
15
15
|
|
16
|
+
def _codedeploy_alarm(args)
|
17
|
+
alarm = args[:alarm] || ""
|
18
|
+
return alarm if alarm.empty?
|
19
|
+
|
20
|
+
alarms = alarm[:alarms].collect{|v| _{ Name v } }
|
21
|
+
enabled = _bool("enabled", args, true)
|
22
|
+
ignore = _bool("ignore", args, false)
|
23
|
+
|
24
|
+
_{
|
25
|
+
Alarms alarms
|
26
|
+
Enabled enabled
|
27
|
+
IgnorePollAlarmFailure ignore
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
16
31
|
def _codedeploy_deployment(args)
|
17
32
|
description = args[:description] || ""
|
18
33
|
ignore = _bool("ignore", args, true)
|
@@ -0,0 +1,203 @@
|
|
1
|
+
#
|
2
|
+
# Helper - Cognito
|
3
|
+
#
|
4
|
+
require 'kumogata/template/helper'
|
5
|
+
|
6
|
+
def _cognito_providers(args)
|
7
|
+
providers = args[:providers] || {}
|
8
|
+
return providers if providers.empty?
|
9
|
+
|
10
|
+
# providers: [ ref_client: 'admin', ref_name: 'admin' ]
|
11
|
+
providers.collect do |provider|
|
12
|
+
_{
|
13
|
+
ClientId _ref_string("client", provider, "user pool client")
|
14
|
+
ProviderName _ref_attr_string("pool", "ProviderName", provider, "user pool")
|
15
|
+
ServerSideTokenCheck _bool("check", provider, false)
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def _cognito_streams(args)
|
21
|
+
stream = args[:stream] || {}
|
22
|
+
return stream if stream.empty?
|
23
|
+
|
24
|
+
_{
|
25
|
+
RoleArn stream[:role]
|
26
|
+
StreamingStatus _bool("status", stream, false) ? "ENABLED" : "DISABLED"
|
27
|
+
StreamName stream[:name]
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def _cognito_push_sync(args)
|
32
|
+
push_sync = args[:push_sync] || {}
|
33
|
+
return push_sync if push_sync.empty?
|
34
|
+
|
35
|
+
_{
|
36
|
+
ApplicationArns push_sync[:applications]
|
37
|
+
RoleArn push_sync[:role]
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
def _cognito_roles_mappings(args)
|
42
|
+
# T.B.D
|
43
|
+
end
|
44
|
+
|
45
|
+
def _cognito_roles(args)
|
46
|
+
roles = args[:roles] || {}
|
47
|
+
return roles if roles.empty?
|
48
|
+
|
49
|
+
unauth = _ref_attr_string("unauth", "Arn", roles, "role")
|
50
|
+
auth = _ref_attr_string("auth", "Arn", roles, "role")
|
51
|
+
|
52
|
+
_{
|
53
|
+
unauthenticated unauth unless unauth.empty?
|
54
|
+
authenticated auth
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
def _cognito_admin_config(args)
|
59
|
+
admin_config = args[:admin_config] || {}
|
60
|
+
return admin_config if admin_config.empty?
|
61
|
+
|
62
|
+
invite = _cognito_invite(admin_config)
|
63
|
+
unused = admin_config[:unused] || 7
|
64
|
+
|
65
|
+
_{
|
66
|
+
AllowAdminCreateUserOnly _bool("allow", admin_config, false)
|
67
|
+
InviteMessageTemplate invite unless invite.empty?
|
68
|
+
UnusedAccountValidityDays unused
|
69
|
+
}
|
70
|
+
end
|
71
|
+
|
72
|
+
def _cognito_invite(args)
|
73
|
+
invite = args[:invite] || {}
|
74
|
+
return invite if invite.empty?
|
75
|
+
|
76
|
+
email_message = _ref_string_default("email_message", invite,
|
77
|
+
"Your username is {username} and temporary password is {####}.")
|
78
|
+
email_subject = _ref_string_default("email_subject", invite,
|
79
|
+
"Your temporary password")
|
80
|
+
sms = _ref_string_default("sms", invite,
|
81
|
+
"Your username is {username} and temporary password is {####}.")
|
82
|
+
|
83
|
+
_{
|
84
|
+
EmailMessage email_message
|
85
|
+
EmailSubject email_subject
|
86
|
+
SMSMessage sms
|
87
|
+
}
|
88
|
+
end
|
89
|
+
|
90
|
+
def _cognito_device_config(args)
|
91
|
+
device_config = args[:device_config] || {}
|
92
|
+
return device_config if device_config.empty?
|
93
|
+
|
94
|
+
_{
|
95
|
+
ChallengeRequiredOnNewDevice _bool("challenge", device_config, false)
|
96
|
+
DeviceOnlyRememberedOnUserPrompt _bool("device_only", device_config, false)
|
97
|
+
}
|
98
|
+
end
|
99
|
+
|
100
|
+
def _cognito_email_config(args)
|
101
|
+
email_config = args[:email_config] || {}
|
102
|
+
return email_config if email_config.empty?
|
103
|
+
|
104
|
+
reply_to = _ref_string_default("reply_to", email_config)
|
105
|
+
source = _ref_string_default("source", email_config)
|
106
|
+
|
107
|
+
_{
|
108
|
+
ReplyToEmailAddress reply_to unless reply_to.empty?
|
109
|
+
SourceArn source
|
110
|
+
}
|
111
|
+
end
|
112
|
+
|
113
|
+
def _cognito_email_verify(args)
|
114
|
+
email_verify = args[:email_verify] || {}
|
115
|
+
return {} if email_verify.empty?
|
116
|
+
|
117
|
+
{
|
118
|
+
message: email_verify[:message] || "Your verification code is {####}.",
|
119
|
+
subject: email_verify[:subject] || "Your verification code",
|
120
|
+
}
|
121
|
+
end
|
122
|
+
|
123
|
+
def _cognito_lambda_config(args)
|
124
|
+
lambda_config = args[:lambda_config] || {}
|
125
|
+
return {} if lambda_config.empty?
|
126
|
+
|
127
|
+
create_auth = _ref_string_default("create_auth", lambda_config)
|
128
|
+
custom_message = _ref_string_default("custom_message", lambda_config)
|
129
|
+
defined_auth = _ref_string_default("defined_auth", lambda_config)
|
130
|
+
post_auth = _ref_string_default("post_auth", lambda_config)
|
131
|
+
post_confirm = _ref_string_default("post_confirm", lambda_config)
|
132
|
+
pre_auth = _ref_string_default("pre_auth", lambda_config)
|
133
|
+
pre_sign = _ref_string_default("pre_sign", lambda_config)
|
134
|
+
verify_auth = _ref_string_default("verify_auth", lambda_config)
|
135
|
+
|
136
|
+
_{
|
137
|
+
CreateAuthChallenge create_auth unless create_auth.empty?
|
138
|
+
CustomMessage custom_message unless custom_message.empty?
|
139
|
+
DefineAuthChallenge defined_auth unless defined_auth.empty?
|
140
|
+
PostAuthentication post_auth unless post_auth.empty?
|
141
|
+
PostConfirmation post_confirm unless post_confirm.empty?
|
142
|
+
PreAuthentication pre_auth unless pre_auth.empty?
|
143
|
+
PreSignUp pre_sign unless pre_sign.empty?
|
144
|
+
VerifyAuthChallengeResponse verify_auth unless verify_auth.empty?
|
145
|
+
}
|
146
|
+
end
|
147
|
+
|
148
|
+
def _cognito_policies(args)
|
149
|
+
policies = args[:policies] || {}
|
150
|
+
password = _cognito_password_policy(policies)
|
151
|
+
|
152
|
+
_{
|
153
|
+
PasswordPolicy password
|
154
|
+
}
|
155
|
+
end
|
156
|
+
|
157
|
+
def _cognito_password_policy(args)
|
158
|
+
policy = args[:password] || {}
|
159
|
+
|
160
|
+
_{
|
161
|
+
MinimumLength policy[:min] || 6
|
162
|
+
RequireLowercase _bool("lowercase", policy, false)
|
163
|
+
RequireNumbers _bool("numbers", policy, false)
|
164
|
+
RequireSymbols _bool("symbols", policy, false)
|
165
|
+
RequireUppercase _bool("uppercase", policy, false)
|
166
|
+
}
|
167
|
+
end
|
168
|
+
|
169
|
+
def _cognito_schemas(args)
|
170
|
+
(args[:schemas] || []).collect do |schema|
|
171
|
+
data_type = schema[:data_type] || "String" # String, Number, DateTime, or Boolean
|
172
|
+
number = schema[:number] || {}
|
173
|
+
string = schema[:string] || {}
|
174
|
+
|
175
|
+
_{
|
176
|
+
AttributeDataType data_type unless data_type.empty?
|
177
|
+
DeveloperOnlyAttribute _bool("developer", schema, false)
|
178
|
+
Mutable _bool("mutable", schema, true)
|
179
|
+
Name schema[:name]
|
180
|
+
NumberAttributeConstraints do
|
181
|
+
MaxValue number[:max]
|
182
|
+
MinValue number[:min]
|
183
|
+
end unless number.empty?
|
184
|
+
StringAttributeConstraints do
|
185
|
+
MaxLength string[:max]
|
186
|
+
MinLength string[:min]
|
187
|
+
end unless string.empty?
|
188
|
+
Required _bool("required", schema, true)
|
189
|
+
}
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
def _cognito_sms_config(args)
|
194
|
+
sms_config = args[:sms_config] || {}
|
195
|
+
return sms_config if sms_config.empty?
|
196
|
+
|
197
|
+
external = _ref_string_default("external", sms_config)
|
198
|
+
|
199
|
+
_{
|
200
|
+
ExternalId external unless external.empty?
|
201
|
+
SnsCallerArn _ref_string("sns_caller", args)
|
202
|
+
}
|
203
|
+
end
|