Skip to content

Commit

Permalink
fix(ecs): rename capacity adding methods (#1715)
Browse files Browse the repository at this point in the history
This is consistent with the new naming for EKS.

BREAKING CHANGE: Rename 'addDefaultAutoScalingGroupCapacity' =>
'addCapacity', 'addAutoScalingGroupCapacity' => 'addAutoScalingGroup'.
  • Loading branch information
rix0rrr authored Feb 11, 2019
1 parent 5773bdf commit e3738ac
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 29 deletions.
8 changes: 4 additions & 4 deletions packages/@aws-cdk/aws-ecs/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class Cluster extends cdk.Construct implements ICluster {
*
* Returns the AutoScalingGroup so you can add autoscaling settings to it.
*/
public addDefaultAutoScalingGroupCapacity(id: string, options: AddDefaultAutoScalingGroupOptions): autoscaling.AutoScalingGroup {
public addCapacity(id: string, options: AddCapacityOptions): autoscaling.AutoScalingGroup {
const autoScalingGroup = new autoscaling.AutoScalingGroup(this, id, {
...options,
vpc: this.vpc,
Expand All @@ -83,15 +83,15 @@ export class Cluster extends cdk.Construct implements ICluster {
instanceType: options.instanceType,
});

this.addAutoScalingGroupCapacity(autoScalingGroup, options);
this.addAutoScalingGroup(autoScalingGroup, options);

return autoScalingGroup;
}

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

Expand Down Expand Up @@ -373,7 +373,7 @@ export interface AddAutoScalingGroupCapacityOptions {
/**
* Properties for adding autoScalingGroup
*/
export interface AddDefaultAutoScalingGroupOptions extends AddAutoScalingGroupCapacityOptions, autoscaling.CommonAutoScalingGroupProps {
export interface AddCapacityOptions extends AddAutoScalingGroupCapacityOptions, autoscaling.CommonAutoScalingGroupProps {
/**
* The type of EC2 instance to launch into your Autoscaling Group
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-ecs/test/ec2/integ.event-task.lit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class EventStack extends cdk.Stack {
const vpc = new ec2.VpcNetwork(this, 'Vpc', { maxAZs: 1 });

const cluster = new ecs.Cluster(this, 'EcsCluster', { vpc });
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', {
cluster.addCapacity('DefaultAutoScalingGroup', {
instanceType: new ec2.InstanceType('t2.micro')
});

Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-awsvpc-nw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const stack = new cdk.Stack(app, 'aws-ecs-integ');
const vpc = new ec2.VpcNetwork(stack, 'Vpc', { maxAZs: 2 });

const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', {
cluster.addCapacity('DefaultAutoScalingGroup', {
instanceType: new ec2.InstanceType('t2.micro')
});

Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-bridge-nw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const stack = new cdk.Stack(app, 'aws-ecs-integ-ecs');
const vpc = new ec2.VpcNetwork(stack, 'Vpc', { maxAZs: 2 });

const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', {
cluster.addCapacity('DefaultAutoScalingGroup', {
instanceType: new ec2.InstanceType('t2.micro')
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export = {
const stack = new cdk.Stack();
const vpc = new ec2.VpcNetwork(stack, 'Vpc', { maxAZs: 1 });
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', {
cluster.addCapacity('DefaultAutoScalingGroup', {
instanceType: new ec2.InstanceType('t2.micro')
});

Expand Down
32 changes: 16 additions & 16 deletions packages/@aws-cdk/aws-ecs/test/ec2/test.ec2-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export = {
const stack = new cdk.Stack();
const vpc = new ec2.VpcNetwork(stack, 'MyVpc', {});
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
cluster.addCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef');

taskDefinition.addContainer("web", {
Expand Down Expand Up @@ -54,7 +54,7 @@ export = {
const stack = new cdk.Stack();
const vpc = new ec2.VpcNetwork(stack, 'MyVpc', {});
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
cluster.addCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef');
taskDefinition.addContainer('BaseContainer', {
image: ecs.ContainerImage.fromDockerHub('test'),
Expand All @@ -79,7 +79,7 @@ export = {
const stack = new cdk.Stack();
const vpc = new ec2.VpcNetwork(stack, 'MyVpc', {});
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
cluster.addCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef');
taskDefinition.addContainer('BaseContainer', {
image: ecs.ContainerImage.fromDockerHub('test'),
Expand Down Expand Up @@ -124,7 +124,7 @@ export = {
const stack = new cdk.Stack();
const vpc = new ec2.VpcNetwork(stack, 'MyVpc', {});
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
cluster.addCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef');

taskDefinition.addContainer("web", {
Expand Down Expand Up @@ -152,7 +152,7 @@ export = {
const stack = new cdk.Stack();
const vpc = new ec2.VpcNetwork(stack, 'MyVpc', {});
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
cluster.addCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef', {
networkMode: NetworkMode.Bridge
});
Expand Down Expand Up @@ -184,7 +184,7 @@ export = {
const stack = new cdk.Stack();
const vpc = new ec2.VpcNetwork(stack, 'MyVpc', {});
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
cluster.addCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef', {
networkMode: NetworkMode.AwsVpc
});
Expand Down Expand Up @@ -235,7 +235,7 @@ export = {
const stack = new cdk.Stack();
const vpc = new ec2.VpcNetwork(stack, 'MyVpc', {});
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
cluster.addCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef', {
networkMode: NetworkMode.AwsVpc
});
Expand Down Expand Up @@ -263,7 +263,7 @@ export = {
const stack = new cdk.Stack();
const vpc = new ec2.VpcNetwork(stack, 'MyVpc', {});
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
cluster.addCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef');

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

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

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

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

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

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

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

taskDefinition.addContainer("web", {
Expand Down Expand Up @@ -498,7 +498,7 @@ export = {
const stack = new cdk.Stack();
const vpc = new ec2.VpcNetwork(stack, 'VPC');
const cluster = new ecs.Cluster(stack, 'Cluster', { vpc });
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
cluster.addCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'TD', { networkMode: ecs.NetworkMode.Host });
const container = taskDefinition.addContainer('web', {
image: ecs.ContainerImage.fromDockerHub('test'),
Expand Down
8 changes: 4 additions & 4 deletions packages/@aws-cdk/aws-ecs/test/test.ecs-cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export = {
vpc,
});

cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', {
cluster.addCapacity('DefaultAutoScalingGroup', {
instanceType: new ec2.InstanceType('t2.micro')
});

Expand Down Expand Up @@ -164,7 +164,7 @@ export = {
});

// WHEN
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', {
cluster.addCapacity('DefaultAutoScalingGroup', {
instanceType: new ec2.InstanceType('t2.micro')
});

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

const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', {
cluster.addCapacity('DefaultAutoScalingGroup', {
instanceType: new InstanceType("m3.large")
});

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

const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', {
cluster.addCapacity('DefaultAutoScalingGroup', {
instanceType: new ec2.InstanceType('t2.micro'),
desiredCapacity: 3
});
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-ecs/test/test.l3s.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export = {
const stack = new cdk.Stack();
const vpc = new ec2.VpcNetwork(stack, 'VPC');
const cluster = new ecs.Cluster(stack, 'Cluster', { vpc });
cluster.addDefaultAutoScalingGroupCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
cluster.addCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });

// WHEN
new ecs.LoadBalancedEc2Service(stack, 'Service', {
Expand Down

0 comments on commit e3738ac

Please sign in to comment.