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
@@ -0,0 +1,282 @@
|
|
1
|
+
#
|
2
|
+
# Helper - Kinesis
|
3
|
+
#
|
4
|
+
require 'kumogata/template/helper'
|
5
|
+
require 'kumogata/template/role'
|
6
|
+
|
7
|
+
def _kinesis_firehose_to_delivery_stream_role(args)
|
8
|
+
role = []
|
9
|
+
# TODO add more destination: redshift and elasticsearch service
|
10
|
+
KINESIS_FIREHOSE_DELIVERY_STREAM_ROLE.each do |v|
|
11
|
+
next if v[:service] == 'lambda' and !args.key? :lambda
|
12
|
+
next if v[:service] == 'kms' and !args.key? :key
|
13
|
+
|
14
|
+
_role = { service: v[:service], actions: v[:actions] }
|
15
|
+
_role[:resources] = v[:resources].collect do |vv|
|
16
|
+
if vv.is_a? String
|
17
|
+
if args.key? :bucket
|
18
|
+
vv.gsub('%BUCKET_NAME%', args[:bucket])
|
19
|
+
elsif args.key? :key
|
20
|
+
vv.gsub('%KEY%', args[:key])
|
21
|
+
end
|
22
|
+
elsif vv.is_a? Hash
|
23
|
+
vv.each_pair do |kkk, vvv|
|
24
|
+
vv[kkk] = vvv.
|
25
|
+
gsub('%STREAM_NAME%', args[:name]).
|
26
|
+
gsub('%LOG_GROUP_NAME%', args[:name]).
|
27
|
+
gsub('%LOG_STREAM_NAME%', '*')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
_role[:condition] = v[:condition].collect do |vv|
|
32
|
+
vv.each_pair do |kkk, vvv|
|
33
|
+
# FIXME s3 or ...
|
34
|
+
case vvv.first[0]
|
35
|
+
when /kms:ViaService/
|
36
|
+
vv[kkk][vvv.first[0]] = _sub_service('s3')
|
37
|
+
when /aws:s3:arn/
|
38
|
+
vv[kkk][vvv.first[0]] = _iam_arn('s3', "#{args[:bucket]}/*")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end if v.key? :condition
|
42
|
+
role << _role
|
43
|
+
end
|
44
|
+
role
|
45
|
+
end
|
46
|
+
|
47
|
+
def _kinesis_firehose_to_delivery_stream_type(value)
|
48
|
+
case value
|
49
|
+
when /direct/
|
50
|
+
'DirectPut'
|
51
|
+
when /kinesis/
|
52
|
+
'KinesisStreamAsSource'
|
53
|
+
else
|
54
|
+
'DirectPut'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def _kinesis_firehose_to_elasticsearch_destination(value)
|
59
|
+
case value
|
60
|
+
when /failed/
|
61
|
+
'FailedDocumentsOnly'
|
62
|
+
when /all/
|
63
|
+
'AllDocuments'
|
64
|
+
else
|
65
|
+
'FailedDocumentsOnly'
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def _kinesis_firehose_to_s3_destinaiton_compression(value)
|
70
|
+
case value
|
71
|
+
when /un/
|
72
|
+
'UNCOMPRESSED'
|
73
|
+
when 'gzip'
|
74
|
+
'GZIP'
|
75
|
+
when 'zip'
|
76
|
+
'ZIP'
|
77
|
+
when 'snappy'
|
78
|
+
'Snappy'
|
79
|
+
else
|
80
|
+
'UNCOMPRESSED'
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def _kinesis_firehose_delivery_stream_elasticsearch_destination(args)
|
85
|
+
return {} if args.nil?
|
86
|
+
|
87
|
+
buffering = _kinesis_firehose_delivery_stream_buffering_hints(args[:buffering_hints])
|
88
|
+
cloudwatch = _kinesis_firehose_delivery_stream_cloudwatch_logging(args[:logging])
|
89
|
+
domain = _ref_attr_string('domain', 'DomainArn', args, 'elasticsearch domain')
|
90
|
+
index_name = args[:index]
|
91
|
+
index_rotation = _valid_values(args[:index_rotation],
|
92
|
+
%w( NoRotation OneHour OneDay OneWeek OneMonth ),
|
93
|
+
'NoRotation')
|
94
|
+
processing = _kinesis_firehose_delivery_stream_processing(args[:processing])
|
95
|
+
retry_options = _kinesis_firehose_delivery_stream_elasticsearch_retry(args[:retry])
|
96
|
+
role = _ref_attr_string('role', 'Arn', args, 'role')
|
97
|
+
s3_backup = _kinesis_firehose_to_elasticsearch_destination(args[:s3_backup])
|
98
|
+
s3_dest = _kinesis_firehose_delivery_stream_s3_destnation(args[:s3_dest])
|
99
|
+
type = args[:type]
|
100
|
+
|
101
|
+
_{
|
102
|
+
BufferingHints buffering
|
103
|
+
CloudWatchLoggingOptions cloudwatch unless cloudwatch.empty?
|
104
|
+
DomainARN domain
|
105
|
+
IndexName index_name
|
106
|
+
IndexRotationPeriod index_rotation
|
107
|
+
ProcessingConfiguration processing unless processing.empty?
|
108
|
+
RetryOptions retry_options
|
109
|
+
RoleARN role
|
110
|
+
S3BackupMode s3_backup
|
111
|
+
S3Configuration s3_dest
|
112
|
+
Type type
|
113
|
+
}
|
114
|
+
end
|
115
|
+
|
116
|
+
def _kinesis_firehose_delivery_stream_buffering_hints(args)
|
117
|
+
args = { interval: 300, size: 5 } if args.nil?
|
118
|
+
|
119
|
+
_{
|
120
|
+
IntervalInSeconds args[:interval]
|
121
|
+
SizeInMBs args[:size]
|
122
|
+
}
|
123
|
+
end
|
124
|
+
|
125
|
+
def _kinesis_firehose_delivery_stream_cloudwatch_logging(args)
|
126
|
+
# FIXME change name by delivery name
|
127
|
+
args = { enabled: true, group: '/aws/kinesisfirehorse', stream: 'S3Delivery' } if args.nil?
|
128
|
+
|
129
|
+
enabled = _bool('enabled', args, true)
|
130
|
+
group = args[:group]
|
131
|
+
stream = args[:stream]
|
132
|
+
|
133
|
+
_{
|
134
|
+
Enabled enabled
|
135
|
+
LogGroupName group
|
136
|
+
LogStreamName stream
|
137
|
+
}
|
138
|
+
end
|
139
|
+
|
140
|
+
def _kinesis_firehose_delivery_stream_processing(args)
|
141
|
+
return {} if args.nil?
|
142
|
+
|
143
|
+
enabled = _bool('enabled', args, true)
|
144
|
+
processors = _kinesis_firehose_delivery_stream_processor(args[:processor])
|
145
|
+
|
146
|
+
_{
|
147
|
+
Enabled enabled
|
148
|
+
Processors processors
|
149
|
+
}
|
150
|
+
end
|
151
|
+
|
152
|
+
def _kinesis_firehose_delivery_stream_processor(args)
|
153
|
+
parameters = _kinesis_firehose_delivery_stream_processor_parameters(args[:parameters])
|
154
|
+
|
155
|
+
_{
|
156
|
+
Parameters parameters
|
157
|
+
Type 'Lambda'
|
158
|
+
}
|
159
|
+
end
|
160
|
+
|
161
|
+
def _kinesis_firehose_delivery_stream_processor_parameters(args)
|
162
|
+
args.collect do |k, v|
|
163
|
+
_{
|
164
|
+
ParameterName k
|
165
|
+
ParameterValue v
|
166
|
+
}
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def _kinesis_firehose_delivery_stream_retry(args)
|
171
|
+
duration = args[:duration] || 300
|
172
|
+
|
173
|
+
_{
|
174
|
+
DurationInSeconds duration
|
175
|
+
}
|
176
|
+
end
|
177
|
+
|
178
|
+
def _kinesis_firehose_delivery_stream_s3_destnation(args)
|
179
|
+
return {} if args.nil?
|
180
|
+
|
181
|
+
bucket = _ref_attr_string('bucket', 'Arn', args, 'bucket')
|
182
|
+
buffering = _kinesis_firehose_delivery_stream_buffering_hints(args[:buffering_hints])
|
183
|
+
cloudwatch = _kinesis_firehose_delivery_stream_cloudwatch_logging(args[:logging])
|
184
|
+
compression = _kinesis_firehose_to_s3_destinaiton_compression(args[:compression])
|
185
|
+
encryption = _kinesis_firehose_delivery_stream_encryption(args[:encryption])
|
186
|
+
prefix = args[:prefix] || ''
|
187
|
+
prefix = "#{prefix}/" if prefix !~ /^.*[-|\/]$/
|
188
|
+
role = _ref_attr_string('role', 'Arn', args, 'role')
|
189
|
+
|
190
|
+
_{
|
191
|
+
BucketARN bucket
|
192
|
+
BufferingHints buffering
|
193
|
+
CloudWatchLoggingOptions cloudwatch
|
194
|
+
CompressionFormat compression
|
195
|
+
EncryptionConfiguration encryption
|
196
|
+
Prefix prefix unless prefix.empty?
|
197
|
+
RoleARN role
|
198
|
+
}
|
199
|
+
end
|
200
|
+
|
201
|
+
def _kinesis_firehose_delivery_stream_encryption(args)
|
202
|
+
return _{ NoEncryptionConfig 'NoEncryption' } if args.nil?
|
203
|
+
|
204
|
+
kms = _kinesis_firehose_delivery_stream_kms_encryption(args[:kms])
|
205
|
+
|
206
|
+
_{
|
207
|
+
KMSEncryptionConfig kms unless kms.empty?
|
208
|
+
NoEncryptionConfig 'NoEncryption' if kms.empty?
|
209
|
+
}
|
210
|
+
end
|
211
|
+
|
212
|
+
def _kinesis_firehose_delivery_stream_kms_encryption(args)
|
213
|
+
return {} if args.nil?
|
214
|
+
|
215
|
+
kms = _ref_attr_string('kms', 'Arn', args, 'kms key')
|
216
|
+
|
217
|
+
_{
|
218
|
+
AWSKMSKeyARN kms
|
219
|
+
}
|
220
|
+
end
|
221
|
+
|
222
|
+
def _kinesis_firehose_delivery_stream_kinesis_stream_source(args)
|
223
|
+
return {} if args.nil?
|
224
|
+
|
225
|
+
kinesis = _ref_attr_string('stream', 'Arn', args, 'kinesis stream')
|
226
|
+
role = _ref_attr_string('role', 'Arn', args, 'role')
|
227
|
+
|
228
|
+
_{
|
229
|
+
KinesisStreamARN kinesis
|
230
|
+
RoleARN role
|
231
|
+
}
|
232
|
+
end
|
233
|
+
|
234
|
+
def _kinesis_firehose_delivery_stream_extended_s3_destination(args)
|
235
|
+
return {} if args.nil?
|
236
|
+
|
237
|
+
bucket = _ref_attr_string('bucket', 'Arn', args, 'bucket')
|
238
|
+
buffering = _kinesis_firehose_delivery_stream_buffering_hints(args[:buffering_hints])
|
239
|
+
cloudwatch = _kinesis_firehose_delivery_stream_cloudwatch_logging(args[:logging])
|
240
|
+
compression = _kinesis_firehose_to_s3_destinaiton_compression(args[:compression])
|
241
|
+
encryption = _kinesis_firehose_delivery_stream_encryption(args[:encryption])
|
242
|
+
prefix = args[:prefix] || ''
|
243
|
+
role = _ref_attr_string('role', 'Arn', args, 'role')
|
244
|
+
s3_backup = _kinesis_firehose_delivery_stream_s3_destnation(args[:s3_backup])
|
245
|
+
s3_backup_mode = _kinesis_firehose_to_elasticsearch_destination(args[:s3_backup_mode])
|
246
|
+
|
247
|
+
_{
|
248
|
+
BucketARN bucket
|
249
|
+
BufferingHints buffering
|
250
|
+
CloudWatchLoggingOptions cloudwatch unless cloudwatch.empty?
|
251
|
+
CompressionFormat compression
|
252
|
+
EncryptionConfiguration encryption unless encryption.empty?
|
253
|
+
Prefix prefix
|
254
|
+
ProcessingConfiguration processing unless processing.empty?
|
255
|
+
RoleARN role
|
256
|
+
S3BackupConfiguration s3_backup unless s3_backup.empty?
|
257
|
+
S3BackupMode s3_backup_mode
|
258
|
+
}
|
259
|
+
end
|
260
|
+
|
261
|
+
def _kinesis_firehose_delivery_stream_redshift_destination(args)
|
262
|
+
return {} if args.nil?
|
263
|
+
|
264
|
+
cloudwatch = _kinesis_firehose_delivery_stream_cloudwatch_logging(args[:logging])
|
265
|
+
cluster = _ref_string('cluster', args, 'redshift cluster jdbc url')
|
266
|
+
password = _ref_string('password', args, 'redshift cluster master user password')
|
267
|
+
processing = _kinesis_firehose_delivery_stream_processing(args[:processing])
|
268
|
+
role = _ref_attr_string('role', 'Arn', args, 'role')
|
269
|
+
s3 = _kinesis_firehose_delivery_stream_s3_destnation(args[:s3])
|
270
|
+
user = _ref_string('user', args, 'redshift cluster master user name')
|
271
|
+
|
272
|
+
_{
|
273
|
+
CloudWatchLoggingOptions cloudwatch unless cloudwatch.empty?
|
274
|
+
ClusterJDBCURL cluster
|
275
|
+
CopyCommand copy
|
276
|
+
Password password
|
277
|
+
ProcessingConfiguration processing unless processing.empty?
|
278
|
+
RoleARN role
|
279
|
+
S3Configuration s3
|
280
|
+
Username user
|
281
|
+
}
|
282
|
+
end
|
@@ -3,6 +3,29 @@
|
|
3
3
|
#
|
4
4
|
require 'kumogata/template/helper'
|
5
5
|
|
6
|
+
def _lambda_to_runtime(value)
|
7
|
+
case value
|
8
|
+
when 'node4'
|
9
|
+
'nodejs4.3'
|
10
|
+
when 'node6'
|
11
|
+
'nodejs6.10'
|
12
|
+
when 'node8'
|
13
|
+
'nodejs8.10'
|
14
|
+
when 'python2'
|
15
|
+
'python2.7'
|
16
|
+
when 'python3'
|
17
|
+
'python3.6'
|
18
|
+
when '.net1'
|
19
|
+
'dotnetcore1.0'
|
20
|
+
when '.net2'
|
21
|
+
'dotnetcore2.0'
|
22
|
+
when 'go'
|
23
|
+
'go1.x'
|
24
|
+
else
|
25
|
+
value
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
6
29
|
def _lambda_function_code(args)
|
7
30
|
return "" unless args.key? :code
|
8
31
|
|
@@ -23,13 +46,15 @@ def _lambda_function_code(args)
|
|
23
46
|
S3Bucket s3_bucket if is_s3
|
24
47
|
S3Key s3_key if is_s3
|
25
48
|
S3ObjectVersion s3_object_version if is_s3 and !s3_object_version.empty?
|
26
|
-
ZipFile _join(zip_file_code,
|
49
|
+
ZipFile _join(zip_file_code, "\n") unless is_s3
|
27
50
|
}
|
28
51
|
end
|
29
52
|
|
30
53
|
def _lambda_function_environment(args)
|
31
54
|
environment = args[:environment] || {}
|
32
|
-
environment.empty?
|
55
|
+
return {} if environment.empty?
|
56
|
+
|
57
|
+
_{ Variables environment }
|
33
58
|
end
|
34
59
|
|
35
60
|
def _lambda_vpc_config(args)
|
@@ -54,3 +79,19 @@ def _lambda_dead_letter(args)
|
|
54
79
|
TargetArn dead_letter
|
55
80
|
}
|
56
81
|
end
|
82
|
+
|
83
|
+
def _lambda_trace_config(args)
|
84
|
+
trace = args[:trace] || ""
|
85
|
+
return trace if trace.empty?
|
86
|
+
|
87
|
+
mode =
|
88
|
+
case trace
|
89
|
+
when "active"
|
90
|
+
"Active"
|
91
|
+
else
|
92
|
+
"PassThrough"
|
93
|
+
end
|
94
|
+
_{
|
95
|
+
Mode mode
|
96
|
+
}
|
97
|
+
end
|
@@ -4,15 +4,11 @@
|
|
4
4
|
require 'kumogata/template/helper'
|
5
5
|
|
6
6
|
def _logs_metric_filter_transformations(args)
|
7
|
-
|
8
|
-
|
9
|
-
array = []
|
10
|
-
trans.each do |tran|
|
11
|
-
array << _{
|
7
|
+
(args[:transformations] || []).collect do |tran|
|
8
|
+
_{
|
12
9
|
MetricName tran[:name]
|
13
10
|
MetricNamespace tran[:ns]
|
14
11
|
MetricValue tran[:value]
|
15
12
|
}
|
16
13
|
end
|
17
|
-
array
|
18
14
|
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
#
|
2
|
+
# Helper - Pinpoint
|
3
|
+
#
|
4
|
+
require 'kumogata/template/helper'
|
5
|
+
require 'kumogata/template/role'
|
6
|
+
|
7
|
+
def _pinpoint_to_iam_readonly(app)
|
8
|
+
[
|
9
|
+
{
|
10
|
+
service: 'mobiletargeting',
|
11
|
+
actions: [
|
12
|
+
'get *',
|
13
|
+
],
|
14
|
+
resource: [
|
15
|
+
{ app: app },
|
16
|
+
{ app: "#{app}/*" },
|
17
|
+
],
|
18
|
+
},
|
19
|
+
{
|
20
|
+
service: 'mobiletargeting',
|
21
|
+
actions: [
|
22
|
+
'get reports',
|
23
|
+
],
|
24
|
+
resource: [
|
25
|
+
{ reports: true },
|
26
|
+
],
|
27
|
+
},
|
28
|
+
]
|
29
|
+
end
|
30
|
+
|
31
|
+
def _pinpoint_to_iam_full(app)
|
32
|
+
[
|
33
|
+
{
|
34
|
+
service: 'mobiletargeting',
|
35
|
+
actions: [
|
36
|
+
'delete *',
|
37
|
+
'get *',
|
38
|
+
'update *',
|
39
|
+
],
|
40
|
+
resource: [
|
41
|
+
{ app: app },
|
42
|
+
{ app: "#{app}/*" },
|
43
|
+
],
|
44
|
+
},
|
45
|
+
{
|
46
|
+
service: 'mobiletargeting',
|
47
|
+
actions: [
|
48
|
+
'get reports',
|
49
|
+
],
|
50
|
+
resource: [
|
51
|
+
{ reports: true },
|
52
|
+
],
|
53
|
+
},
|
54
|
+
]
|
55
|
+
end
|
56
|
+
|
57
|
+
def _pinpoint_to_kinesis_stream_role(args)
|
58
|
+
role = []
|
59
|
+
PINPOINT_KINESIS_STREAM_ROLE.each do |v|
|
60
|
+
_role = { service: v[:service], actions: v[:actions] }
|
61
|
+
_role[:resources] = v[:resources].collect do |vv|
|
62
|
+
vv.each_pair do |kkk, vvv|
|
63
|
+
vv[kkk] = vvv.gsub(/%KINESIS_STREAM_NAME%/, args[:name])
|
64
|
+
end
|
65
|
+
end
|
66
|
+
role << _role
|
67
|
+
end
|
68
|
+
role
|
69
|
+
end
|
70
|
+
|
71
|
+
def _pinpoint_to_kinesis_firehose_delivery_stream_role(args)
|
72
|
+
role = []
|
73
|
+
PINPOINT_KINESIS_FIREHOSE_DELIVERY_STREAM_ROLE.each do |v|
|
74
|
+
_role = { service: v[:service], actions: v[:actions] }
|
75
|
+
_role[:resources] = v[:resources].collect do |vv|
|
76
|
+
vv.each_pair do |kkk, vvv|
|
77
|
+
vv[kkk] = vvv.gsub(/%FIREHOSE_DELIVERY_STREAM_NAME%/, args[:name])
|
78
|
+
end
|
79
|
+
end
|
80
|
+
role << _role
|
81
|
+
end
|
82
|
+
role
|
83
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#
|
2
|
+
# Helper - RDS
|
3
|
+
#
|
4
|
+
require 'kumogata/template/helper'
|
5
|
+
|
6
|
+
def _rds_to_parameter_charset(charset = 'utf8mb4')
|
7
|
+
{
|
8
|
+
"character-set-client-handshake": 1,
|
9
|
+
"character_set_client": charset,
|
10
|
+
"character_set_connection": charset,
|
11
|
+
"character_set_database": charset,
|
12
|
+
"character_set_results": charset,
|
13
|
+
"character_set_server": charset,
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
def _rds_to_event_subscription_source(value)
|
18
|
+
case value
|
19
|
+
when "instance"
|
20
|
+
"db-instance"
|
21
|
+
when "parameter", "parameter group"
|
22
|
+
"db-parameter-group"
|
23
|
+
when "security", "security group"
|
24
|
+
"db-security-group"
|
25
|
+
when "snapshot"
|
26
|
+
"db-snapshot"
|
27
|
+
when /db-/
|
28
|
+
value
|
29
|
+
else
|
30
|
+
"db-instance"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def _rds_option_group_configurations(args)
|
35
|
+
(args[:configurations] || []).collect do |v|
|
36
|
+
security_groups = v[:security_groups] || []
|
37
|
+
settings = v[:settings] || {}
|
38
|
+
port = v[:port] || ""
|
39
|
+
vpc_security_groups = v[:security_groups] || []
|
40
|
+
|
41
|
+
_{
|
42
|
+
DBSecurityGroupMemberships security_groups unless security_groups.empty?
|
43
|
+
OptionName v[:name]
|
44
|
+
OptionSettings _{
|
45
|
+
Name settings[:name]
|
46
|
+
Value settings[:value]
|
47
|
+
} unless settings.empty?
|
48
|
+
Port port unless port.empty?
|
49
|
+
VpcSecurityGroupMemberships vpc_security_groups unless vpc_security_groups.empty?
|
50
|
+
}
|
51
|
+
end
|
52
|
+
end
|
@@ -4,10 +4,7 @@
|
|
4
4
|
require 'kumogata/template/helper'
|
5
5
|
|
6
6
|
def _redshift_parameters(args)
|
7
|
-
|
8
|
-
|
9
|
-
array = []
|
10
|
-
parameters.collect do |v|
|
7
|
+
(args[:parameters] || []).collect do |v|
|
11
8
|
name = v[:name] || ""
|
12
9
|
value =
|
13
10
|
if name == "wlm_json_configuration"
|
@@ -17,10 +14,22 @@ def _redshift_parameters(args)
|
|
17
14
|
end
|
18
15
|
next if name.empty? or value.empty?
|
19
16
|
|
20
|
-
|
17
|
+
_{
|
21
18
|
ParameterName name
|
22
19
|
ParameterValue value
|
23
20
|
}
|
24
21
|
end
|
25
|
-
|
22
|
+
end
|
23
|
+
|
24
|
+
def _redshift_logging(args)
|
25
|
+
logging = args[:logging] || ""
|
26
|
+
return logging if logging.empty?
|
27
|
+
|
28
|
+
bucket = _ref_string("bucket", logging, "bucket")
|
29
|
+
key = _ref_string("key", logging, "key")
|
30
|
+
|
31
|
+
_{
|
32
|
+
BucketName bucket
|
33
|
+
S3KeyPrefix key
|
34
|
+
}
|
26
35
|
end
|