Skip to content

Commit

Permalink
fix: make capitalization of Ip/Az consistent (#3202)
Browse files Browse the repository at this point in the history
Fix short miscapitalizations of an abbreviation with a lowercase suffix;
they would not get properly translated into Python.

BREAKING CHANGE: in all identifiers, renamed `IPv4` => `Ipv4`, `IPv6` =>
`Ipv6`, `AZs` => `Azs`.
  • Loading branch information
rix0rrr authored Jul 5, 2019
1 parent 6a79180 commit d60d673
Show file tree
Hide file tree
Showing 51 changed files with 93 additions and 87 deletions.
8 changes: 7 additions & 1 deletion allowed-breaking-changes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
removed:@aws-cdk/aws-ec2.Port.toRuleJSON
change-return-type:@aws-cdk/aws-codebuild.PipelineProject.addSecondaryArtifact
change-return-type:@aws-cdk/aws-codebuild.Project.addSecondaryArtifact

removed:@aws-cdk/aws-ec2.Connections.allowFromAnyIPv4
removed:@aws-cdk/aws-ec2.Connections.allowToAnyIPv4
removed:@aws-cdk/aws-ec2.VpcProps.maxAZs
removed:@aws-cdk/aws-elasticloadbalancingv2.ApplicationLoadBalancer.metricIPv6ProcessedBytes
removed:@aws-cdk/aws-elasticloadbalancingv2.ApplicationLoadBalancer.metricIPv6RequestCount
removed:@aws-cdk/aws-elasticloadbalancingv2.ApplicationTargetGroup.metricIPv6RequestCount
removed:@aws-cdk/core.Fn.getAZs
20 changes: 10 additions & 10 deletions design/aws-ecs/aws-ecs-autoscaling-queue-worker.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# AWS ECS - L3 Construct for Autoscaling ECS/Fargate Service that Processes Items in a SQS Queue

To address issue [#2396](https://github.com/awslabs/aws-cdk/issues/2396), the AWS ECS CDK construct library should provide a way for customers to create a queue processing service (an AWS ECS/Fargate service that processes items from an sqs queue). This would mean adding new ECS CDK constructs `QueueProcessingEc2Service` and `QueueProcessingFargateService`, that would take in the necessary properties required to create a task definition, an SQS queue as well as an ECS/Fargate service and enable autoscaling for the service based on cpu usage and the SQS queue's approximateNumberOfMessagesVisible metric.
To address issue [#2396](https://github.com/awslabs/aws-cdk/issues/2396), the AWS ECS CDK construct library should provide a way for customers to create a queue processing service (an AWS ECS/Fargate service that processes items from an sqs queue). This would mean adding new ECS CDK constructs `QueueProcessingEc2Service` and `QueueProcessingFargateService`, that would take in the necessary properties required to create a task definition, an SQS queue as well as an ECS/Fargate service and enable autoscaling for the service based on cpu usage and the SQS queue's approximateNumberOfMessagesVisible metric.

## General approach

Expand All @@ -9,7 +9,7 @@ The new `ecs.QueueProcessingServiceBase`, `ecs.QueueProcessingEc2Service` and `e
* QueueProcessingEc2Service
* QueueProcessingFargateService

A `QueueProcessingService` will create a task definition with the specified container (on both EC2 and Fargate). An AWS SQS `Queue` will be created and autoscaling of the ECS Service will be dependent on both CPU as well as the SQS queue's `ApproximateNumberOfMessagesVisible` metric.
A `QueueProcessingService` will create a task definition with the specified container (on both EC2 and Fargate). An AWS SQS `Queue` will be created and autoscaling of the ECS Service will be dependent on both CPU as well as the SQS queue's `ApproximateNumberOfMessagesVisible` metric.

The `QueueProcessingService` constructs (for EC2 and Fargate) will use the following existing constructs:

Expand All @@ -24,7 +24,7 @@ Given the above, we should make the following changes to support queue processin
2. Create `QueueProcessingEc2ServiceProps` interface and `QueueProcessingEc2Service` construct
3. Create `QueueProcessingFargateServiceProps` interface and `QueueProcessingFargateService` construct

### Part 1: Create `QueueProcessingServiceBaseProps` interface and `QueueProcessingServiceBase` construct
### Part 1: Create `QueueProcessingServiceBaseProps` interface and `QueueProcessingServiceBase` construct

The `QueueProcessingServiceBaseProps` interface will contain common properties used to construct both the QueueProcessingEc2Service and the QueueProcessingFargateService:

Expand Down Expand Up @@ -93,14 +93,14 @@ export interface QueueProcessingServiceBaseProps {
*
* Maps a range of metric values to a particular scaling behavior.
* https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-scaling-simple-step.html
*
*
* @default [{ upper: 0, change: -1 },{ lower: 100, change: +1 },{ lower: 500, change: +5 }]
*/
readonly scalingSteps: autoScaling.ScalingInterval[];
}
```

### Part 2: Create `QueueProcessingEc2ServiceProps` interface and `QueueProcessingEc2Service` construct
### Part 2: Create `QueueProcessingEc2ServiceProps` interface and `QueueProcessingEc2Service` construct

The `QueueProcessingEc2ServiceProps` interface will contain properties to construct the Ec2TaskDefinition, SQSQueue and Ec2Service:

Expand Down Expand Up @@ -147,12 +147,12 @@ export interface QueueProcessingEc2ServiceProps {
An example use case:
```ts
// Create the vpc and cluster used by the queue processing service
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAZs: 1 });
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAzs: 1 });
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
cluster.addCapacity('DefaultAutoScalingGroup', {
instanceType: new ec2.InstanceType('t2.micro')
});
const queue = new sqs.Queue(stack, 'ProcessingQueue', {
const queue = new sqs.Queue(stack, 'ProcessingQueue', {
QueueName: 'EcsEventQueue'
});

Expand All @@ -168,7 +168,7 @@ new QueueProcessingEc2Service(stack, 'QueueProcessingEc2Service', {
});
```

### Part 3: Create `QueueProcessingFargateServiceProps` interface and `QueueProcessingFargateService` construct
### Part 3: Create `QueueProcessingFargateServiceProps` interface and `QueueProcessingFargateService` construct

The `QueueProcessingFargateServiceProps` interface will contain properties to construct the FargateTaskDefinition, SQSQueue and FargateService:

Expand Down Expand Up @@ -219,9 +219,9 @@ export interface QueueProcessingFargateServiceProps {
An example use case:
```ts
// Create the vpc and cluster used by the queue processing service
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAZs: 2 });
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAzs: 2 });
const cluster = new ecs.Cluster(stack, 'FargateCluster', { vpc });
const queue = new sqs.Queue(stack, 'ProcessingQueue', {
const queue = new sqs.Queue(stack, 'ProcessingQueue', {
QueueName: 'FargateEventQueue'
});

Expand Down
12 changes: 6 additions & 6 deletions design/aws-ecs/aws-ecs-scheduled-ecs-task-construct.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ The new [`ecs.ScheduledEc2Task`] class will include an L3 construct for:

* ScheduledEc2Task

A `ScheduledEc2Task` will create a task definition with the specified container. An `Ec2EventRuleTarget` will be created and associated as the target to an `Amazon Cloudwatch Event Rule` (indicating how frequently the task should be run). Based on the `Amazon Cloudwatch Event Rule` schedule, a task will run on the EC2 instances specified in the cluster.
A `ScheduledEc2Task` will create a task definition with the specified container. An `Ec2EventRuleTarget` will be created and associated as the target to an `Amazon Cloudwatch Event Rule` (indicating how frequently the task should be run). Based on the `Amazon Cloudwatch Event Rule` schedule, a task will run on the EC2 instances specified in the cluster.

## Code changes

Given the above, we should make the following changes to support scheduled tasks on ECS:
1. Create `ScheduledEc2TaskProps` interface and `ScheduledEc2Task` construct

# Part 1: Create `ScheduledEc2TaskProps` interface and `ScheduledEc2Task` construct
# Part 1: Create `ScheduledEc2TaskProps` interface and `ScheduledEc2Task` construct

The `ScheduledEc2TaskProps` interface will contain properties to construct the Ec2TaskDefinition, Ec2EventRuleTarget and EventRule:

Expand Down Expand Up @@ -55,14 +55,14 @@ export interface ScheduledEc2TaskProps {

/**
* The CMD value to pass to the container. A string with commands delimited by commas.
*
*
* @default none
*/
readonly command?: string;

/**
* The minimum number of CPU units to reserve for the container.
*
*
* @default none
*/
readonly cpu?: number;
Expand All @@ -76,7 +76,7 @@ export interface ScheduledEc2TaskProps {

/**
* The environment variables to pass to the container.
*
*
* @default none
*/
readonly environment?: { [key: string]: string };
Expand Down Expand Up @@ -118,7 +118,7 @@ The `ScheduledEc2Task` construct will use the following existing constructs:
An example use case to create a task that is scheduled to run every minute:
```ts
// Create the vpc and cluster used by the scheduled task
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAZs: 1 });
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAzs: 1 });
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
cluster.addCapacity('DefaultAutoScalingGroup', {
instanceType: new ec2.InstanceType('t2.micro')
Expand Down
2 changes: 1 addition & 1 deletion design/aws-ecs/aws-ecs-service-discovery-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export interface ServiceDiscoveryOptions {
A full example would look like the following:

```
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAZs: 2 });
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAzs: 2 });
// Cloud Map Namespace
const namespace = new servicediscovery.PrivateDnsNamespace(stack, 'MyNamespace', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const app = new cdk.App();
const stack = new cdk.Stack(app, 'aws-cdk-autoscaling-integ');

const vpc = new ec2.Vpc(stack, 'VPC', {
maxAZs: 2
maxAzs: 2
});

new autoscaling.AutoScalingGroup(stack, 'Fleet', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const app = new cdk.App();
const stack = new cdk.Stack(app, 'aws-cdk-asg-integ');

const vpc = new ec2.Vpc(stack, 'VPC', {
maxAZs: 3
maxAzs: 3
});

const asg = new autoscaling.AutoScalingGroup(stack, 'Fleet', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const app = new cdk.App();
const stack = new cdk.Stack(app, 'aws-cdk-asg-integ');

const vpc = new ec2.Vpc(stack, 'VPC', {
maxAZs: 2
maxAzs: 2
});

const asg = new autoscaling.AutoScalingGroup(stack, 'Fleet', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const app = new cdk.App();
const stack = new cdk.Stack(app, 'aws-cdk-autoscaling-integ');

const vpc = new ec2.Vpc(stack, 'VPC', {
maxAZs: 2
maxAzs: 2
});

const asg = new autoscaling.AutoScalingGroup(stack, 'Fleet', {
Expand All @@ -30,4 +30,4 @@ asg.scaleOnCpuUtilization('KeepCPUReasonable', {
targetUtilizationPercent: 50
});

app.synth();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const app = new cdk.App();
const stack = new cdk.Stack(app, 'aws-cdk-autoscaling-integ');

const vpc = new ec2.Vpc(stack, 'VPC', {
maxAZs: 2
maxAzs: 2
});

new autoscaling.AutoScalingGroup(stack, 'Fleet', {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codebuild/test/integ.project-vpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const app = new cdk.App();

const stack = new cdk.Stack(app, 'aws-cdk-codebuild-project-vpc');
const vpc = new ec2.Vpc(stack, 'MyVPC', {
maxAZs: 1,
maxAzs: 1,
natGateways: 1,
});
const securityGroup = new ec2.SecurityGroup(stack, 'SecurityGroup1', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const app = new cdk.App();
const stack = new cdk.Stack(app, 'aws-cdk-codepipeline-ecs-deploy');

const vpc = new ec2.Vpc(stack, 'VPC', {
maxAZs: 1,
maxAzs: 1,
});
const cluster = new ecs.Cluster(stack, "EcsCluster", {
vpc,
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-ec2/lib/connections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,14 @@ export class Connections implements IConnectable {
/**
* Allow to all IPv4 ranges
*/
public allowToAnyIPv4(portRange: Port, description?: string) {
public allowToAnyIpv4(portRange: Port, description?: string) {
this.allowTo(Peer.anyIpv4(), portRange, description);
}

/**
* Allow from any IPv4 ranges
*/
public allowFromAnyIPv4(portRange: Port, description?: string) {
public allowFromAnyIpv4(portRange: Port, description?: string) {
this.allowFrom(Peer.anyIpv4(), portRange, description);
}

Expand Down Expand Up @@ -221,7 +221,7 @@ export class Connections implements IConnectable {
if (!this.defaultPort) {
throw new Error('Cannot call allowDefaultPortFromAnyIpv4(): this resource has no default port');
}
this.allowFromAnyIPv4(this.defaultPort, description);
this.allowFromAnyIpv4(this.defaultPort, description);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-ec2/lib/vpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ export interface VpcProps {
*
* @default 3
*/
readonly maxAZs?: number;
readonly maxAzs?: number;

/**
* The number of NAT Gateways to create.
Expand Down Expand Up @@ -798,7 +798,7 @@ export class Vpc extends VpcBase {

this.availabilityZones = stack.availabilityZones;

const maxAZs = props.maxAZs !== undefined ? props.maxAZs : 3;
const maxAZs = props.maxAzs !== undefined ? props.maxAzs : 3;
this.availabilityZones = this.availabilityZones.slice(0, maxAZs);

this.vpcId = this.resource.ref;
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-ec2/test/test.connections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export = {
const connections = new Connections({ securityGroups: [sg1] });

// WHEN
connections.allowFromAnyIPv4(Port.tcp(88));
connections.allowFromAnyIpv4(Port.tcp(88));
connections.addSecurityGroup(sg2);

// THEN
Expand Down
14 changes: 7 additions & 7 deletions packages/@aws-cdk/aws-ec2/test/test.vpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export = {
subnetType: SubnetType.ISOLATED,
}
],
maxAZs: 3
maxAzs: 3
});
expect(stack).to(countResources("AWS::EC2::Subnet", 6));
test.done();
Expand All @@ -164,7 +164,7 @@ export = {
subnetType: SubnetType.PRIVATE,
}
],
maxAZs: 3
maxAzs: 3
});
for (let i = 0; i < 3; i++) {
expect(stack).to(haveResource("AWS::EC2::Subnet", {
Expand Down Expand Up @@ -205,7 +205,7 @@ export = {
subnetType: SubnetType.ISOLATED,
}
],
maxAZs: 3
maxAzs: 3
});
expect(stack).to(countResources("AWS::EC2::InternetGateway", 1));
expect(stack).to(countResources("AWS::EC2::NatGateway", zones));
Expand Down Expand Up @@ -244,7 +244,7 @@ export = {
subnetType: SubnetType.ISOLATED,
}
],
maxAZs: 3
maxAzs: 3
});
expect(stack).to(countResources("AWS::EC2::InternetGateway", 1));
expect(stack).to(countResources("AWS::EC2::NatGateway", 2));
Expand Down Expand Up @@ -272,7 +272,7 @@ export = {
"with public subnets MapPublicIpOnLaunch is true"(test: Test) {
const stack = getTestStack();
new Vpc(stack, 'VPC', {
maxAZs: 1,
maxAzs: 1,
subnetConfiguration: [
{
cidrMask: 24,
Expand Down Expand Up @@ -309,7 +309,7 @@ export = {

"with maxAZs set to 2"(test: Test) {
const stack = getTestStack();
new Vpc(stack, 'VPC', { maxAZs: 2 });
new Vpc(stack, 'VPC', { maxAzs: 2 });
expect(stack).to(countResources("AWS::EC2::Subnet", 4));
expect(stack).to(countResources("AWS::EC2::Route", 4));
for (let i = 0; i < 4; i++) {
Expand Down Expand Up @@ -687,7 +687,7 @@ export = {
// GIVEN
const stack = getTestStack();
const vpc = new Vpc(stack, 'VpcNetwork', {
maxAZs: 1,
maxAzs: 1,
subnetConfiguration: [
{name: 'app', subnetType: SubnetType.PRIVATE },
{name: 'db', subnetType: SubnetType.PRIVATE },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class EventStack extends cdk.Stack {
constructor(scope: cdk.App, id: string) {
super(scope, id);

const vpc = new ec2.Vpc(this, 'Vpc', { maxAZs: 1 });
const vpc = new ec2.Vpc(this, 'Vpc', { maxAzs: 1 });

const cluster = new ecs.Cluster(this, 'EcsCluster', { vpc });
cluster.addCapacity('DefaultAutoScalingGroup', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export = {
"Can create a scheduled Ec2 Task - with only required props"(test: Test) {
// GIVEN
const stack = new cdk.Stack();
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAZs: 1 });
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAzs: 1 });
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
cluster.addCapacity('DefaultAutoScalingGroup', {
instanceType: new ec2.InstanceType('t2.micro')
Expand Down Expand Up @@ -73,7 +73,7 @@ export = {
"Can create a scheduled Ec2 Task - with optional props"(test: Test) {
// GIVEN
const stack = new cdk.Stack();
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAZs: 1 });
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAzs: 1 });
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
cluster.addCapacity('DefaultAutoScalingGroup', {
instanceType: new ec2.InstanceType('t2.micro')
Expand Down Expand Up @@ -150,7 +150,7 @@ export = {
"Scheduled Ec2 Task - with MemoryReservation defined"(test: Test) {
// GIVEN
const stack = new cdk.Stack();
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAZs: 1 });
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAzs: 1 });
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
cluster.addCapacity('DefaultAutoScalingGroup', {
instanceType: new ec2.InstanceType('t2.micro')
Expand Down Expand Up @@ -198,7 +198,7 @@ export = {
"Scheduled Ec2 Task - with Command defined"(test: Test) {
// GIVEN
const stack = new cdk.Stack();
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAZs: 1 });
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAzs: 1 });
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
cluster.addCapacity('DefaultAutoScalingGroup', {
instanceType: new ec2.InstanceType('t2.micro')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import ecsPatterns = require('../../lib');

const app = new cdk.App();
const stack = new cdk.Stack(app, 'aws-ecs-integ');
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAZs: 2 });
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAzs: 2 });

const cluster = new ecs.Cluster(stack, 'Cluster', { vpc });

Expand Down
Loading

0 comments on commit d60d673

Please sign in to comment.