ecs_deploy_cli 0.2.2 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c4714117729290e91e7d5869862246b6aee1d023bbeca7681b92620f18dd03e
4
- data.tar.gz: e6ddab9870c19af272723491398afd4ca49bf8f647182270ac71c0c3b08aa578
3
+ metadata.gz: eba7ecf67d569ffb2287bab5ccda1eb17d475fe2548836c1ead5ff0baf9677a5
4
+ data.tar.gz: 8b3315133ecd7c5e4810535d97c564797de3d5265f7b010a24ecafc612156ee4
5
5
  SHA512:
6
- metadata.gz: 7dc1d20820ebf9f6d9c300b8f0f31df44ca256b379d6e84ca10e0c48f120ea566e94a61cb25694462fe03f67ae35b8658e64e0af4d5253ee14a9717c614b2377
7
- data.tar.gz: 903942389ab805b9201c46d55562994648bc8102b5ad6bed62770674cc115f39127d482fa8afd405dde058372413ef684d33e52af6509b4e0d4e4f4eab3b07bd
6
+ metadata.gz: dd116db322654227906aaaf343abb10a60f2602b156ac4e961306d06db6ce8b3c88a005c2bdd7c996a6641977d07bee9ee2b0e4d4c54aeaa2c7f5724f53af58b
7
+ data.tar.gz: 7c25e31633ce3c69e9c95b7f1530df90da0dffe373334df2ac6bcb785cbd34e4a7dbee225556dc85ac42bc17a23d183bf6104219dc555231521998b89607a66d
@@ -26,6 +26,7 @@ end
26
26
 
27
27
  require 'ecs_deploy_cli/version'
28
28
  require 'ecs_deploy_cli/dsl/auto_options'
29
+ require 'ecs_deploy_cli/dsl/cluster'
29
30
  require 'ecs_deploy_cli/dsl/container'
30
31
  require 'ecs_deploy_cli/dsl/task'
31
32
  require 'ecs_deploy_cli/dsl/cron'
@@ -26,6 +26,13 @@ module EcsDeployCli
26
26
  puts "ECS Deploy CLI Version #{EcsDeployCli::VERSION}."
27
27
  end
28
28
 
29
+ desc 'setup', 'Creates the cluster and relative services'
30
+ option :file, default: 'ECSFile'
31
+ def setup
32
+ @parser = load(options[:file])
33
+ runner.setup!
34
+ end
35
+
29
36
  desc 'deploy-scheduled-tasks', 'Updates all scheduled tasks defined in your ECSFile'
30
37
  option :file, default: 'ECSFile'
31
38
  def deploy_scheduled_tasks
@@ -68,9 +75,12 @@ module EcsDeployCli
68
75
 
69
76
  desc 'ssh', 'Connects to ECS instance via SSH'
70
77
  option :file, default: 'ECSFile'
78
+ option :service, default: nil
79
+ option :task, default: nil
71
80
  def ssh
72
81
  @parser = load(options[:file])
73
- runner.ssh
82
+ ssh_options = { family: options[:task], service_name: options[:service] }.delete_if { |_, v| v.nil? }
83
+ runner.ssh(**ssh_options)
74
84
  end
75
85
 
76
86
  private
@@ -0,0 +1,411 @@
1
+ AWSTemplateFormatVersion: '2010-09-09'
2
+ Description: >
3
+ AWS CloudFormation template to create a new VPC
4
+ or use an existing VPC for ECS deployment
5
+ in Create Cluster Wizard. Requires exactly 1
6
+ Instance Types for a Spot Request.
7
+ Parameters:
8
+ EcsClusterName:
9
+ Type: String
10
+ Description: >
11
+ Specifies the ECS Cluster Name with which the resources would be
12
+ associated
13
+ Default: default
14
+ EcsAmiId:
15
+ Type: String
16
+ Description: Specifies the AMI ID for your container instances.
17
+ EcsInstanceType:
18
+ Type: CommaDelimitedList
19
+ Description: >
20
+ Specifies the EC2 instance type for your container instances.
21
+ Defaults to m4.large
22
+ Default: m4.large
23
+ ConstraintDescription: must be a valid EC2 instance type.
24
+ KeyName:
25
+ Type: String
26
+ Description: >
27
+ Optional - Specifies the name of an existing Amazon EC2 key pair
28
+ to enable SSH access to the EC2 instances in your cluster.
29
+ Default: ''
30
+ VpcId:
31
+ Type: String
32
+ Description: >
33
+ Optional - Specifies the ID of an existing VPC in which to launch
34
+ your container instances. If you specify a VPC ID, you must specify a list of
35
+ existing subnets in that VPC. If you do not specify a VPC ID, a new VPC is created
36
+ with atleast 1 subnet.
37
+ Default: ''
38
+ ConstraintDescription: >
39
+ VPC Id must begin with 'vpc-' or leave blank to have a
40
+ new VPC created
41
+ SubnetIds:
42
+ Type: CommaDelimitedList
43
+ Description: >
44
+ Optional - Specifies the Comma separated list of existing VPC Subnet
45
+ Ids where ECS instances will run
46
+ Default: ''
47
+ SecurityGroupId:
48
+ Type: String
49
+ Description: >
50
+ Optional - Specifies the Security Group Id of an existing Security
51
+ Group. Leave blank to have a new Security Group created
52
+ Default: ''
53
+ VpcCidr:
54
+ Type: String
55
+ Description: Optional - Specifies the CIDR Block of VPC
56
+ Default: ''
57
+ SubnetCidr1:
58
+ Type: String
59
+ Description: Specifies the CIDR Block of Subnet 1
60
+ Default: ''
61
+ SubnetCidr2:
62
+ Type: String
63
+ Description: Specifies the CIDR Block of Subnet 2
64
+ Default: ''
65
+ SubnetCidr3:
66
+ Type: String
67
+ Description: Specifies the CIDR Block of Subnet 3
68
+ Default: ''
69
+ AsgMaxSize:
70
+ Type: Number
71
+ Description: >
72
+ Specifies the number of instances to launch and register to the cluster.
73
+ Defaults to 1.
74
+ Default: '1'
75
+ IamRoleInstanceProfile:
76
+ Type: String
77
+ Description: >
78
+ Specifies the Name or the Amazon Resource Name (ARN) of the instance
79
+ profile associated with the IAM role for the instance
80
+ SecurityIngressFromPort:
81
+ Type: Number
82
+ Description: >
83
+ Optional - Specifies the Start of Security Group port to open on
84
+ ECS instances - defaults to port 0
85
+ Default: '0'
86
+ SecurityIngressToPort:
87
+ Type: Number
88
+ Description: >
89
+ Optional - Specifies the End of Security Group port to open on ECS
90
+ instances - defaults to port 65535
91
+ Default: '65535'
92
+ SecurityIngressCidrIp:
93
+ Type: String
94
+ Description: >
95
+ Optional - Specifies the CIDR/IP range for Security Ports - defaults
96
+ to 0.0.0.0/0
97
+ Default: 0.0.0.0/0
98
+ EcsEndpoint:
99
+ Type: String
100
+ Description: >
101
+ Optional - Specifies the ECS Endpoint for the ECS Agent to connect to
102
+ Default: ''
103
+ VpcAvailabilityZones:
104
+ Type: CommaDelimitedList
105
+ Description: >
106
+ Specifies a comma-separated list of 3 VPC Availability Zones for
107
+ the creation of new subnets. These zones must have the available status.
108
+ Default: ''
109
+ RootEbsVolumeSize:
110
+ Type: Number
111
+ Description: >
112
+ Optional - Specifies the Size in GBs of the root EBS volume
113
+ Default: 30
114
+ EbsVolumeSize:
115
+ Type: Number
116
+ Description: >
117
+ Optional - Specifies the Size in GBs of the data storage EBS volume used by the Docker in the AL1 ECS-optimized AMI
118
+ Default: 22
119
+ EbsVolumeType:
120
+ Type: String
121
+ Description: Optional - Specifies the Type of (Amazon EBS) volume
122
+ Default: ''
123
+ AllowedValues:
124
+ - ''
125
+ - standard
126
+ - io1
127
+ - gp2
128
+ - sc1
129
+ - st1
130
+ ConstraintDescription: Must be a valid EC2 volume type.
131
+ RootDeviceName:
132
+ Type: String
133
+ Description: Optional - Specifies the device mapping for the root EBS volume.
134
+ Default: /dev/xvda
135
+ DeviceName:
136
+ Type: String
137
+ Description: Optional - Specifies the device mapping for the EBS volume used for data storage. Only applicable to AL1.
138
+ UseSpot:
139
+ Type: String
140
+ Default: 'false'
141
+ IamSpotFleetRoleArn:
142
+ Type: String
143
+ Default: ''
144
+ SpotPrice:
145
+ Type: String
146
+ Default: ''
147
+ SpotAllocationStrategy:
148
+ Type: String
149
+ Default: 'diversified'
150
+ AllowedValues:
151
+ - 'lowestPrice'
152
+ - 'diversified'
153
+ UserData:
154
+ Type: String
155
+ IsWindows:
156
+ Type: String
157
+ Default: 'false'
158
+ ConfigureRootVolume:
159
+ Type: String
160
+ Description: Optional - Specifies if there should be customization of the root volume
161
+ Default: 'false'
162
+ ConfigureDataVolume:
163
+ Type: String
164
+ Description: Optional - Specifies if there should be customization of the data volume
165
+ Default: 'true'
166
+ AutoAssignPublicIp:
167
+ Type: String
168
+ Default: 'INHERIT'
169
+ Conditions:
170
+ CreateEC2LCWithKeyPair:
171
+ !Not [!Equals [!Ref KeyName, '']]
172
+ SetEndpointToECSAgent:
173
+ !Not [!Equals [!Ref EcsEndpoint, '']]
174
+ CreateNewSecurityGroup:
175
+ !Equals [!Ref SecurityGroupId, '']
176
+ CreateNewVpc:
177
+ !Equals [!Ref VpcId, '']
178
+ CreateSubnet1: !And
179
+ - !Not [!Equals [!Ref SubnetCidr1, '']]
180
+ - !Condition CreateNewVpc
181
+ CreateSubnet2: !And
182
+ - !Not [!Equals [!Ref SubnetCidr2, '']]
183
+ - !Condition CreateSubnet1
184
+ CreateSubnet3: !And
185
+ - !Not [!Equals [!Ref SubnetCidr3, '']]
186
+ - !Condition CreateSubnet2
187
+ CreateWithSpot: !Equals [!Ref UseSpot, 'true']
188
+ CreateWithASG: !Not [!Condition CreateWithSpot]
189
+ CreateWithSpotPrice: !Not [!Equals [!Ref SpotPrice, '']]
190
+ IsConfiguringRootVolume: !Equals [!Ref ConfigureRootVolume, 'true']
191
+ IsConfiguringDataVolume: !Equals [!Ref ConfigureDataVolume, 'true']
192
+ IsInheritPublicIp: !Equals [!Ref AutoAssignPublicIp, 'INHERIT']
193
+ Resources:
194
+ Vpc:
195
+ Condition: CreateSubnet1
196
+ Type: AWS::EC2::VPC
197
+ Properties:
198
+ CidrBlock: !Ref VpcCidr
199
+ EnableDnsSupport: true
200
+ EnableDnsHostnames: true
201
+ PubSubnetAz1:
202
+ Condition: CreateSubnet1
203
+ Type: AWS::EC2::Subnet
204
+ Properties:
205
+ VpcId: !Ref Vpc
206
+ CidrBlock: !Ref SubnetCidr1
207
+ AvailabilityZone: !Select [ 0, !Ref VpcAvailabilityZones ]
208
+ MapPublicIpOnLaunch: true
209
+ PubSubnetAz2:
210
+ Condition: CreateSubnet2
211
+ Type: AWS::EC2::Subnet
212
+ Properties:
213
+ VpcId: !Ref Vpc
214
+ CidrBlock: !Ref SubnetCidr2
215
+ AvailabilityZone: !Select [ 1, !Ref VpcAvailabilityZones ]
216
+ MapPublicIpOnLaunch: true
217
+ PubSubnetAz3:
218
+ Condition: CreateSubnet3
219
+ Type: AWS::EC2::Subnet
220
+ Properties:
221
+ VpcId: !Ref Vpc
222
+ CidrBlock: !Ref SubnetCidr3
223
+ AvailabilityZone: !Select [ 2, !Ref VpcAvailabilityZones ]
224
+ MapPublicIpOnLaunch: true
225
+ InternetGateway:
226
+ Condition: CreateSubnet1
227
+ Type: AWS::EC2::InternetGateway
228
+ AttachGateway:
229
+ Condition: CreateSubnet1
230
+ Type: AWS::EC2::VPCGatewayAttachment
231
+ Properties:
232
+ VpcId: !Ref Vpc
233
+ InternetGatewayId: !Ref InternetGateway
234
+ RouteViaIgw:
235
+ Condition: CreateSubnet1
236
+ Type: AWS::EC2::RouteTable
237
+ Properties:
238
+ VpcId: !Ref Vpc
239
+ PublicRouteViaIgw:
240
+ Condition: CreateSubnet1
241
+ Type: AWS::EC2::Route
242
+ DependsOn: AttachGateway
243
+ Properties:
244
+ RouteTableId: !Ref RouteViaIgw
245
+ DestinationCidrBlock: 0.0.0.0/0
246
+ GatewayId: !Ref InternetGateway
247
+ PubSubnet1RouteTableAssociation:
248
+ Condition: CreateSubnet1
249
+ Type: AWS::EC2::SubnetRouteTableAssociation
250
+ Properties:
251
+ SubnetId: !Ref PubSubnetAz1
252
+ RouteTableId: !Ref RouteViaIgw
253
+ PubSubnet2RouteTableAssociation:
254
+ Condition: CreateSubnet2
255
+ Type: AWS::EC2::SubnetRouteTableAssociation
256
+ Properties:
257
+ SubnetId: !Ref PubSubnetAz2
258
+ RouteTableId: !Ref RouteViaIgw
259
+ PubSubnet3RouteTableAssociation:
260
+ Condition: CreateSubnet3
261
+ Type: AWS::EC2::SubnetRouteTableAssociation
262
+ Properties:
263
+ SubnetId: !Ref PubSubnetAz3
264
+ RouteTableId: !Ref RouteViaIgw
265
+ EcsSecurityGroup:
266
+ Condition: CreateNewSecurityGroup
267
+ Type: AWS::EC2::SecurityGroup
268
+ Properties:
269
+ GroupDescription: ECS Allowed Ports
270
+ VpcId: !If [ CreateSubnet1, !Ref Vpc, !Ref VpcId ]
271
+ SecurityGroupIngress:
272
+ IpProtocol: tcp
273
+ FromPort: !Ref SecurityIngressFromPort
274
+ ToPort: !Ref SecurityIngressToPort
275
+ CidrIp: !Ref SecurityIngressCidrIp
276
+
277
+ ## TODO: FINISH
278
+ # ALBSecurityGroup:
279
+ # Condition: CreateNewLoadBalancer
280
+ # Type: AWS::EC2::SecurityGroup
281
+ # Properties:
282
+ # GroupDescription: ECS Allowed Ports
283
+ # VpcId: !If [ CreateSubnet1, !Ref Vpc, !Ref VpcId ]
284
+ # SecurityGroupIngress:
285
+ # IpProtocol: tcp
286
+ # FromPort: !Ref SecurityIngressFromPort
287
+ # ToPort: !Ref SecurityIngressToPort
288
+ # CidrIp: !Ref SecurityIngressCidrIp
289
+
290
+ # EcsLoadBalancer:
291
+ # Condition: CreateNewLoadBalancer
292
+ # Type: AWS::ElasticLoadBalancing::LoadBalancer
293
+ # Properties:
294
+ # LoadBalancerName: !Ref LoadBalancer
295
+ # AvailabilityZones:
296
+ # - !Select [ 0, !Ref VpcAvailabilityZones ]
297
+ # - !Select [ 1, !Ref VpcAvailabilityZones ]
298
+ # - !Select [ 2, !Ref VpcAvailabilityZones ]
299
+ # SecurityGroups:
300
+ # - !Select [ 0, !Ref VpcAvailabilityZones ]
301
+ # Subnets:
302
+ # -
303
+ ## /TODO: FINISH
304
+
305
+ EcsInstanceLc:
306
+ Type: AWS::AutoScaling::LaunchConfiguration
307
+ Condition: CreateWithASG
308
+ Properties:
309
+ ImageId: !Ref EcsAmiId
310
+ InstanceType: !Select [ 0, !Ref EcsInstanceType ]
311
+ AssociatePublicIpAddress: !If [ IsInheritPublicIp, !Ref "AWS::NoValue", !Ref AutoAssignPublicIp ]
312
+ IamInstanceProfile: !Ref IamRoleInstanceProfile
313
+ KeyName: !If [ CreateEC2LCWithKeyPair, !Ref KeyName, !Ref "AWS::NoValue" ]
314
+ SecurityGroups: [ !If [ CreateNewSecurityGroup, !Ref EcsSecurityGroup, !Ref SecurityGroupId ] ]
315
+ BlockDeviceMappings:
316
+ - !If
317
+ - IsConfiguringRootVolume
318
+ - DeviceName: !Ref RootDeviceName
319
+ Ebs:
320
+ VolumeSize: !Ref RootEbsVolumeSize
321
+ VolumeType: !Ref EbsVolumeType
322
+ - !Ref AWS::NoValue
323
+ - !If
324
+ - IsConfiguringDataVolume
325
+ - DeviceName: !Ref DeviceName
326
+ Ebs:
327
+ VolumeSize: !Ref EbsVolumeSize
328
+ VolumeType: !Ref EbsVolumeType
329
+ - !Ref AWS::NoValue
330
+ UserData:
331
+ Fn::Base64: !Ref UserData
332
+ EcsInstanceAsg:
333
+ Type: AWS::AutoScaling::AutoScalingGroup
334
+ Condition: CreateWithASG
335
+ Properties:
336
+ VPCZoneIdentifier: !If
337
+ - CreateSubnet1
338
+ - !If
339
+ - CreateSubnet2
340
+ - !If
341
+ - CreateSubnet3
342
+ - [ !Sub "${PubSubnetAz1}, ${PubSubnetAz2}, ${PubSubnetAz3}" ]
343
+ - [ !Sub "${PubSubnetAz1}, ${PubSubnetAz2}" ]
344
+ - [ !Sub "${PubSubnetAz1}" ]
345
+ - !Ref SubnetIds
346
+ LaunchConfigurationName: !Ref EcsInstanceLc
347
+ MinSize: '0'
348
+ MaxSize: !Ref AsgMaxSize
349
+ DesiredCapacity: !Ref AsgMaxSize
350
+ Tags:
351
+ -
352
+ Key: Name
353
+ Value: !Sub "ECS Instance - ${AWS::StackName}"
354
+ PropagateAtLaunch: true
355
+ -
356
+ Key: Description
357
+ Value: "This instance is the part of the Auto Scaling group which was created through ECS Console"
358
+ PropagateAtLaunch: true
359
+ EcsSpotFleet:
360
+ Condition: CreateWithSpot
361
+ Type: AWS::EC2::SpotFleet
362
+ Properties:
363
+ SpotFleetRequestConfigData:
364
+ AllocationStrategy: !Ref SpotAllocationStrategy
365
+ IamFleetRole: !Ref IamSpotFleetRoleArn
366
+ TargetCapacity: !Ref AsgMaxSize
367
+ SpotPrice: !If [ CreateWithSpotPrice, !Ref SpotPrice, !Ref 'AWS::NoValue' ]
368
+ TerminateInstancesWithExpiration: true
369
+ LaunchSpecifications:
370
+ -
371
+ IamInstanceProfile:
372
+ Arn: !Ref IamRoleInstanceProfile
373
+ ImageId: !Ref EcsAmiId
374
+ InstanceType: !Select [ 0, !Ref EcsInstanceType ]
375
+ KeyName: !If [ CreateEC2LCWithKeyPair, !Ref KeyName, !Ref "AWS::NoValue" ]
376
+ Monitoring:
377
+ Enabled: true
378
+ SecurityGroups:
379
+ - GroupId: !If [ CreateNewSecurityGroup, !Ref EcsSecurityGroup, !Ref SecurityGroupId ]
380
+ SubnetId: !If
381
+ - CreateSubnet1
382
+ - !If
383
+ - CreateSubnet2
384
+ - !If
385
+ - CreateSubnet3
386
+ - !Join [ "," , [ !Ref PubSubnetAz1, !Ref PubSubnetAz2, !Ref PubSubnetAz3 ] ]
387
+ - !Join [ "," , [ !Ref PubSubnetAz1, !Ref PubSubnetAz2 ] ]
388
+ - !Ref PubSubnetAz1
389
+ - !Join [ "," , !Ref SubnetIds ]
390
+ BlockDeviceMappings:
391
+ - DeviceName: !Ref DeviceName
392
+ Ebs:
393
+ VolumeSize: !Ref EbsVolumeSize
394
+ VolumeType: !Ref EbsVolumeType
395
+ UserData:
396
+ Fn::Base64: !Ref UserData
397
+ Outputs:
398
+ EcsInstanceAsgName:
399
+ Condition: CreateWithASG
400
+ Description: Auto Scaling Group Name for ECS Instances
401
+ Value: !Ref EcsInstanceAsg
402
+ EcsSpotFleetRequestId:
403
+ Condition: CreateWithSpot
404
+ Description: Spot Fleet Request for ECS Instances
405
+ Value: !Ref EcsSpotFleet
406
+ UsedByECSCreateCluster:
407
+ Description: Flag used by ECS Create Cluster Wizard
408
+ Value: 'true'
409
+ TemplateVersion:
410
+ Description: The version of the template used by Create Cluster Wizard
411
+ Value: '2.0.0'