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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7c8d9ab5748134f2d4b2f803d7a699707c951515945790d0874e2dbae7d290f0
|
4
|
+
data.tar.gz: 401347892cbc9146e7e7f8c35eb6f0a57026695eeee659c4f038610a4c51d957
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7acf0b5c6353373debd184868eb057e6a07ac307307ef4de9e3c4a0115460514ef90a049232f9721be81e2e6d35510d820dd20e2a20dfb84da401854ad119d8a
|
7
|
+
data.tar.gz: 4cf9d0c4105dde1a10aa1dd903c42a0f2b1d8c1caed6e539db15490221f34ab26dcb35a68e2fa482d5ed88d7d45e431b960b1b1dd1c116b1da0a23e419c39694
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/kumogata-template.gemspec
CHANGED
@@ -19,8 +19,8 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
21
|
spec.add_dependency 'aws-sdk', '~> 2.3'
|
22
|
-
spec.add_dependency 'kumogata2-plugin-ruby', '
|
23
|
-
spec.add_development_dependency 'bundler'
|
24
|
-
spec.add_development_dependency 'rake'
|
25
|
-
spec.add_development_dependency 'minitest'
|
22
|
+
spec.add_dependency 'kumogata2-plugin-ruby', '~> 0.1'
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
24
|
+
spec.add_development_dependency 'rake', '~> 12.3'
|
25
|
+
spec.add_development_dependency 'minitest', '~> 5.11'
|
26
26
|
end
|
@@ -24,6 +24,12 @@ def _alb_to_lb_attribute_idle_timeout(value)
|
|
24
24
|
}
|
25
25
|
end
|
26
26
|
|
27
|
+
def _alb_to_lb_http2(value = true)
|
28
|
+
{
|
29
|
+
"routing.http2.enabled": value
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
27
33
|
def _alb_to_target_group_attribute_delay_timeout(value)
|
28
34
|
# wait before changing the state of a deregistering target from draining to unused 0-3600 seconds.
|
29
35
|
{
|
@@ -40,6 +46,18 @@ def _alb_to_target_group_stickiness(value)
|
|
40
46
|
}
|
41
47
|
end
|
42
48
|
|
49
|
+
def _alb_to_min_health_check(args)
|
50
|
+
{
|
51
|
+
protocol: _valid_values(args[:protocol], %w( http https ), 'http').upcase,
|
52
|
+
path: args[:path] || '/',
|
53
|
+
port: args[:port] || 80,
|
54
|
+
healthy: args[:healthy] || 2,
|
55
|
+
unhealthly: args[:unhealthly] || 2,
|
56
|
+
timeout: args[:timeout] || 2,
|
57
|
+
interval: args[:interval] || 5,
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
43
61
|
def _alb_certificates(args)
|
44
62
|
certificate = _ref_string("certificate", args)
|
45
63
|
|
@@ -51,46 +69,39 @@ def _alb_certificates(args)
|
|
51
69
|
end
|
52
70
|
|
53
71
|
def _alb_actions(args)
|
54
|
-
|
55
|
-
|
56
|
-
array = []
|
57
|
-
defaults.each do |default|
|
72
|
+
(args[:actions] || []).collect do |default|
|
58
73
|
target = _ref_string("target", default, "target group")
|
59
|
-
|
74
|
+
_{
|
60
75
|
TargetGroupArn target
|
61
76
|
Type "forward"
|
62
77
|
}
|
63
78
|
end
|
64
|
-
array
|
65
79
|
end
|
66
80
|
|
67
81
|
def _alb_conditions(args)
|
68
|
-
|
69
|
-
|
70
|
-
array = []
|
71
|
-
conditions.each do |condition|
|
82
|
+
(args[:conditions] || []).collect do |condition|
|
72
83
|
condition = [ condition ] unless condition.is_a? Array
|
73
|
-
|
84
|
+
_{
|
74
85
|
Field "path-pattern"
|
75
86
|
Values condition
|
76
87
|
}
|
77
88
|
end
|
78
|
-
array
|
79
89
|
end
|
80
90
|
|
81
91
|
def _alb_attributes(args)
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
92
|
+
(args[:attributes] || []).collect do |attribute|
|
93
|
+
type = attribute[:type] || ''
|
94
|
+
case type
|
95
|
+
when 'log'
|
96
|
+
attribute = _alb_to_lb_attribute_access_log(attribute)
|
97
|
+
when 'timeout'
|
98
|
+
attribute = _alb_to_lb_attribute_idle_timeout(attribute[:timeout])
|
99
|
+
when 'delay-timeout'
|
100
|
+
attribute = _alb_to_target_group_attribute_delay_timeout(attribute[:timeout])
|
101
|
+
end
|
102
|
+
|
103
|
+
_pair_value({ attribute: attribute }, 'attribute')
|
104
|
+
end.flatten
|
94
105
|
end
|
95
106
|
|
96
107
|
def _alb_matcher(args)
|
@@ -103,8 +114,15 @@ def _alb_matcher(args)
|
|
103
114
|
end
|
104
115
|
|
105
116
|
def _alb_health_check(args)
|
117
|
+
type = args[:type] || ''
|
118
|
+
case type
|
119
|
+
when 'min'
|
120
|
+
return _alb_to_min_health_check(args)
|
121
|
+
end
|
122
|
+
|
106
123
|
protocol = _valid_values(args[:protocol] || "", %w( http https ), "http")
|
107
|
-
|
124
|
+
|
125
|
+
# return to native hash
|
108
126
|
{
|
109
127
|
interval: args[:interval] || 30,
|
110
128
|
path: args[:path] || "/",
|
@@ -117,24 +135,20 @@ def _alb_health_check(args)
|
|
117
135
|
end
|
118
136
|
|
119
137
|
def _alb_targets(args)
|
120
|
-
targets = args[:targets] || []
|
121
|
-
ref_targets = args[:ref_targets] || []
|
122
|
-
|
123
|
-
array = []
|
124
|
-
targets.each do |target|
|
138
|
+
targets = (args[:targets] || []).collect do |target|
|
125
139
|
id = _ref_string("instance", target, "instance")
|
126
|
-
|
140
|
+
_{
|
127
141
|
Id id
|
128
142
|
Port target[:port] if target.key? :port
|
129
143
|
}
|
130
144
|
end
|
131
145
|
|
132
|
-
ref_targets.
|
133
|
-
|
146
|
+
targets += (args[:ref_targets] || []).collect do |target|
|
147
|
+
_{
|
134
148
|
Id _ref_string("instance", { ref_instance: target }, "instance")
|
135
149
|
Port 80
|
136
150
|
}
|
137
151
|
end
|
138
152
|
|
139
|
-
|
153
|
+
targets
|
140
154
|
end
|
@@ -0,0 +1,262 @@
|
|
1
|
+
#
|
2
|
+
# Helper - Api Gateway
|
3
|
+
#
|
4
|
+
require 'kumogata/template/helper'
|
5
|
+
|
6
|
+
def _api_gateway_to_parameter(args)
|
7
|
+
type = _valid_values(args[:type], %w( integration method ), "method")
|
8
|
+
location = _valid_values(args[:location], %w( querystring path header ), "path")
|
9
|
+
operation = args[:operation] || "request"
|
10
|
+
"#{type}.#{operation}.#{location}.#{args[:name]}"
|
11
|
+
end
|
12
|
+
|
13
|
+
def _api_gateway_to_parameter_headers(kind)
|
14
|
+
headers =
|
15
|
+
case kind
|
16
|
+
when "aws"
|
17
|
+
[
|
18
|
+
{ name: "X-AWS-Request-Id", value: "context.requestId" },
|
19
|
+
{ name: "X-AWS-API-Id", value: "context.apiId" },
|
20
|
+
]
|
21
|
+
when "cognito"
|
22
|
+
[
|
23
|
+
{ name: "X-AWS-Cognito-Identity-Id", value: "context.identity.cognitoIdentityId" },
|
24
|
+
{ name: "X-AWS-Cognito-Identity-Pool-Id", value: "context.identity.cognitoIdentityPoolId" },
|
25
|
+
{ name: "X-AWS-Cognito-Authentication-Type", value: "context.identity.cognitoAuthenticationType" },
|
26
|
+
{ name: "X-AWS-Cognito-Authentication-Provider", value: "context.identity.cognitoAuthenticationProvider" },
|
27
|
+
]
|
28
|
+
else
|
29
|
+
[]
|
30
|
+
end
|
31
|
+
return headers if headers.empty?
|
32
|
+
|
33
|
+
headers.collect{|v| v.merge!({ location: "header" }) }
|
34
|
+
end
|
35
|
+
|
36
|
+
def _api_gateway_to_parameter_response_headers(args = {})
|
37
|
+
headers = {}
|
38
|
+
key = _api_gateway_to_parameter({ operation: "response",
|
39
|
+
location: "header",
|
40
|
+
name: "Access-Control-Allow-Methods" })
|
41
|
+
headers[key] = "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'"
|
42
|
+
|
43
|
+
key = _api_gateway_to_parameter({ operation: "response",
|
44
|
+
location: "header",
|
45
|
+
name: "Access-Control-Allow-Headers" })
|
46
|
+
allow_headers = %w( Content-Type Authorization X-Amz-Date X-Api-Key X-Amz-Security-Token)
|
47
|
+
allow_headers += args[:allow_headers] if args.key? :allow_headers
|
48
|
+
headers[key] = sprintf("'%s'", allow_headers.join(','))
|
49
|
+
|
50
|
+
key = _api_gateway_to_parameter({ operation: "response",
|
51
|
+
location: "header",
|
52
|
+
name: "Access-Control-Allow-Origin" })
|
53
|
+
headers[key] = "'*'"
|
54
|
+
|
55
|
+
headers
|
56
|
+
end
|
57
|
+
|
58
|
+
def _api_gateway_stage_keys(args)
|
59
|
+
(args[:stage_keys] || []).collect do |key|
|
60
|
+
rest = _ref_string("rest", key, "reset api")
|
61
|
+
stage = _ref_string("stage", key)
|
62
|
+
_{
|
63
|
+
RestApiId rest
|
64
|
+
StageName stage
|
65
|
+
}
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def _api_gateway_integration(args)
|
70
|
+
args_proxy = _bool("proxy", args, false)
|
71
|
+
args_parameters = args[:parameters] || []
|
72
|
+
|
73
|
+
integration = args[:integration] || {}
|
74
|
+
return integration if integration.empty?
|
75
|
+
|
76
|
+
cache_keys = integration[:cache_keys] || []
|
77
|
+
cache_keys << _api_gateway_to_parameter({ type: "method", location: "path", name: "proxy" }) if args_proxy
|
78
|
+
cache_ns = integration[:cache_ns] || ""
|
79
|
+
http =
|
80
|
+
if args_proxy
|
81
|
+
"any"
|
82
|
+
else
|
83
|
+
_valid_values(integration[:http], %w( delete get head options patch post put any ), "any")
|
84
|
+
end
|
85
|
+
responses =
|
86
|
+
if integration.key? :responses
|
87
|
+
integration[:responses].collect{|v| _api_gateway_integration_response(v) }
|
88
|
+
else
|
89
|
+
[]
|
90
|
+
end
|
91
|
+
responses << _api_gateway_integration_response({ template: { "application/json": "null" } }) if args_proxy
|
92
|
+
pass =
|
93
|
+
if args_proxy
|
94
|
+
"when_no_match"
|
95
|
+
else
|
96
|
+
_valid_values(integration[:pass], %w( when_no_match when_no_templates never ), "")
|
97
|
+
end
|
98
|
+
role = _ref_attr_string("role", "Arn", integration)
|
99
|
+
parameters = {}
|
100
|
+
args_parameters.collect do |v|
|
101
|
+
k = _api_gateway_to_parameter({ type: "integration", location: v[:location], name: v[:name] })
|
102
|
+
parameters[k] = _api_gateway_to_parameter(v)
|
103
|
+
end
|
104
|
+
(integration[:parameters] || []).collect do |v|
|
105
|
+
k = _api_gateway_to_parameter({ type: "integration", location: v[:location], name: v[:name] })
|
106
|
+
parameters[k] = v[:value]
|
107
|
+
end
|
108
|
+
# RequestTemplates
|
109
|
+
# - Key: The content type value
|
110
|
+
# - Value: the template http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html
|
111
|
+
templates = integration[:templates] || {}
|
112
|
+
type =
|
113
|
+
if args_proxy
|
114
|
+
"http_proxy"
|
115
|
+
else
|
116
|
+
_valid_values(integration[:type], %w( mock http http_proxy aws aws_proxy ), "http")
|
117
|
+
end
|
118
|
+
|
119
|
+
uri =
|
120
|
+
case type
|
121
|
+
when /http/
|
122
|
+
_ref_string("uri", integration)
|
123
|
+
when /aws/
|
124
|
+
_iam_arn("api-gateway", integration)
|
125
|
+
else
|
126
|
+
""
|
127
|
+
end
|
128
|
+
uri = _join([ uri, "{proxy}" ], "/") if args_proxy
|
129
|
+
|
130
|
+
_{
|
131
|
+
CacheKeyParameters cache_keys unless cache_keys.empty?
|
132
|
+
CacheNamespace cache_ns unless cache_ns.empty?
|
133
|
+
Credentials role unless role.empty?
|
134
|
+
IntegrationHttpMethod http.upcase if type != "mock"
|
135
|
+
IntegrationResponses responses unless responses.empty?
|
136
|
+
PassthroughBehavior pass.upcase unless pass.empty?
|
137
|
+
RequestParameters parameters unless parameters.empty?
|
138
|
+
RequestTemplates templates unless templates.empty?
|
139
|
+
Type type.upcase
|
140
|
+
Uri uri unless uri.empty?
|
141
|
+
}
|
142
|
+
end
|
143
|
+
|
144
|
+
def _api_gateway_integration_response(args)
|
145
|
+
parameter = args[:parameter] || {}
|
146
|
+
template = args[:template] || {}
|
147
|
+
selection = args[:selection] || ""
|
148
|
+
status = args[:status] || 200
|
149
|
+
|
150
|
+
_{
|
151
|
+
ResponseParameters parameter unless parameter.empty?
|
152
|
+
ResponseTemplates template unless template.empty?
|
153
|
+
SelectionPattern selection unless selection.empty?
|
154
|
+
StatusCode status
|
155
|
+
}
|
156
|
+
end
|
157
|
+
|
158
|
+
def _api_gateway_responses(args)
|
159
|
+
(args[:responses] || []).collect do |response|
|
160
|
+
models = response[:models] || []
|
161
|
+
parameters = response[:parameters] || []
|
162
|
+
status = response[:status] || 200
|
163
|
+
|
164
|
+
_{
|
165
|
+
ResponseModels models unless models.empty?
|
166
|
+
ResponseParameters parameters unless parameters.empty?
|
167
|
+
StatusCode status
|
168
|
+
}
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
def _api_gateway_stage_description(args)
|
173
|
+
description = args[:stage_description] || {}
|
174
|
+
return description if description.empty?
|
175
|
+
|
176
|
+
cache = description[:cache] || {}
|
177
|
+
certificate = _ref_string_default("certificate", description, "certificate")
|
178
|
+
data_trace = _bool("data_trace", description, false)
|
179
|
+
description_desc = description[:description] || ""
|
180
|
+
logging = _valid_values(description[:logging], %w( off error info ), "off")
|
181
|
+
method = _api_gateway_method_settings(description)
|
182
|
+
metrics = _bool("metrics", description, false)
|
183
|
+
stage = _name("stage", description)
|
184
|
+
throtting = description[:throtting] || {}
|
185
|
+
variables = description[:variables] || {}
|
186
|
+
|
187
|
+
_{
|
188
|
+
CacheClusterEnabled true if cache.key? :cluster
|
189
|
+
CacheClusterSize cache[:size] unless cache.empty?
|
190
|
+
CacheDataEncrypted true if cache.key? :encrypted
|
191
|
+
CacheTtlInSeconds cache[:ttl] unless cache.empty?
|
192
|
+
CachingEnabled cache.empty? ? false : true
|
193
|
+
ClientCertificateId certificate unless certificate.empty?
|
194
|
+
DataTraceEnabled data_trace
|
195
|
+
Description description unless description_desc.empty?
|
196
|
+
LoggingLevel logging.upcase
|
197
|
+
MethodSettings method unless method.empty?
|
198
|
+
MetricsEnabled metrics
|
199
|
+
StageName stage
|
200
|
+
ThrottlingBurstLimit throtting[:burst] unless throtting.empty?
|
201
|
+
ThrottlingRateLimit throtting[:rate] unless throtting.empty?
|
202
|
+
Variables variables unless variables.empty?
|
203
|
+
}
|
204
|
+
end
|
205
|
+
|
206
|
+
def _api_gateway_method_settings(args)
|
207
|
+
(args[:settings] || []).collect do |setting|
|
208
|
+
cache = setting[:cache] || {}
|
209
|
+
data_trace = _bool("data_trace", setting, false)
|
210
|
+
http = setting[:http] || "*"
|
211
|
+
logging = _valid_values(setting[:logging], %w( off error info ), "info")
|
212
|
+
metrics = _bool("metrics", setting, false)
|
213
|
+
resource = setting[:resource] || "/*"
|
214
|
+
throtting = setting[:throtting] || {}
|
215
|
+
|
216
|
+
_{
|
217
|
+
CacheDataEncrypted cache[:encrypted] unless cache.empty?
|
218
|
+
CacheTtlInSeconds cache[:ttl] unless cache.empty?
|
219
|
+
CachingEnabled cache.empty? ? false : true
|
220
|
+
DataTraceEnabled data_trace
|
221
|
+
HttpMethod http
|
222
|
+
LoggingLevel logging.upcase
|
223
|
+
MetricsEnabled metrics
|
224
|
+
ResourcePath resource
|
225
|
+
ThrottlingBurstLimit throtting[:burst] unless throtting.empty?
|
226
|
+
ThrottlingRateLimit throtting[:rate] unless throtting.empty?
|
227
|
+
}
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
def _api_gateway_stages(args)
|
232
|
+
(args[:stages] || []).collect do |stage|
|
233
|
+
_{
|
234
|
+
ApiId _ref_string("rest", stage, "rest api")
|
235
|
+
Stage _ref_string("stage", stage, "stage")
|
236
|
+
}
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
def _api_gateway_quota(args)
|
241
|
+
quota = args[:quota] || {}
|
242
|
+
return quota if quota.empty?
|
243
|
+
|
244
|
+
offset = quota[:offset] || ""
|
245
|
+
period = _valid_values(quota[:period], %w( day week month ), "month")
|
246
|
+
|
247
|
+
_{
|
248
|
+
Limit quota[:limit]
|
249
|
+
Offset offset unless offset.empty?
|
250
|
+
Period period.upcase
|
251
|
+
}
|
252
|
+
end
|
253
|
+
|
254
|
+
def _api_gateway_throttle(args)
|
255
|
+
throttle = args[:throttle] || {}
|
256
|
+
return throttle if throttle.empty?
|
257
|
+
|
258
|
+
_{
|
259
|
+
BurstLimit throttle[:bust]
|
260
|
+
RateLimit throttle[:rate]
|
261
|
+
}
|
262
|
+
end
|
@@ -107,53 +107,26 @@ def _autoscaling_step(args)
|
|
107
107
|
}
|
108
108
|
end
|
109
109
|
|
110
|
-
def _autoscaling_tags(args)
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
Value _tag_name(args)
|
115
|
-
PropagateAtLaunch _bool("tag_name_launch", args, true)
|
116
|
-
},
|
117
|
-
_{
|
118
|
-
Key "Service"
|
119
|
-
Value { Ref _resource_name("service") }
|
120
|
-
PropagateAtLaunch _bool("tag_service_launch", args, true)
|
121
|
-
},
|
122
|
-
_{
|
123
|
-
Key "Version"
|
124
|
-
Value { Ref _resource_name("version") }
|
125
|
-
PropagateAtLaunch _bool("tag_version_launch", args, true)
|
126
|
-
},
|
127
|
-
]
|
128
|
-
if args.key? :tags_append
|
129
|
-
args[:tags_append].each do|key, value|
|
130
|
-
tag = _tag({ key: key, value: value })
|
131
|
-
tag["PropagateAtLaunch"] = _bool("tag_#{key}_launch", args, true)
|
132
|
-
tags << tag
|
133
|
-
end
|
110
|
+
def _autoscaling_tags(args, tag_name = "tag_name")
|
111
|
+
_tags(args, tag_name).collect do |tag|
|
112
|
+
tag["PropagateAtLaunch"] = _bool("#{tag["Key"].downcase}_launch", args, true).to_s
|
113
|
+
tag
|
134
114
|
end
|
135
|
-
tags
|
136
115
|
end
|
137
116
|
|
138
117
|
def _autoscaling_terminations(args)
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
when "close"
|
153
|
-
"ClosestToNextInstanceHour"
|
154
|
-
else
|
155
|
-
"Default"
|
156
|
-
end
|
118
|
+
(args[:terminations] || []).collect do |termination|
|
119
|
+
case termination.downcase
|
120
|
+
when "old instance"
|
121
|
+
"OldestInstance"
|
122
|
+
when "new instance"
|
123
|
+
"NewestInstance"
|
124
|
+
when "old launch"
|
125
|
+
"OldestLaunchConfiguration"
|
126
|
+
when "close"
|
127
|
+
"ClosestToNextInstanceHour"
|
128
|
+
else
|
129
|
+
"Default"
|
130
|
+
end
|
157
131
|
end
|
158
|
-
array
|
159
132
|
end
|
@@ -4,15 +4,18 @@
|
|
4
4
|
require 'kumogata/template/helper'
|
5
5
|
|
6
6
|
def _certificate_validations(args)
|
7
|
-
|
8
|
-
|
7
|
+
validations = args[:validation] || []
|
8
|
+
return [ _{
|
9
|
+
DomainName _ref_string("domain", args, "domain")
|
10
|
+
ValidationDomain _ref_string("domain", args, "domain")
|
11
|
+
} ] if validations.empty?
|
9
12
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
validations.collect do |validation|
|
14
|
+
domain = _ref_string("domain", validation, "domain")
|
15
|
+
validation = _ref_string("validation", validation, "domain")
|
16
|
+
_{
|
17
|
+
DomainName domain
|
18
|
+
ValidationDomain validation || domain
|
15
19
|
}
|
16
20
|
end
|
17
|
-
result
|
18
21
|
end
|