Skip to content

Commit e3738ac

Browse files
authored
fix(ecs): rename capacity adding methods (#1715)
This is consistent with the new naming for EKS. BREAKING CHANGE: Rename 'addDefaultAutoScalingGroupCapacity' => 'addCapacity', 'addAutoScalingGroupCapacity' => 'addAutoScalingGroup'.
1 parent 5773bdf commit e3738ac

8 files changed

+29
-29
lines changed

packages/@aws-cdk/aws-ecs/lib/cluster.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class Cluster extends cdk.Construct implements ICluster {
7474
*
7575
* Returns the AutoScalingGroup so you can add autoscaling settings to it.
7676
*/
77-
public addDefaultAutoScalingGroupCapacity(id: string, options: AddDefaultAutoScalingGroupOptions): autoscaling.AutoScalingGroup {
77+
public addCapacity(id: string, options: AddCapacityOptions): autoscaling.AutoScalingGroup {
7878
const autoScalingGroup = new autoscaling.AutoScalingGroup(this, id, {
7979
...options,
8080
vpc: this.vpc,
@@ -83,15 +83,15 @@ export class Cluster extends cdk.Construct implements ICluster {
8383
instanceType: options.instanceType,
8484
});
8585

86-
this.addAutoScalingGroupCapacity(autoScalingGroup, options);
86+
this.addAutoScalingGroup(autoScalingGroup, options);
8787

8888
return autoScalingGroup;
8989
}
9090

9191
/**
9292
* Add compute capacity to this ECS cluster in the form of an AutoScalingGroup
9393
*/
94-
public addAutoScalingGroupCapacity(autoScalingGroup: autoscaling.AutoScalingGroup, options: AddAutoScalingGroupCapacityOptions = {}) {
94+
public addAutoScalingGroup(autoScalingGroup: autoscaling.AutoScalingGroup, options: AddAutoScalingGroupCapacityOptions = {}) {
9595
this._hasEc2Capacity = true;
9696
this.connections.connections.addSecurityGroup(...autoScalingGroup.connections.securityGroups);
9797

@@ -373,7 +373,7 @@ export interface AddAutoScalingGroupCapacityOptions {
373373
/**
374374
* Properties for adding autoScalingGroup
375375
*/
376-
export interface AddDefaultAutoScalingGroupOptions extends AddAutoScalingGroupCapacityOptions, autoscaling.CommonAutoScalingGroupProps {
376+
export interface AddCapacityOptions extends AddAutoScalingGroupCapacityOptions, autoscaling.CommonAutoScalingGroupProps {
377377
/**
378378
* The type of EC2 instance to launch into your Autoscaling Group
379379
*/

packages/@aws-cdk/aws-ecs/test/ec2/integ.event-task.lit.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class EventStack extends cdk.Stack {
1212
const vpc = new ec2.VpcNetwork(this, 'Vpc', { maxAZs: 1 });
1313

1414
const cluster = new ecs.Cluster(this, 'EcsCluster', { vpc });
15-
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', {
15+
cluster.addCapacity('DefaultAutoScalingGroup', {
1616
instanceType: new ec2.InstanceType('t2.micro')
1717
});
1818

packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-awsvpc-nw.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const stack = new cdk.Stack(app, 'aws-ecs-integ');
1010
const vpc = new ec2.VpcNetwork(stack, 'Vpc', { maxAZs: 2 });
1111

1212
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
13-
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', {
13+
cluster.addCapacity('DefaultAutoScalingGroup', {
1414
instanceType: new ec2.InstanceType('t2.micro')
1515
});
1616

packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-bridge-nw.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const stack = new cdk.Stack(app, 'aws-ecs-integ-ecs');
1010
const vpc = new ec2.VpcNetwork(stack, 'Vpc', { maxAZs: 2 });
1111

1212
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
13-
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', {
13+
cluster.addCapacity('DefaultAutoScalingGroup', {
1414
instanceType: new ec2.InstanceType('t2.micro')
1515
});
1616

packages/@aws-cdk/aws-ecs/test/ec2/test.ec2-event-rule-target.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export = {
1111
const stack = new cdk.Stack();
1212
const vpc = new ec2.VpcNetwork(stack, 'Vpc', { maxAZs: 1 });
1313
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
14-
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', {
14+
cluster.addCapacity('DefaultAutoScalingGroup', {
1515
instanceType: new ec2.InstanceType('t2.micro')
1616
});
1717

packages/@aws-cdk/aws-ecs/test/ec2/test.ec2-service.ts

+16-16
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export = {
1313
const stack = new cdk.Stack();
1414
const vpc = new ec2.VpcNetwork(stack, 'MyVpc', {});
1515
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
16-
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
16+
cluster.addCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
1717
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef');
1818

1919
taskDefinition.addContainer("web", {
@@ -54,7 +54,7 @@ export = {
5454
const stack = new cdk.Stack();
5555
const vpc = new ec2.VpcNetwork(stack, 'MyVpc', {});
5656
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
57-
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
57+
cluster.addCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
5858
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef');
5959
taskDefinition.addContainer('BaseContainer', {
6060
image: ecs.ContainerImage.fromDockerHub('test'),
@@ -79,7 +79,7 @@ export = {
7979
const stack = new cdk.Stack();
8080
const vpc = new ec2.VpcNetwork(stack, 'MyVpc', {});
8181
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
82-
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
82+
cluster.addCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
8383
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef');
8484
taskDefinition.addContainer('BaseContainer', {
8585
image: ecs.ContainerImage.fromDockerHub('test'),
@@ -124,7 +124,7 @@ export = {
124124
const stack = new cdk.Stack();
125125
const vpc = new ec2.VpcNetwork(stack, 'MyVpc', {});
126126
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
127-
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
127+
cluster.addCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
128128
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef');
129129

130130
taskDefinition.addContainer("web", {
@@ -152,7 +152,7 @@ export = {
152152
const stack = new cdk.Stack();
153153
const vpc = new ec2.VpcNetwork(stack, 'MyVpc', {});
154154
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
155-
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
155+
cluster.addCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
156156
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef', {
157157
networkMode: NetworkMode.Bridge
158158
});
@@ -184,7 +184,7 @@ export = {
184184
const stack = new cdk.Stack();
185185
const vpc = new ec2.VpcNetwork(stack, 'MyVpc', {});
186186
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
187-
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
187+
cluster.addCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
188188
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef', {
189189
networkMode: NetworkMode.AwsVpc
190190
});
@@ -235,7 +235,7 @@ export = {
235235
const stack = new cdk.Stack();
236236
const vpc = new ec2.VpcNetwork(stack, 'MyVpc', {});
237237
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
238-
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
238+
cluster.addCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
239239
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef', {
240240
networkMode: NetworkMode.AwsVpc
241241
});
@@ -263,7 +263,7 @@ export = {
263263
const stack = new cdk.Stack();
264264
const vpc = new ec2.VpcNetwork(stack, 'MyVpc', {});
265265
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
266-
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
266+
cluster.addCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
267267
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef');
268268

269269
taskDefinition.addContainer("web", {
@@ -292,7 +292,7 @@ export = {
292292
const stack = new cdk.Stack();
293293
const vpc = new ec2.VpcNetwork(stack, 'MyVpc', {});
294294
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
295-
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
295+
cluster.addCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
296296
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef');
297297

298298
taskDefinition.addContainer("web", {
@@ -323,7 +323,7 @@ export = {
323323
const stack = new cdk.Stack();
324324
const vpc = new ec2.VpcNetwork(stack, 'MyVpc', {});
325325
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
326-
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
326+
cluster.addCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
327327
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef');
328328

329329
taskDefinition.addContainer("web", {
@@ -354,7 +354,7 @@ export = {
354354
const stack = new cdk.Stack();
355355
const vpc = new ec2.VpcNetwork(stack, 'MyVpc', {});
356356
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
357-
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
357+
cluster.addCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
358358
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef');
359359

360360
taskDefinition.addContainer("web", {
@@ -381,7 +381,7 @@ export = {
381381
const stack = new cdk.Stack();
382382
const vpc = new ec2.VpcNetwork(stack, 'MyVpc');
383383
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
384-
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
384+
cluster.addCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
385385
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef');
386386

387387
taskDefinition.addContainer("web", {
@@ -411,7 +411,7 @@ export = {
411411
const stack = new cdk.Stack();
412412
const vpc = new ec2.VpcNetwork(stack, 'MyVpc');
413413
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
414-
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
414+
cluster.addCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
415415
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef');
416416

417417
taskDefinition.addContainer("web", {
@@ -438,7 +438,7 @@ export = {
438438
const stack = new cdk.Stack();
439439
const vpc = new ec2.VpcNetwork(stack, 'MyVpc', {});
440440
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
441-
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
441+
cluster.addCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
442442
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef');
443443

444444
taskDefinition.addContainer("web", {
@@ -469,7 +469,7 @@ export = {
469469
const stack = new cdk.Stack();
470470
const vpc = new ec2.VpcNetwork(stack, 'MyVpc', {});
471471
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
472-
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
472+
cluster.addCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
473473
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef');
474474

475475
taskDefinition.addContainer("web", {
@@ -498,7 +498,7 @@ export = {
498498
const stack = new cdk.Stack();
499499
const vpc = new ec2.VpcNetwork(stack, 'VPC');
500500
const cluster = new ecs.Cluster(stack, 'Cluster', { vpc });
501-
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
501+
cluster.addCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
502502
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'TD', { networkMode: ecs.NetworkMode.Host });
503503
const container = taskDefinition.addContainer('web', {
504504
image: ecs.ContainerImage.fromDockerHub('test'),

packages/@aws-cdk/aws-ecs/test/test.ecs-cluster.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export = {
1515
vpc,
1616
});
1717

18-
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', {
18+
cluster.addCapacity('DefaultAutoScalingGroup', {
1919
instanceType: new ec2.InstanceType('t2.micro')
2020
});
2121

@@ -164,7 +164,7 @@ export = {
164164
});
165165

166166
// WHEN
167-
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', {
167+
cluster.addCapacity('DefaultAutoScalingGroup', {
168168
instanceType: new ec2.InstanceType('t2.micro')
169169
});
170170

@@ -188,7 +188,7 @@ export = {
188188
const vpc = new ec2.VpcNetwork(stack, 'MyVpc', {});
189189

190190
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
191-
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', {
191+
cluster.addCapacity('DefaultAutoScalingGroup', {
192192
instanceType: new InstanceType("m3.large")
193193
});
194194

@@ -206,7 +206,7 @@ export = {
206206
const vpc = new ec2.VpcNetwork(stack, 'MyVpc', {});
207207

208208
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
209-
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', {
209+
cluster.addCapacity('DefaultAutoScalingGroup', {
210210
instanceType: new ec2.InstanceType('t2.micro'),
211211
desiredCapacity: 3
212212
});

packages/@aws-cdk/aws-ecs/test/test.l3s.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export = {
1212
const stack = new cdk.Stack();
1313
const vpc = new ec2.VpcNetwork(stack, 'VPC');
1414
const cluster = new ecs.Cluster(stack, 'Cluster', { vpc });
15-
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
15+
cluster.addCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
1616

1717
// WHEN
1818
new ecs.LoadBalancedEc2Service(stack, 'Service', {

0 commit comments

Comments
 (0)