kumogata-template 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +54 -0
- data/.travis.yml +8 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +75 -0
- data/README.md +204 -0
- data/Rakefile +23 -0
- data/bin/kumogata-template +9 -0
- data/kumogata-template.gemspec +26 -0
- data/lib/kumogata/template.rb +17 -0
- data/lib/kumogata/template/autoscaling.rb +77 -0
- data/lib/kumogata/template/cloudwatch.rb +28 -0
- data/lib/kumogata/template/codedeploy.rb +85 -0
- data/lib/kumogata/template/const.rb +175 -0
- data/lib/kumogata/template/datapipeline.rb +90 -0
- data/lib/kumogata/template/dynamodb.rb +111 -0
- data/lib/kumogata/template/ec2.rb +165 -0
- data/lib/kumogata/template/ecs.rb +119 -0
- data/lib/kumogata/template/elasticbeanstalk.rb +33 -0
- data/lib/kumogata/template/elb.rb +132 -0
- data/lib/kumogata/template/emr.rb +166 -0
- data/lib/kumogata/template/events.rb +25 -0
- data/lib/kumogata/template/ext/argument_parser.rb +8 -0
- data/lib/kumogata/template/ext/kumogata.rb +103 -0
- data/lib/kumogata/template/helper.rb +211 -0
- data/lib/kumogata/template/iam.rb +96 -0
- data/lib/kumogata/template/lambda.rb +34 -0
- data/lib/kumogata/template/s3.rb +223 -0
- data/lib/kumogata/template/sns.rb +25 -0
- data/lib/kumogata/template/version.rb +1 -0
- data/template/_template.rb +25 -0
- data/template/autoscaling-group.rb +47 -0
- data/template/autoscaling-launch-configuration.rb +54 -0
- data/template/autoscaling-lifecycle-hook.rb +27 -0
- data/template/autoscaling-scaling-policy.rb +33 -0
- data/template/autoscaling-scheduled-action.rb +37 -0
- data/template/cloudtrail.rb +39 -0
- data/template/cloudwatch-alarm.rb +45 -0
- data/template/codedeploy-application.rb +15 -0
- data/template/codedeploy-deployment-config.rb +23 -0
- data/template/codedeploy-deployment-group.rb +35 -0
- data/template/datapipeline-pipeline.rb +28 -0
- data/template/dynamodb-table.rb +33 -0
- data/template/ec2-eip-association.rb +23 -0
- data/template/ec2-eip.rb +17 -0
- data/template/ec2-instance.rb +65 -0
- data/template/ec2-internet-gateway.rb +15 -0
- data/template/ec2-nat-gateway.rb +17 -0
- data/template/ec2-network-acl-entry.rb +30 -0
- data/template/ec2-network-acl.rb +17 -0
- data/template/ec2-route-table.rb +17 -0
- data/template/ec2-route.rb +27 -0
- data/template/ec2-security-group.rb +24 -0
- data/template/ec2-subnet-network-acl-association.rb +17 -0
- data/template/ec2-subnet-route-table-association.rb +17 -0
- data/template/ec2-subnet.rb +23 -0
- data/template/ec2-volume-attachment.rb +19 -0
- data/template/ec2-volume.rb +31 -0
- data/template/ec2-vpc-endpoint.rb +23 -0
- data/template/ec2-vpc-gateway-attachment.rb +19 -0
- data/template/ec2-vpc.rb +24 -0
- data/template/ecs-cluster.rb +11 -0
- data/template/ecs-service.rb +24 -0
- data/template/ecs-task-definition.rb +18 -0
- data/template/elasticache-cache-cluster.rb +63 -0
- data/template/elasticache-parameter-group.rb +20 -0
- data/template/elasticache-replication-group.rb +58 -0
- data/template/elasticache-subnet-group.rb +17 -0
- data/template/elasticbeanstalk-application-version.rb +24 -0
- data/template/elasticbeanstalk-application.rb +17 -0
- data/template/elasticbeanstalk-configuration-template.rb +31 -0
- data/template/elasticbeanstalk-environment.rb +44 -0
- data/template/elb-loadbalancer.rb +46 -0
- data/template/emr-cluster.rb +39 -0
- data/template/emr-instance-group-config.rb +33 -0
- data/template/emr-step.rb +22 -0
- data/template/events-rule.rb +28 -0
- data/template/iam-access-key.rb +19 -0
- data/template/iam-group.rb +20 -0
- data/template/iam-instance-profile.rb +17 -0
- data/template/iam-managed-policy.rb +28 -0
- data/template/iam-policy.rb +26 -0
- data/template/iam-role.rb +21 -0
- data/template/iam-user-to-group-addition.rb +17 -0
- data/template/iam-user.rb +24 -0
- data/template/lambda-alias.rb +21 -0
- data/template/lambda-event-source-mapping.rb +24 -0
- data/template/lambda-function.rb +34 -0
- data/template/lambda-permission.rb +26 -0
- data/template/lambda-version.rb +19 -0
- data/template/mappings-ec2.rb +85 -0
- data/template/output-access-key.rb +6 -0
- data/template/output-arn.rb +6 -0
- data/template/output-autoscaling.rb +6 -0
- data/template/output-az.rb +6 -0
- data/template/output-dynamodb.rb +6 -0
- data/template/output-ec2.rb +8 -0
- data/template/output-elasticache.rb +30 -0
- data/template/output-elb.rb +12 -0
- data/template/output-emr.rb +6 -0
- data/template/output-rds.rb +10 -0
- data/template/output-redshift.rb +10 -0
- data/template/output-s3.rb +8 -0
- data/template/output-security-group.rb +5 -0
- data/template/output-sqs.rb +5 -0
- data/template/output-topic.rb +6 -0
- data/template/output-vpc.rb +10 -0
- data/template/output.rb +29 -0
- data/template/parameter-ec2.rb +22 -0
- data/template/parameter-elasticache.rb +9 -0
- data/template/parameter-rds.rb +9 -0
- data/template/parameter-redshift.rb +9 -0
- data/template/parameter.rb +20 -0
- data/template/rds-db-cluster-parameter-group.rb +22 -0
- data/template/rds-db-cluster.rb +47 -0
- data/template/rds-db-instance.rb +82 -0
- data/template/rds-db-parameter-group.rb +21 -0
- data/template/rds-db-subnet-group.rb +19 -0
- data/template/rds-event-subscription.rb +42 -0
- data/template/rds-option-group.rb +23 -0
- data/template/redshift-cluster-parameter-group.rb +19 -0
- data/template/redshift-cluster-subnet-group.rb +17 -0
- data/template/redshift-cluster.rb +60 -0
- data/template/s3-bucket-policy.rb +20 -0
- data/template/s3-bucket.rb +42 -0
- data/template/sns-topic.rb +20 -0
- data/template/sqs-queue.rb +27 -0
- data/test/_template.rb +26 -0
- data/test/abstract_unit.rb +101 -0
- data/test/autoscaling_test.rb +109 -0
- data/test/codedeploy_test.rb +117 -0
- data/test/datapipeline_test.rb +142 -0
- data/test/dynamodb_test.rb +184 -0
- data/test/ec2_test.rb +286 -0
- data/test/ecs_test.rb +135 -0
- data/test/elasticbeanstalk_test.rb +56 -0
- data/test/elb_test.rb +147 -0
- data/test/emr_test.rb +193 -0
- data/test/events_test.rb +22 -0
- data/test/helper_test.rb +547 -0
- data/test/iam_test.rb +93 -0
- data/test/lambda_test.rb +41 -0
- data/test/s3_test.rb +195 -0
- data/test/sns_test.rb +27 -0
- data/test/template/autoscaling-group_test.rb +177 -0
- data/test/template/autoscaling-launch-configuration_test.rb +117 -0
- data/test/template/autoscaling-lifecycle-hook_test.rb +33 -0
- data/test/template/autoscaling-scaling-policy_test.rb +26 -0
- data/test/template/autoscaling-scheduled-action_test.rb +26 -0
- data/test/template/cloudtrail_test.rb +55 -0
- data/test/template/cloudwatch-alarm_test.rb +38 -0
- data/test/template/codedeploy-application_test.rb +21 -0
- data/test/template/codedeploy-deployment-config_test.rb +26 -0
- data/test/template/codedeploy-deployment-group_test.rb +48 -0
- data/test/template/datapipeline-pipeline_test.rb +358 -0
- data/test/template/dynamodb-table_test.rb +94 -0
- data/test/template/ec2-eip-association_test.rb +22 -0
- data/test/template/ec2-eip_test.rb +21 -0
- data/test/template/ec2-instance_test.rb +95 -0
- data/test/template/ec2-internet-gateway_test.rb +48 -0
- data/test/template/ec2-nat-gateway_test.rb +22 -0
- data/test/template/ec2-network-acl-entry_test.rb +61 -0
- data/test/template/ec2-network-acl_test.rb +51 -0
- data/test/template/ec2-route-table_test.rb +49 -0
- data/test/template/ec2-route_test.rb +21 -0
- data/test/template/ec2-security-group_test.rb +50 -0
- data/test/template/ec2-subnet-netwokr-acl-association_test.rb +26 -0
- data/test/template/ec2-subnet-route-table-association_test.rb +22 -0
- data/test/template/ec2-subnet_test.rb +51 -0
- data/test/template/ec2-volume-attachment_test.rb +24 -0
- data/test/template/ec2-volume_test.rb +52 -0
- data/test/template/ec2-vpc-gateway-attachment_test.rb +23 -0
- data/test/template/ec2-vpc_test.rb +102 -0
- data/test/template/ecs-cluster_test.rb +18 -0
- data/test/template/ecs-service_test.rb +29 -0
- data/test/template/ecs-task-definition_test.rb +143 -0
- data/test/template/elasticache-cache-cluster_test.rb +77 -0
- data/test/template/elasticache-parameter-group_test.rb +25 -0
- data/test/template/elasticache-replication-group_test.rb +45 -0
- data/test/template/elasticache-subnet-group_test.rb +26 -0
- data/test/template/elasticbeanstalk-application-version_test.rb +27 -0
- data/test/template/elasticbeanstalk-application_test.rb +21 -0
- data/test/template/elasticbeanstalk-configuration-template_test.rb +23 -0
- data/test/template/elasticbeanstalk-environment_test.rb +56 -0
- data/test/template/elasticbeanstalk-template_test.rb +33 -0
- data/test/template/elb-loadbalancer_test.rb +94 -0
- data/test/template/emr-cluster_test.rb +147 -0
- data/test/template/emr-instance-group-config_test.rb +65 -0
- data/test/template/emr-step_test.rb +82 -0
- data/test/template/events-rule_test.rb +34 -0
- data/test/template/iam-access-key_test.rb +22 -0
- data/test/template/iam-group_test.rb +21 -0
- data/test/template/iam-instance-profile_test.rb +24 -0
- data/test/template/iam-managed-policy_test.rb +35 -0
- data/test/template/iam-policy_test.rb +52 -0
- data/test/template/iam-role_test.rb +37 -0
- data/test/template/iam-user-to-group-addition_test.rb +24 -0
- data/test/template/iam-user_test.rb +21 -0
- data/test/template/lambda-alias_test.rb +46 -0
- data/test/template/lambda-event-source-mapping_test.rb +36 -0
- data/test/template/lambda-function_test.rb +34 -0
- data/test/template/lambda-permission_test.rb +32 -0
- data/test/template/lambda-version_test.rb +27 -0
- data/test/template/mappings-ec2_test.rb +92 -0
- data/test/template/output-access-key_test.rb +30 -0
- data/test/template/output-arn_test.rb +30 -0
- data/test/template/output-autoscaling_test.rb +27 -0
- data/test/template/output-az_test.rb +31 -0
- data/test/template/output-dynamodb_test.rb +21 -0
- data/test/template/output-ec2_test.rb +82 -0
- data/test/template/output-elasticache_test.rb +107 -0
- data/test/template/output-elb_test.rb +48 -0
- data/test/template/output-emr_test.rb +30 -0
- data/test/template/output-rds_test.rb +39 -0
- data/test/template/output-redshift_test.rb +39 -0
- data/test/template/output-s3_test.rb +52 -0
- data/test/template/output-security-group_test.rb +21 -0
- data/test/template/output-sqs_test.rb +21 -0
- data/test/template/output-topic_test.rb +30 -0
- data/test/template/output-vpc_test.rb +48 -0
- data/test/template/output_test.rb +87 -0
- data/test/template/parameter-ec2_test.rb +44 -0
- data/test/template/parameter-elasticache_test.rb +30 -0
- data/test/template/parameter-rds_test.rb +30 -0
- data/test/template/parameter-redshift_test.rb +30 -0
- data/test/template/parameter_test.rb +40 -0
- data/test/template/rds-db-cluster-parameter-group_test.rb +53 -0
- data/test/template/rds-db-cluster_test.rb +84 -0
- data/test/template/rds-db-instance_test.rb +93 -0
- data/test/template/rds-db-parameter-group_test.rb +53 -0
- data/test/template/rds-db-subnet-group.rb +54 -0
- data/test/template/rds-event-subscription_test.rb +48 -0
- data/test/template/rds-option-group_test.rb +56 -0
- data/test/template/redshift-cluster-parameter-group_test.rb +28 -0
- data/test/template/redshift-cluster-subnet-group_test.rb +26 -0
- data/test/template/redshift-cluster_test.rb +47 -0
- data/test/template/s3-bucket-policy_test.rb +40 -0
- data/test/template/s3-bucket_test.rb +127 -0
- data/test/template/sns-topic_test.rb +42 -0
- data/test/template/sqs-queue_test.rb +25 -0
- metadata +468 -0
@@ -0,0 +1,165 @@
|
|
1
|
+
#
|
2
|
+
# Helper - EC2
|
3
|
+
#
|
4
|
+
require 'kumogata/template/helper'
|
5
|
+
|
6
|
+
def _ec2_tags(args)
|
7
|
+
if args.key? :tags_append
|
8
|
+
tags_append = {}
|
9
|
+
tags_append[:ref_domain] = "domain" unless args[:tags_append].key? :domain
|
10
|
+
tags_append[:ref_role] = "role" unless args[:tags_append].key? :role
|
11
|
+
tags_append.merge!(args[:tags_append])
|
12
|
+
args[:tags_append] = tags_append
|
13
|
+
else
|
14
|
+
args[:tags_append] = {
|
15
|
+
ref_domain: "domain",
|
16
|
+
ref_role: "role"
|
17
|
+
}
|
18
|
+
end
|
19
|
+
_tags(args)
|
20
|
+
end
|
21
|
+
|
22
|
+
def _ec2_security_group_egresses(name, args)
|
23
|
+
return [] unless args.key? name.to_sym
|
24
|
+
|
25
|
+
rules = []
|
26
|
+
_array(args[name.to_sym]).each do |arg|
|
27
|
+
rules << _ec2_security_group_egress(arg)
|
28
|
+
end
|
29
|
+
rules
|
30
|
+
end
|
31
|
+
|
32
|
+
def _ec2_security_group_egress(args)
|
33
|
+
cidr = args[:cidr] || "0.0.0.0/0"
|
34
|
+
destination = _ref_string("destination", args, "security group")
|
35
|
+
from = _ref_string("from", args)
|
36
|
+
group = _ref_string("group", args, "security group")
|
37
|
+
ip = args[:ip_protocol] || "tcp"
|
38
|
+
to = _ref_string("to", args)
|
39
|
+
from = to if from.empty?
|
40
|
+
|
41
|
+
_{
|
42
|
+
CidrIp cidr if destination.empty?
|
43
|
+
DestinationSecurityGroupId destination unless destination.empty?
|
44
|
+
FromPort from unless ip == "icmp"
|
45
|
+
GroupId group unless group.empty?
|
46
|
+
IpProtocol ip
|
47
|
+
ToPort to unless ip == "icmp"
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
def _ec2_security_group_ingresses(name, args)
|
52
|
+
return [] unless args.key? name.to_sym
|
53
|
+
|
54
|
+
rules = []
|
55
|
+
_array(args[name.to_sym]).each do |arg|
|
56
|
+
rules << _ec2_security_group_ingress(arg)
|
57
|
+
end
|
58
|
+
rules
|
59
|
+
end
|
60
|
+
|
61
|
+
def _ec2_security_group_ingress(args)
|
62
|
+
cidr = args[:cidr] || "0.0.0.0/0"
|
63
|
+
from = _ref_string("from", args)
|
64
|
+
group_id = _ref_string("group", args, "security group")
|
65
|
+
group_name = args[:group_name] || ""
|
66
|
+
ip = args[:ip_protocol] || "tcp"
|
67
|
+
source_group_name = _ref_string("source_group_name", args, "security group")
|
68
|
+
source_group_id = _ref_string("source_group_id", args, "security group")
|
69
|
+
source_group_owner_id = _ref_string("source_group_owner_id", args, "account id")
|
70
|
+
to = _ref_string("to", args)
|
71
|
+
to = from if to.empty?
|
72
|
+
|
73
|
+
_{
|
74
|
+
CidrIp cidr if source_group_name.empty? and source_group_id.empty?
|
75
|
+
FromPort from unless ip == "icmp"
|
76
|
+
GroupId group_id unless group_id.empty?
|
77
|
+
GroupName group_name unless group_name.empty?
|
78
|
+
IpProtocol ip
|
79
|
+
SourceSecurityGroupName source_group_name unless source_group_name.empty?
|
80
|
+
SourceSecurityGroupId source_group_id unless source_group_id.empty?
|
81
|
+
SourceSecurityGroupOwnerId source_group_name unless source_group_owner_id.empty?
|
82
|
+
ToPort to unless ip == "icmp"
|
83
|
+
}
|
84
|
+
end
|
85
|
+
|
86
|
+
def _ec2_block_device(args)
|
87
|
+
device = args[:device] || "/dev/sda1"
|
88
|
+
delete = _bool("delete", args, true)
|
89
|
+
encrypted = _bool("encrypted", args, false)
|
90
|
+
iops = args[:iops] || 300
|
91
|
+
snapshot = args[:snapshot] || ""
|
92
|
+
size = _ref_string("size", args, "volume size")
|
93
|
+
type = _valid_values(args[:type], %w( io1 gp2 sc1 st1 ), "gp2")
|
94
|
+
no_device = args[:no_device] || ""
|
95
|
+
virtual = args[:virtual] || ""
|
96
|
+
|
97
|
+
_{
|
98
|
+
DeviceName device
|
99
|
+
Ebs do
|
100
|
+
DeleteOnTermination delete
|
101
|
+
Encrypted encrypted if encrypted == true
|
102
|
+
Iops iops if type == "io1"
|
103
|
+
SnapshotId snapshot if device.empty?
|
104
|
+
VolumeSize size if snapshot.empty? and !size.empty?
|
105
|
+
VolumeType type
|
106
|
+
end
|
107
|
+
NoDevice no_device unless no_device.empty?
|
108
|
+
VirtualName virtual unless virtual.empty?
|
109
|
+
}
|
110
|
+
end
|
111
|
+
|
112
|
+
def _ec2_network_interface(args)
|
113
|
+
associate_public = _bool("associate_public", args, true)
|
114
|
+
delete = _bool("delete", args, true)
|
115
|
+
description = args[:description] || ""
|
116
|
+
device = args[:device] || 0
|
117
|
+
group_set = _ref_array("group_set", args, "security group")
|
118
|
+
network_interface = _ref_string("network", args)
|
119
|
+
private_ip = args[:private_ip] || ""
|
120
|
+
private_ips = args[:private_ips] || ""
|
121
|
+
secondary_private_ip = args[:secondary_private_ip] || ""
|
122
|
+
subnet = _ref_string("subnet", args, "subnet")
|
123
|
+
|
124
|
+
_{
|
125
|
+
AssociatePublicIpAddress associate_public
|
126
|
+
DeleteOnTermination delete
|
127
|
+
Description description unless description.empty?
|
128
|
+
DeviceIndex device
|
129
|
+
GroupSet group_set unless group_set.empty?
|
130
|
+
NetworkInterfaceId network_interface unless network_interface.empty?
|
131
|
+
PrivateIpAddress private_ip unless private_ip.empty?
|
132
|
+
PrivateIpAddresses private_ips unless private_ips.empty?
|
133
|
+
SecondaryPrivateIpAddressCount secondary_private_ip unless secondary_private_ip.empty?
|
134
|
+
SubnetId subnet
|
135
|
+
}
|
136
|
+
end
|
137
|
+
|
138
|
+
def _ec2_image(instance_type, args)
|
139
|
+
return args[:image_id] if args.key? :image_id
|
140
|
+
resource_image = _resource_name(args[:image] || EC2_DEFAULT_IMAGE)
|
141
|
+
_find_in_map("AWSRegionArch2AMI#{resource_image}",
|
142
|
+
_{ Ref "AWS::Region" },
|
143
|
+
_find_in_map("AWSInstanceType2Arch", instance_type, "Arch"))
|
144
|
+
end
|
145
|
+
|
146
|
+
def _ec2_port_range(args)
|
147
|
+
_{
|
148
|
+
From args[:from] || 0
|
149
|
+
To args[:to] || args[:from] || 65535
|
150
|
+
}
|
151
|
+
end
|
152
|
+
|
153
|
+
def _ec2_protocol_number(protocol)
|
154
|
+
# http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml
|
155
|
+
case protocol
|
156
|
+
when 'tcp'
|
157
|
+
6
|
158
|
+
when 'udp'
|
159
|
+
17
|
160
|
+
when 'icmp'
|
161
|
+
1
|
162
|
+
else
|
163
|
+
-1
|
164
|
+
end
|
165
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
#
|
2
|
+
# Helper - ECS
|
3
|
+
#
|
4
|
+
require 'kumogata/template/helper'
|
5
|
+
|
6
|
+
def _ecs_load_balancers(args)
|
7
|
+
balancers = args[:load_balancers] || []
|
8
|
+
|
9
|
+
array = []
|
10
|
+
balancers.each do |balancer|
|
11
|
+
array << _{
|
12
|
+
ContainerName balancer[:container_name] || 80
|
13
|
+
ContainerPort balancer[:container_port] || 80
|
14
|
+
LoadBalancerName balancer[:lb_name] || ""
|
15
|
+
}
|
16
|
+
end
|
17
|
+
array
|
18
|
+
end
|
19
|
+
|
20
|
+
def _ecs_container_definitions(args)
|
21
|
+
definitions = args[:container_definitions] || []
|
22
|
+
|
23
|
+
array = []
|
24
|
+
definitions.each do |definition|
|
25
|
+
command = definition[:command] || []
|
26
|
+
entry_point = definition[:entry_point] || []
|
27
|
+
environment = definition[:environment] || []
|
28
|
+
links = definition[:link] || []
|
29
|
+
mount_points = _ecs_mount_points(definition)
|
30
|
+
port_mappings =
|
31
|
+
if definition.key? :port_mappings
|
32
|
+
if definition[:port_mappings].nil?
|
33
|
+
[]
|
34
|
+
else
|
35
|
+
_ecs_port_mappings(definition)
|
36
|
+
end
|
37
|
+
else
|
38
|
+
_ecs_port_mappings({ port_mappings: [ { container_port: 80 } ] })
|
39
|
+
end
|
40
|
+
volumes_from = _ecs_volumes_from(definition)
|
41
|
+
array << _{
|
42
|
+
Command command unless command.empty?
|
43
|
+
Cpu definition[:cpu] || 10
|
44
|
+
EntryPoint entry_point unless entry_point.empty?
|
45
|
+
Environment environment unless environment.empty?
|
46
|
+
Essential _bool("essential", definition, true)
|
47
|
+
Image definition[:image] # repository-url/image:tag
|
48
|
+
Links links unless links.empty?
|
49
|
+
Memory definition[:memory] || 300 # MiB
|
50
|
+
MountPoints mount_points unless mount_points.empty?
|
51
|
+
Name _ref_string("name", definition)
|
52
|
+
PortMappings port_mappings unless port_mappings.empty?
|
53
|
+
VolumesFrom volumes_from unless volumes_from.empty?
|
54
|
+
}
|
55
|
+
end
|
56
|
+
array
|
57
|
+
end
|
58
|
+
|
59
|
+
def _ecs_mount_points(args)
|
60
|
+
mount_points = args[:mount_points] || []
|
61
|
+
array = []
|
62
|
+
mount_points.each do |point|
|
63
|
+
array << _{
|
64
|
+
ContainerPath point[:container_path]
|
65
|
+
SourceVolume point[:source_volume]
|
66
|
+
ReadOnly _bool("read_only", point, false)
|
67
|
+
}
|
68
|
+
end
|
69
|
+
array
|
70
|
+
end
|
71
|
+
|
72
|
+
def _ecs_port_mappings(args)
|
73
|
+
port_mappings = args[:port_mappings] || []
|
74
|
+
|
75
|
+
array = []
|
76
|
+
port_mappings.each do |point|
|
77
|
+
host_port = _ref_string("host_port", point, "host port")
|
78
|
+
array << _{
|
79
|
+
ContainerPort _ref_string("container_port", point, "container port")
|
80
|
+
HostPort host_port unless host_port.empty?
|
81
|
+
}
|
82
|
+
end
|
83
|
+
array
|
84
|
+
end
|
85
|
+
|
86
|
+
def _ecs_volumes_from(args)
|
87
|
+
volumes_from = args[:volumes_from] || []
|
88
|
+
|
89
|
+
array = []
|
90
|
+
volumes_from.each do |volume|
|
91
|
+
array << _{
|
92
|
+
SourceContainer _ref_string("source", volume)
|
93
|
+
ReadOnly _bool("read_only", volume, false)
|
94
|
+
}
|
95
|
+
end
|
96
|
+
array
|
97
|
+
end
|
98
|
+
|
99
|
+
def _ecs_volumes(args)
|
100
|
+
volumes = args[:volumes] || []
|
101
|
+
|
102
|
+
array = []
|
103
|
+
volumes.each do |volume|
|
104
|
+
host = _ecs_volumes_host(volume[:host])
|
105
|
+
array << _{
|
106
|
+
Name volume[:name]
|
107
|
+
Host host unless host.empty?
|
108
|
+
}
|
109
|
+
end
|
110
|
+
array
|
111
|
+
end
|
112
|
+
|
113
|
+
def _ecs_volumes_host(args)
|
114
|
+
return {} if args.nil? or !args.key? :source_path
|
115
|
+
|
116
|
+
_{
|
117
|
+
SourcePath args[:source_path]
|
118
|
+
}
|
119
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#
|
2
|
+
# Helper - Elasticbeanstalk
|
3
|
+
#
|
4
|
+
require 'kumogata/template/helper'
|
5
|
+
|
6
|
+
def _elasticbeanstalk_option(options)
|
7
|
+
array = []
|
8
|
+
options.each do |option|
|
9
|
+
array << _{
|
10
|
+
Namespace option[:namespace]
|
11
|
+
OptionName option[:option]
|
12
|
+
Value option[:value]
|
13
|
+
}
|
14
|
+
end
|
15
|
+
array
|
16
|
+
end
|
17
|
+
|
18
|
+
def _elasticbeanstalk_configuration(configuration)
|
19
|
+
_{
|
20
|
+
ApplicationName configuration[:application]
|
21
|
+
TemplateName configuration[:template]
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
def _elasticbeanstalk_tier(tier)
|
26
|
+
name = _valid_values(tier[:name], %w( WebServer Worker ), "WebServer")
|
27
|
+
|
28
|
+
_{
|
29
|
+
Name name
|
30
|
+
Type (name == "WebServer") ? "Standard" : "SQS/HTTP"
|
31
|
+
Version tier[:version] || "1.0"
|
32
|
+
}
|
33
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
#
|
2
|
+
# Helper - ELB
|
3
|
+
#
|
4
|
+
require 'kumogata/template/helper'
|
5
|
+
|
6
|
+
def _elb_access_logging_policy(args)
|
7
|
+
access = args[:access_logging] || ""
|
8
|
+
return "" if access.empty?
|
9
|
+
|
10
|
+
_{
|
11
|
+
EmitInterval access[:emit] || 5
|
12
|
+
Enabled _bool("enabled", access, true)
|
13
|
+
S3BucketName access[:s3_bucket]
|
14
|
+
S3BucketPrefix access[:s3_bucket_prefix]
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
def _elb_app_cookie_stickiness_policy(args)
|
19
|
+
array = []
|
20
|
+
apps = args[:app_cookie] || []
|
21
|
+
|
22
|
+
apps.each do |app|
|
23
|
+
array << _{
|
24
|
+
CookieName app[:cookie]
|
25
|
+
PolicyName app[:policy]
|
26
|
+
}
|
27
|
+
end
|
28
|
+
array
|
29
|
+
end
|
30
|
+
|
31
|
+
def _elb_connection_draining_policy(args)
|
32
|
+
connection = args[:connection_draining] || {}
|
33
|
+
|
34
|
+
_{
|
35
|
+
Enabled _bool("enabled", connection, true)
|
36
|
+
Timeout connection[:timeout] || 60
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
def _elb_connection_settings(args)
|
41
|
+
connection = args[:connection_settings] || {}
|
42
|
+
|
43
|
+
_{
|
44
|
+
IdleTimeout connection[:idle] || 60
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
def _elb_health_check(args)
|
49
|
+
health_check = args[:health_check] || {}
|
50
|
+
protocol = _valid_values(health_check[:protocol], %w( http https tcp ssl ), "http")
|
51
|
+
port = health_check[:port] || case protocol
|
52
|
+
when "http"
|
53
|
+
80
|
54
|
+
when "https"
|
55
|
+
443
|
56
|
+
end
|
57
|
+
path = health_check[:path] || "index.html"
|
58
|
+
_{
|
59
|
+
HealthyThreshold health_check[:healthy] || 10
|
60
|
+
Interval health_check[:interval] || 30
|
61
|
+
Target "#{protocol.upcase}:#{port}/#{path}"
|
62
|
+
Timeout health_check[:timeout] || 5
|
63
|
+
UnhealthyThreshold health_check[:unhealthly] || 2
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
def _elb_cookie_stickiness_policy(args)
|
68
|
+
cookies = args[:cookie_stickiness] || []
|
69
|
+
|
70
|
+
array = []
|
71
|
+
cookies.each do |cookie|
|
72
|
+
array << _{
|
73
|
+
CookieExpirationPeriod cookie[:expiration]
|
74
|
+
PolicyName cookie[:policy]
|
75
|
+
}
|
76
|
+
end
|
77
|
+
array
|
78
|
+
end
|
79
|
+
|
80
|
+
def _elb_listeners(args)
|
81
|
+
listeners = args[:listeners] || []
|
82
|
+
listeners = [ { protocol: "http" } ] if listeners.empty?
|
83
|
+
|
84
|
+
array = []
|
85
|
+
listeners.each do |listener|
|
86
|
+
proto = listener[:protocol].upcase
|
87
|
+
protocol = _valid_values(proto, %w( http https tcp ssl ), "http")
|
88
|
+
port = listener[:port] || case protocol
|
89
|
+
when "http"
|
90
|
+
80
|
91
|
+
when "https"
|
92
|
+
443
|
93
|
+
end
|
94
|
+
lb_port = listener[:lb_port] || port
|
95
|
+
policies = []
|
96
|
+
policies << "ELBSecurityPolicy-2015-05" if protocol == "https" or protocol == "ssl"
|
97
|
+
ssl = _ref_string("ssl", listener)
|
98
|
+
|
99
|
+
array << _{
|
100
|
+
InstancePort port
|
101
|
+
InstanceProtocol protocol.upcase
|
102
|
+
LoadBalancerPort lb_port
|
103
|
+
PolicyNames policies unless policies.empty?
|
104
|
+
Protocol protocol.upcase
|
105
|
+
SSLCertificateId ssl if protocol == "https"
|
106
|
+
}
|
107
|
+
end
|
108
|
+
array
|
109
|
+
end
|
110
|
+
|
111
|
+
def _elb_policy_types(args)
|
112
|
+
policies = args[:policy] || []
|
113
|
+
return [] if policies.empty?
|
114
|
+
|
115
|
+
array = []
|
116
|
+
policies.each do |policy|
|
117
|
+
attributes = []
|
118
|
+
instance_ports = []
|
119
|
+
lb_ports = []
|
120
|
+
policy_name = policy[:name]
|
121
|
+
policy_type = policy[:type]
|
122
|
+
|
123
|
+
array << _{
|
124
|
+
Attributes attributes unless attributes.empty?
|
125
|
+
InstancePorts instance_ports unless instance_ports.empty?
|
126
|
+
LoadBalancerPorts lb_ports unless lb_ports.empty?
|
127
|
+
PolicyName policy_name
|
128
|
+
PolicyType policy_type
|
129
|
+
}
|
130
|
+
end
|
131
|
+
array
|
132
|
+
end
|