kumogata-template 0.0.29 → 0.0.30

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/Gemfile.lock +13 -40
  4. data/README.md +34 -83
  5. data/bin/kumogata-template +2 -2
  6. data/kumogata-template.gemspec +4 -4
  7. data/lib/kumogata/template/autoscaling.rb +19 -0
  8. data/lib/kumogata/template/cloudwatch.rb +1 -9
  9. data/lib/kumogata/template/const.rb +22 -4
  10. data/lib/kumogata/template/ec2.rb +18 -8
  11. data/lib/kumogata/template/ecs.rb +34 -0
  12. data/lib/kumogata/template/elasticbeanstalk.rb +937 -3
  13. data/lib/kumogata/template/ext/kumogata.rb +64 -16
  14. data/lib/kumogata/template/helper.rb +146 -19
  15. data/lib/kumogata/template/iam.rb +2 -3
  16. data/lib/kumogata/template/lambda.rb +10 -1
  17. data/lib/kumogata/template/version.rb +1 -1
  18. data/template/_template.rb +20 -3
  19. data/template/alb-load-balancer.rb +8 -1
  20. data/template/autoscaling-launch-configuration.rb +2 -11
  21. data/template/autoscaling-scheduled-action.rb +2 -17
  22. data/template/ec2-instance.rb +5 -7
  23. data/template/ec2-network-acl-entry.rb +3 -1
  24. data/template/ec2-route.rb +3 -1
  25. data/template/ec2-security-group.rb +2 -0
  26. data/template/ec2-subnet.rb +2 -1
  27. data/template/ec2-vpc.rb +2 -1
  28. data/template/ecs-service.rb +4 -0
  29. data/template/ecs-task-definition.rb +6 -4
  30. data/template/elasticbeanstalk-application-version.rb +9 -4
  31. data/template/elasticbeanstalk-application.rb +4 -3
  32. data/template/elasticbeanstalk-configuration-template.rb +7 -2
  33. data/template/elasticbeanstalk-environment.rb +10 -10
  34. data/template/emr-cluster.rb +8 -3
  35. data/template/iam-instance-profile.rb +2 -0
  36. data/template/lambda-function.rb +8 -3
  37. data/template/mappings-ec2.rb +44 -44
  38. data/template/output-access-key.rb +7 -2
  39. data/template/output-alb.rb +16 -11
  40. data/template/output-arn.rb +6 -3
  41. data/template/output-autoscaling.rb +7 -2
  42. data/template/output-dynamodb.rb +7 -2
  43. data/template/output-ec2-subnet.rb +14 -0
  44. data/template/output-ec2.rb +13 -4
  45. data/template/output-elasticache.rb +23 -7
  46. data/template/output-elasticbeanstalk-environment.rb +8 -0
  47. data/template/output-elb.rb +13 -6
  48. data/template/output-emr.rb +8 -3
  49. data/template/output-iam-instance-profile.rb +7 -2
  50. data/template/output-iam-role.rb +7 -2
  51. data/template/output-name.rb +3 -1
  52. data/template/output-rds.rb +7 -3
  53. data/template/output-redshift.rb +7 -3
  54. data/template/output-s3.rb +11 -3
  55. data/template/output-security-group.rb +4 -1
  56. data/template/output-sqs.rb +4 -1
  57. data/template/output-topic.rb +8 -3
  58. data/template/output-vpc.rb +16 -4
  59. data/template/output.rb +3 -1
  60. data/template/rds-db-instance.rb +7 -0
  61. data/template/redshift-cluster.rb +2 -0
  62. data/template/sqs-queue.rb +14 -0
  63. data/test/abstract_unit.rb +31 -8
  64. data/test/elasticbeanstalk_test.rb +3 -3
  65. data/test/helper_test.rb +431 -0
  66. data/test/template/autoscaling-launch-configuration_test.rb +1 -4
  67. data/test/template/ec2-instance_test.rb +2 -2
  68. data/test/template/ec2-vpc_test.rb +2 -2
  69. data/test/template/ecs-task-definition_test.rb +13 -13
  70. data/test/template/elasticbeanstalk-application-version_test.rb +13 -3
  71. data/test/template/elasticbeanstalk-template_test.rb +1 -1
  72. data/test/template/iam-instance-profile_test.rb +20 -0
  73. data/test/template/lambda-function_test.rb +60 -4
  74. data/test/template/{output-az_test.rb → output-ec2-subet_test.rb} +7 -8
  75. data/test/template/output-elasticache_test.rb +18 -0
  76. data/test/template/output_test.rb +23 -0
  77. data/test/template/rds-db-instance_test.rb +1 -1
  78. metadata +22 -22
  79. data/lib/kumogata/template/ext/argument_parser.rb +0 -8
  80. data/template/output-az.rb +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b7c5c58bc386eb269e5d341c8ebf017a35acfb4
4
- data.tar.gz: fe355680255862807a561345d95d579b5d59714d
3
+ metadata.gz: 2e12e89a89f82fa03c5fd7d65813a60a86c387a9
4
+ data.tar.gz: 6fb3b59eab473bd93551eaf0289cc3d79bef748b
5
5
  SHA512:
6
- metadata.gz: f199fc4f72e2a341e97aa94eacc362143dc33f8a5a959c77c28881caddf909c380c2dfac5bdf4c4c76bcb2bc1f5ecae4dd3d5a4a941dce512e099c4a9ccc3a79
7
- data.tar.gz: 38306ede34739c5a85b4a200fa123f408bc33683ebc2ac6a3baf2e077a82e12663c336147b79b58ae8dc8f1df103666330654692ac664ce24e5f362d64eb2f89
6
+ metadata.gz: 344f8ec28fa37924fefc87483d9de29dad189195aa8a5a470994487833a44486da9e1a676c73f029962396ac7ac202d5e24a743b711cc914fd2759c8c1653ca8
7
+ data.tar.gz: c2005b2a03797e94e535d7bcfd624067b1fc31773037926d878d95ced42f443caab739e9d5138346059c398cb6aeba432f4ee31cdfdd3a21a45b2f7e2d3a03cb
data/.travis.yml CHANGED
@@ -2,7 +2,7 @@ sudo: false
2
2
  language: ruby
3
3
  cache: bundler
4
4
  rvm:
5
- - 2.3.4
5
+ - 2.4.1
6
6
  gemfile: n0ts/kumogata-template/Gemfile
7
7
  script:
8
8
  - bundle install --path vendor/bundle
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kumogata-template (0.0.28)
4
+ kumogata-template (0.0.29)
5
5
  aws-sdk (~> 2.3)
6
- kumogata (= 0.5.12)
6
+ kumogata2-plugin-ruby (= 0.1.3)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
@@ -15,64 +15,37 @@ GEM
15
15
  jmespath (~> 1.0)
16
16
  aws-sdk-resources (2.9.25)
17
17
  aws-sdk-core (= 2.9.25)
18
- aws-sdk-v1 (1.67.0)
19
- json (~> 1.4)
20
- nokogiri (~> 1)
21
18
  aws-sigv4 (1.0.0)
22
19
  coderay (1.1.1)
23
- coffee-script (2.4.1)
24
- coffee-script-source
25
- execjs
26
- coffee-script-source (1.12.2)
27
20
  diffy (3.2.0)
28
- dslh (0.2.7)
29
- execjs (2.7.0)
21
+ dslh (0.4.8)
30
22
  hashie (3.5.5)
31
23
  highline (1.7.8)
32
24
  jmespath (1.3.1)
33
- json (1.8.3)
34
- json5 (0.0.1)
35
- kumogata (0.5.12)
36
- aws-sdk-v1
25
+ kumogata2 (0.1.9)
26
+ aws-sdk (>= 2.3.0)
37
27
  coderay
38
- coffee-script
39
28
  diffy
40
- dslh (>= 0.2.7, < 0.3)
41
29
  hashie
42
30
  highline
43
- json (= 1.8.3)
44
- json5
45
- net-ssh
46
- nokogiri (= 1.6.7.2)
47
- retryable (~> 2.0.0)
48
31
  term-ansicolor
49
- therubyracer (= 0.12.2)
50
- uuidtools
51
- libv8 (3.16.14.19-x86_64-darwin-16)
52
- mini_portile2 (2.0.0)
32
+ kumogata2-plugin-ruby (0.1.3)
33
+ dslh (>= 0.3.7)
34
+ kumogata2
53
35
  minitest (5.10.2)
54
- net-ssh (4.1.0)
55
- nokogiri (1.6.7.2)
56
- mini_portile2 (~> 2.0.0.rc2)
57
- rake (11.3.0)
58
- ref (2.0.0)
59
- retryable (2.0.4)
36
+ rake (12.0.0)
60
37
  term-ansicolor (1.6.0)
61
38
  tins (~> 1.0)
62
- therubyracer (0.12.2)
63
- libv8 (~> 3.16.14.0)
64
- ref
65
39
  tins (1.14.0)
66
- uuidtools (2.1.5)
67
40
 
68
41
  PLATFORMS
69
42
  ruby
70
43
 
71
44
  DEPENDENCIES
72
- bundler (~> 1.11)
45
+ bundler
73
46
  kumogata-template!
74
- minitest (~> 5.8)
75
- rake (~> 11.1)
47
+ minitest
48
+ rake
76
49
 
77
50
  BUNDLED WITH
78
- 1.15.0
51
+ 1.15.1
data/README.md CHANGED
@@ -5,13 +5,10 @@
5
5
 
6
6
  ## About
7
7
 
8
- - `kumogate-template` is a template sets for [kumogata](https://github.com/winebarrel/kumogata).
8
+ - `kumogate-template` is a template sets for [kumogata2](https://github.com/winebarrel/kumogata2).
9
9
 
10
10
  ## Installation
11
11
 
12
- Add
13
-
14
-
15
12
  Add this line to your application's Gemfile:
16
13
 
17
14
  ```ruby
@@ -124,82 +121,36 @@ EOS
124
121
  - more example see [test code](test/template)
125
122
 
126
123
 
127
- ## Support AWS Resource Types
128
-
129
- - AWS::AutoScaling::AutoScalingGroup
130
- - AWS::AutoScaling::LaunchConfiguration
131
- - AWS::AutoScaling::LifecycleHook
132
- - AWS::AutoScaling::ScalingPolicy
133
- - AWS::AutoScaling::ScheduledAction
134
- - AWS::CloudTrail::Trail
135
- - AWS::CodeDeploy::Application
136
- - AWS::CodeDeploy::DeploymentConfig
137
- - AWS::CodeDeploy::DeploymentGroup
138
- - AWS::DataPipeline::Pipeline
139
- - AWS::DynamoDB::Table
140
- - AWS::EC2::EIPAssociation
141
- - AWS::EC2::EIP
142
- - AWS::EC2::Instance
143
- - AWS::EC2::InternetGateway
144
- - AWS::EC2::NatGateway
145
- - AWS::EC2::NetworkAclEntry
146
- - AWS::EC2::NetworkAcl
147
- - AWS::EC2::RouteTable
148
- - AWS::EC2::Route
149
- - AWS::EC2::SecurityGroup
150
- - AWS::EC2::SubnetNetworkAclAssociation
151
- - AWS::EC2::SubnetRouteTableAssociation
152
- - AWS::EC2::Subnet
153
- - AWS::EC2::VolumeAttachment
154
- - AWS::EC2::VPCEndpoint
155
- - AWS::EC2::VPCGatewayAttachment
156
- - AWS::EC2::VPC
157
- - AWS::ECS::Cluster
158
- - AWS::ECS::Service
159
- - AWS::ECS::TaskDefinition
160
- - AWS::ElastiCache::CacheCluster
161
- - AWS::ElastiCache::ParameterGroup
162
- - AWS::ElastiCache::ReplicationGroup
163
- - AWS::ElastiCache::SubnetGroup
164
- - AWS::ElasticBeanstalk::ApplicationVersion
165
- - AWS::ElasticBeanstalk::Application
166
- - AWS::ElasticBeanstalk::ConfigurationTemplate
167
- - AWS::ElasticBeanstalk::Environment
168
- - AWS::ElasticLoadBalancing::LoadBalancer
169
- - AWS::EMR::Cluster
170
- - AWS::EMR::InstanceGroupConfig
171
- - AWS::EMR::Step
172
- - AWS::Events::Rule
173
- - AWS::IAM::AccessKey
174
- - AWS::IAM::Group
175
- - AWS::IAM::InstanceProfile
176
- - AWS::IAM::ManagedPolicy
177
- - AWS::IAM::Policy
178
- - AWS::IAM::Role
179
- - AWS::IAM::UserToGroupAddition
180
- - AWS::IAM::User
181
- - AWS::Lambda::Alias
182
- - AWS::Lambda::EventSourceMapping
183
- - AWS::Lambda::Function
184
- - AWS::Lambda::Permission
185
- - AWS::Lambda::Version
186
- - AWS::RDS::DBClusterParameterGroup
187
- - AWS::RDS::DBCluster
188
- - AWS::RDS::DBInstance
189
- - AWS::RDS::DBParameterGroup
190
- - AWS::RDS::DBSubnetGroup
191
- - AWS::RDS::EventSubscription
192
- - AWS::RDS::OptionGroup
193
- - AWS::Redshift::ClusterParameterGroup
194
- - AWS::Redshift::ClusterSubnetGroup
195
- - AWS::Redshift::Cluster
196
- - AWS::S3::BucketPolicy
197
- - AWS::S3::Bucket
198
- - AWS::SNS::Topic
199
- - AWS::SQS::Queue
200
-
201
-
202
- ## TODO
203
-
204
- - Support [Kumogata2](https://github.com/winebarrel/kumogata2)
205
- - Useful kumogate-template snippets
124
+ ## AWS CloudFormation
125
+
126
+ - [Relese notes](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/ReleaseHistory.html)
127
+ - Almost support release date is `January 17, 2017`
128
+
129
+ - [Support Resource Types](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html)
130
+ - AWS::AutoScaling::*
131
+ - AWS::CertificateManager::*
132
+ - AWS::CloudFront::**
133
+ - AWS::CloudTrail::*
134
+ - AWS::CloudWatch::*
135
+ - AWS::CodeBuild::*
136
+ - AWS::CodeCommit::*
137
+ - AWS::CodeDeploy::*
138
+ - AWS::DataPipeline::*
139
+ - AWS::DynamoDB::*
140
+ - AWS::EC2::*
141
+ - AWS::ECS::*
142
+ - AWS::ElastiCache::*
143
+ - AWS::ElasticBeanstalk::*
144
+ - AWS::ElasticLoadBalancing::*
145
+ - AWS::ElasticLoadBalancingV2::*
146
+ - AWS::EMR::*
147
+ - AWS::Events::*
148
+ - AMS::KMS::*
149
+ - AWS::IAM::*
150
+ - AWS::Lambda::*
151
+ - AWS::Logs::*
152
+ - AWS::RDS::*
153
+ - AWS::Redshift::*
154
+ - AWS::S3::*
155
+ - AWS::SNS::*
156
+ - AWS::SQS::*
@@ -2,8 +2,8 @@
2
2
  $: << File.expand_path("#{File.dirname __FILE__}/../lib")
3
3
  require 'rubygems'
4
4
  require 'kumogata/template/ext/kumogata'
5
- require 'kumogata/template/ext/argument_parser'
5
+ require 'kumogata/template/ext/option_parser'
6
6
  require 'kumogata/template'
7
7
 
8
8
 
9
- load Gem.bin_path('kumogata', 'kumogata')
9
+ load Gem.bin_path('kumogata2', 'kumogata2')
@@ -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 'kumogata', '0.5.12'
23
- spec.add_development_dependency 'bundler', '~> 1.11'
24
- spec.add_development_dependency 'rake', '~> 11.1'
25
- spec.add_development_dependency 'minitest', '~> 5.8'
22
+ spec.add_dependency 'kumogata2-plugin-ruby', '0.1.3'
23
+ spec.add_development_dependency 'bundler'
24
+ spec.add_development_dependency 'rake'
25
+ spec.add_development_dependency 'minitest'
26
26
  end
@@ -43,6 +43,25 @@ def _autoscaling_to_policy(value)
43
43
  end
44
44
  end
45
45
 
46
+ def _autoscaling_to_schedued_recurrence(value)
47
+ case value
48
+ when "every 5 min"
49
+ "*/5 * * * *"
50
+ when "every 30 min"
51
+ "0,30 * * * *"
52
+ when "every 1 hour"
53
+ "0 * * * *"
54
+ when "every day"
55
+ "0 0 * * *"
56
+ when "every week"
57
+ "0 0 * * Tue"
58
+ when /\*/
59
+ value
60
+ else
61
+ _timestamp_utc(value, "cron")
62
+ end
63
+ end
64
+
46
65
  def _autoscaling_metrics
47
66
  _{
48
67
  Granularity "1Minute"
@@ -238,15 +238,7 @@ end
238
238
 
239
239
  def _cloudwatch_to_ec2_action(value)
240
240
  value = _valid_values(value, %w( recover stop terminate reboot ), "recover")
241
- _{
242
- Fn__Join "", [
243
- "arn:aws:automate:",
244
- _{
245
- Ref "AWS::Region"
246
- },
247
- ":ec2:#{value}"
248
- ]
249
- }
241
+ _join([ "arn:aws:automate:", _region, ":ec2:#{value}" ], "")
250
242
  end
251
243
 
252
244
  def _cloudwatch_dimension(args)
@@ -95,7 +95,7 @@ EC2_INSTANCE_TYPES =
95
95
  # x1.32xlarge 128 1,952 2 x 1,902 SSD 10
96
96
  "x1.16xlarge", "x1.32xlarge",
97
97
  ]
98
- EC2_DEFAULT_INSTANCE_TYPE = "t2.medium"
98
+ EC2_DEFAULT_INSTANCE_TYPE = "t2.micro"
99
99
 
100
100
  ELASTICACHE_DEFAULT_ENGINE = "redis"
101
101
  ELASTICACHE_DEFAULT_ENGINE_VERSION = {
@@ -160,10 +160,10 @@ RDS_INSTANCE_CLASSES =
160
160
  RDS_DEFAULT_INSTANCE_CLASS = "db.t2.medium"
161
161
  RDS_DEFAULT_ENGINE = "mysql"
162
162
  RDS_DEFAULT_ENGINE_VERSION = {
163
- mysql: "5.7.10",
164
- mariadb: "10.0.17",
163
+ mysql: "5.7.17",
164
+ mariadb: "10.1.19",
165
165
  aurora: "5.6.10a",
166
- postgres: "9.4.5",
166
+ postgres: "9.6.2-R1",
167
167
  }
168
168
 
169
169
  # https://aws.amazon.com/redshift/pricing/
@@ -204,3 +204,21 @@ ELB_ACCESS_LOG_ACCOUNT_ID = {
204
204
  "ap-northeast-2": "600734575887",
205
205
  "sa-east-1": "507241528517",
206
206
  }
207
+
208
+ # http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/concepts.platforms.html
209
+ ELASTIC_BEANTALK_LINUX = "64bit Amazon Linux 2017.03"
210
+ ELASTIC_BEANTALK_PLATFORM = {
211
+ packer: "#{ELASTIC_BEANTALK_LINUX} v2.2.0 running Packer 1.0.0",
212
+ docker: "#{ELASTIC_BEANTALK_LINUX} v2.6.0 running Docker 1.12.6",
213
+ go: "#{ELASTIC_BEANTALK_LINUX} v2.4.0 running Go 1.7",
214
+ java: "#{ELASTIC_BEANTALK_LINUX} v2.5.0 running Java 8",
215
+ java_tomcat: "#{ELASTIC_BEANTALK_LINUX} v2.6.0 running Tomcat 8 Java 8",
216
+ windows_server: "64bit Windows Server 2012 R2 v1.2.0 running IIS 8.5",
217
+ node: "#{ELASTIC_BEANTALK_LINUX} v4.1.0 running Node.js",
218
+ php: "#{ELASTIC_BEANTALK_LINUX} v2.4.0 running PHP 7.0",
219
+ python: "#{ELASTIC_BEANTALK_LINUX} v2.4.0 running Python 3.4",
220
+ ruby_puma: "#{ELASTIC_BEANTALK_LINUX} v2.4.0 running Ruby 2.3 (Puma)",
221
+ ruby_passenger: "#{ELASTIC_BEANTALK_LINUX} v2.4.0 running Ruby 2.3 (Passenger Standalone)",
222
+ }
223
+
224
+ ELASTIC_BEANTALK_EC2_DEFAULT_ROLE = "aws-elasticbeanstalk-ec2-role"
@@ -31,6 +31,7 @@ end
31
31
 
32
32
  def _ec2_security_group_egress(args)
33
33
  cidr = args[:cidr] || "0.0.0.0/0"
34
+ cidr_ipv6 = args[:cidr_ipv6] || ""
34
35
  destination = _ref_string("destination", args, "security group")
35
36
  from = _ref_string("from", args)
36
37
  group = _ref_string("group", args, "security group")
@@ -40,6 +41,7 @@ def _ec2_security_group_egress(args)
40
41
 
41
42
  _{
42
43
  CidrIp cidr if destination.empty?
44
+ CidrIpv6 cidr_ipv6 unless cidr_ipv6.empty?
43
45
  DestinationSecurityGroupId destination unless destination.empty?
44
46
  FromPort from unless ip == "icmp"
45
47
  GroupId group unless group.empty?
@@ -66,6 +68,7 @@ end
66
68
 
67
69
  def _ec2_security_group_ingress(args)
68
70
  cidr = args[:cidr] || "0.0.0.0/0"
71
+ cidr_ipv6 = args[:cidr_ipv6] || ""
69
72
  from = _ref_string("from", args)
70
73
  group_id = _ref_string("group", args, "security group")
71
74
  group_name = args[:group_name] || ""
@@ -79,6 +82,7 @@ def _ec2_security_group_ingress(args)
79
82
 
80
83
  _{
81
84
  CidrIp cidr if source_group_name.empty? and source_group_id.empty?
85
+ CidrIpv6 cidr_ipv6 unless cidr_ipv6.empty?
82
86
  FromPort from unless ip == "icmp"
83
87
  GroupId group_id unless group_id.empty?
84
88
  GroupName group_name unless group_name.empty?
@@ -153,7 +157,7 @@ def _ec2_image(instance_type, args)
153
157
 
154
158
  resource_image = _resource_name(args[:image] || EC2_DEFAULT_IMAGE)
155
159
  _find_in_map("AWSRegionArch2AMI#{resource_image}",
156
- _{ Ref "AWS::Region" },
160
+ _region,
157
161
  _find_in_map("AWSInstanceType2Arch", instance_type, "Arch"))
158
162
  end
159
163
 
@@ -178,6 +182,17 @@ def _ec2_protocol_number(protocol)
178
182
  end
179
183
  end
180
184
 
185
+ def _ec2_user_data(args)
186
+ user_data = _ref_string("user_data", args, "user data")
187
+ return "" if user_data.empty?
188
+
189
+ if user_data.is_a? Hash
190
+ _base64(user_data)
191
+ else
192
+ _base64_shell(user_data)
193
+ end
194
+ end
195
+
181
196
  def _ec2_spot_fleet_request(args)
182
197
  allocation = _valid_values(args[:allocation], %w( lowestPrice diversified), "lowestPrice")
183
198
  express = _valid_values(args[:express], %w( noTermination default), "")
@@ -225,7 +240,7 @@ def _ec2_spot_fleet_launches(args)
225
240
  ram_disk = args[:ram_disk] || ""
226
241
  security_groups = _ref_array("security_groups", args, "security group")
227
242
  subnet = _ref_string("subnet", args, "subnet")
228
- user_data = _ref_string("user_data", args, "user data")
243
+ user_data = _ec2_user_data(args)
229
244
  weighted = args[:weighted] || ""
230
245
 
231
246
  _{
@@ -246,12 +261,7 @@ def _ec2_spot_fleet_launches(args)
246
261
  RamdiskId ram_disk unless ram_disk.empty?
247
262
  SecurityGroups security_groups unless security_groups.empty?
248
263
  SubnetId subnet unless subnet.empty?
249
- UserData do
250
- Fn__Base64 (<<-EOS).undent
251
- #!/bin/bash
252
- #{user_data}
253
- EOS
254
- end unless user_data.empty?
264
+ UserData user_data unless user_data.empty?
255
265
  WeightedCapacity weighted if args.key? :weighted
256
266
  }
257
267
  end
@@ -126,3 +126,37 @@ def _ecs_deployment(args)
126
126
  MinimumHealthyPercent args[:min]
127
127
  }
128
128
  end
129
+
130
+ def _ecs_placement_definition(args)
131
+ return "" unless args.key? :placement
132
+
133
+ placement = args[:placement]
134
+ type = _valid_values(placement[:type], %w( distinctInstance memberOf), "distinctInstance")
135
+ expression = placement[:expression] || ""
136
+
137
+ _{
138
+ Type type
139
+ Expression expression unless placement.empty?
140
+ }
141
+ end
142
+
143
+ def _ecs_placement_service(args)
144
+ return "" unless args.key? :placement
145
+
146
+ placement = args[:placement]
147
+ type = _valid_values(placement[:type], %w( random spread binpack ), "random")
148
+ field =
149
+ case type
150
+ when "binpack"
151
+ _valid_values(args[:field], %w( cpu memory ), "cpu")
152
+ when "spread"
153
+ args[:field] || ""
154
+ else
155
+ ""
156
+ end
157
+
158
+ _{
159
+ Type type
160
+ Field field unless field.empty?
161
+ }
162
+ end