Skip to content

Commit

Permalink
refactor: rename enum-like members to ALL_CAPS
Browse files Browse the repository at this point in the history
Similar to the enum naming convention, public static readonly properties
must be ALL_CAPS.

This is in accordance with the new construct library guidelines.

Fixes #3018

BREAKING CHANGE: members in enum like classes are now named using ALL_CAPS
  • Loading branch information
shivlaks committed Jun 24, 2019
1 parent 3b44791 commit 42b29ef
Show file tree
Hide file tree
Showing 114 changed files with 507 additions and 477 deletions.
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-apigateway/test/integ.restapi.books.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ class BookStack extends cdk.Stack {
super(scope, id);

const booksHandler = new apigw.LambdaIntegration(new lambda.Function(this, 'BooksHandler', {
runtime: lambda.Runtime.Nodejs810,
runtime: lambda.Runtime.NODEJS_8_10,
handler: 'index.handler',
code: lambda.Code.inline(`exports.handler = ${echoHandlerCode}`)
}));

const bookHandler = new apigw.LambdaIntegration(new lambda.Function(this, 'BookHandler', {
runtime: lambda.Runtime.Nodejs810,
runtime: lambda.Runtime.NODEJS_8_10,
handler: 'index.handler',
code: lambda.Code.inline(`exports.handler = ${echoHandlerCode}`)
}));

const hello = new apigw.LambdaIntegration(new lambda.Function(this, 'Hello', {
runtime: lambda.Runtime.Nodejs810,
runtime: lambda.Runtime.NODEJS_8_10,
handler: 'index.handler',
code: lambda.Code.inline(`exports.handler = ${helloCode}`)
}));
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/test/integ.restapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Test extends cdk.Stack {
});

const handler = new lambda.Function(this, 'MyHandler', {
runtime: lambda.Runtime.Nodejs810,
runtime: lambda.Runtime.NODEJS_8_10,
code: lambda.Code.inline(`exports.handler = ${handlerCode}`),
handler: 'index.handler',
});
Expand Down
8 changes: 4 additions & 4 deletions packages/@aws-cdk/aws-apigateway/test/test.lambda-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export = {
const handler = new lambda.Function(stack, 'handler', {
handler: 'index.handler',
code: lambda.Code.inline('boom'),
runtime: lambda.Runtime.Nodejs810,
runtime: lambda.Runtime.NODEJS_8_10,
});

// WHEN
Expand Down Expand Up @@ -78,7 +78,7 @@ export = {
const handler = new lambda.Function(stack, 'handler', {
handler: 'index.handler',
code: lambda.Code.inline('boom'),
runtime: lambda.Runtime.Nodejs810,
runtime: lambda.Runtime.NODEJS_8_10,
});
const alias = new lambda.Alias(stack, 'alias', {
aliasName: 'my-alias',
Expand Down Expand Up @@ -145,7 +145,7 @@ export = {
const handler = new lambda.Function(stack, 'handler', {
handler: 'index.handler',
code: lambda.Code.inline('boom'),
runtime: lambda.Runtime.Nodejs810,
runtime: lambda.Runtime.NODEJS_8_10,
});

// WHEN
Expand Down Expand Up @@ -184,7 +184,7 @@ export = {
const handler = new lambda.Function(stack, 'handler', {
handler: 'index.handler',
code: lambda.Code.inline('boom'),
runtime: lambda.Runtime.Nodejs810,
runtime: lambda.Runtime.NODEJS_8_10,
});

test.throws(() => new apigw.LambdaRestApi(stack, 'lambda-rest-api', {
Expand Down
8 changes: 4 additions & 4 deletions packages/@aws-cdk/aws-apigateway/test/test.lambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export = {
const stack = new cdk.Stack();
const api = new apigateway.RestApi(stack, 'my-api');
const handler = new lambda.Function(stack, 'Handler', {
runtime: lambda.Runtime.Python27,
runtime: lambda.Runtime.PYTHON_2_7,
handler: 'boom',
code: lambda.Code.inline('foo')
});
Expand Down Expand Up @@ -56,7 +56,7 @@ export = {
// GIVEN
const stack = new cdk.Stack();
const fn = new lambda.Function(stack, 'Handler', {
runtime: lambda.Runtime.Nodejs810,
runtime: lambda.Runtime.NODEJS_8_10,
code: lambda.Code.inline('foo'),
handler: 'index.handler'
});
Expand Down Expand Up @@ -106,7 +106,7 @@ export = {
// GIVEN
const stack = new cdk.Stack();
const fn = new lambda.Function(stack, 'Handler', {
runtime: lambda.Runtime.Nodejs810,
runtime: lambda.Runtime.NODEJS_8_10,
code: lambda.Code.inline('foo'),
handler: 'index.handler'
});
Expand All @@ -132,7 +132,7 @@ export = {
const api = new apigateway.RestApi(stack, 'test-api');

const handler = new lambda.Function(stack, 'MyFunc', {
runtime: lambda.Runtime.Nodejs810,
runtime: lambda.Runtime.NODEJS_8_10,
handler: 'index.handler',
code: lambda.Code.inline(``)
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('given an AutoScalingGroup', () => {
// GIVEN
const fn = new lambda.Function(stack, 'Fn', {
code: lambda.Code.inline('foo'),
runtime: lambda.Runtime.Nodejs810,
runtime: lambda.Runtime.NODEJS_8_10,
handler: 'index.index',
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class DnsValidatedCertificate extends cdk.Resource implements ICertificat
const requestorFunction = new lambda.Function(this, 'CertificateRequestorFunction', {
code: lambda.Code.asset(path.resolve(__dirname, '..', 'lambda-packages', 'dns_validated_certificate_handler', 'lib')),
handler: 'index.certificateRequestHandler',
runtime: lambda.Runtime.Nodejs810,
runtime: lambda.Runtime.NODEJS_8_10,
timeout: cdk.Duration.minutes(15)
});
requestorFunction.addToRolePolicy(new iam.PolicyStatement({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export class AwsCustomResource extends cdk.Construct {

const provider = new lambda.SingletonFunction(this, 'Provider', {
code: lambda.Code.asset(path.join(__dirname, 'aws-custom-resource-provider')),
runtime: lambda.Runtime.Nodejs10x,
runtime: lambda.Runtime.NODEJS_10_X,
handler: 'index.handler',
uuid: '679f53fa-c002-430c-b0da-5b7982bd2287',
lambdaPurpose: 'AWS'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class DemoResource extends cdk.Construct {
code: new lambda.InlineCode(fs.readFileSync('integ.trivial-lambda-provider.py', { encoding: 'utf-8' })),
handler: 'index.main',
timeout: cdk.Duration.minutes(5),
runtime: lambda.Runtime.Python27,
runtime: lambda.Runtime.PYTHON_2_7,
})),
properties: props
});
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-cloudformation/test/test.resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class TestCustomResource extends cdk.Construct {
const singletonLambda = new lambda.SingletonFunction(this, 'Lambda', {
uuid: 'TestCustomResourceProvider',
code: new lambda.InlineCode('def hello(): pass'),
runtime: lambda.Runtime.Python27,
runtime: lambda.Runtime.PYTHON_2_7,
handler: 'index.hello',
timeout: cdk.Duration.minutes(5),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const sourceBucket = new s3.Bucket(stack, 'Bucket', {
const lambdaFunction = new lambda.Function(stack, 'Lambda', {
code: lambda.Code.inline('foo'),
handler: 'index.handler',
runtime: lambda.Runtime.Nodejs810
runtime: lambda.Runtime.NODEJS_8_10
});

const lambdaVersion = new lambda.Version(stack, 'LambdaVersion', {
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-cloudwatch/lib/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class AlarmWidget extends ConcreteWidget {
properties: {
view: 'timeSeries',
title: this.props.title,
region: this.props.region || cdk.Aws.region,
region: this.props.region || cdk.Aws.REGION,
annotations: {
alarms: [this.props.alarm.alarmArn]
},
Expand Down Expand Up @@ -176,7 +176,7 @@ export class GraphWidget extends ConcreteWidget {
properties: {
view: 'timeSeries',
title: this.props.title,
region: this.props.region || cdk.Aws.region,
region: this.props.region || cdk.Aws.REGION,
metrics: (this.props.left || []).map(m => metricJson(m, 'left')).concat(
(this.props.right || []).map(m => metricJson(m, 'right'))),
annotations: {
Expand Down Expand Up @@ -223,7 +223,7 @@ export class SingleValueWidget extends ConcreteWidget {
properties: {
view: 'singleValue',
title: this.props.title,
region: this.props.region || cdk.Aws.region,
region: this.props.region || cdk.Aws.REGION,
metrics: this.props.metrics.map(m => metricJson(m, 'left'))
}
}];
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codebuild/lib/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export abstract class Cache {
return {
_toCloudFormation: () => ({
type: 'S3',
location: Fn.join('/', [bucket.bucketName, options && options.prefix || Aws.noValue])
location: Fn.join('/', [bucket.bucketName, options && options.prefix || Aws.NO_VALUE])
}),
_bind: (project) => {
bucket.grantReadWrite(project);
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-codebuild/lib/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -865,13 +865,13 @@ export class Project extends ProjectBase {
}

this.role.addToPolicy(new iam.PolicyStatement({
resources: [`arn:aws:ec2:${Aws.region}:${Aws.accountId}:network-interface/*`],
resources: [`arn:aws:ec2:${Aws.REGION}:${Aws.ACCOUNT_ID}:network-interface/*`],
actions: ['ec2:CreateNetworkInterfacePermission'],
conditions: {
StringEquals: {
'ec2:Subnet': props.vpc
.selectSubnets(props.subnetSelection).subnetIds
.map(si => `arn:aws:ec2:${Aws.region}:${Aws.accountId}:subnet/${si}`),
.map(si => `arn:aws:ec2:${Aws.REGION}:${Aws.ACCOUNT_ID}:subnet/${si}`),
'ec2:AuthorizedService': 'codebuild.amazonaws.com'
},
},
Expand Down
18 changes: 9 additions & 9 deletions packages/@aws-cdk/aws-codedeploy/lib/lambda/deployment-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ export interface LambdaDeploymentConfigImportProps {
* @resource AWS::CodeDeploy::DeploymentConfig
*/
export class LambdaDeploymentConfig {
public static readonly AllAtOnce = deploymentConfig('CodeDeployDefault.LambdaAllAtOnce');
public static readonly Canary10Percent30Minutes = deploymentConfig('CodeDeployDefault.LambdaCanary10Percent30Minutes');
public static readonly Canary10Percent5Minutes = deploymentConfig('CodeDeployDefault.LambdaCanary10Percent5Minutes');
public static readonly Canary10Percent10Minutes = deploymentConfig('CodeDeployDefault.LambdaCanary10Percent10Minutes');
public static readonly Canary10Percent15Minutes = deploymentConfig('CodeDeployDefault.LambdaCanary10Percent15Minutes');
public static readonly Linear10PercentEvery10Minutes = deploymentConfig('CodeDeployDefault.LambdaLinear10PercentEvery10Minutes');
public static readonly Linear10PercentEvery1Minute = deploymentConfig('CodeDeployDefault.LambdaLinear10PercentEvery1Minute');
public static readonly Linear10PercentEvery2Minutes = deploymentConfig('CodeDeployDefault.LambdaLinear10PercentEvery2Minutes');
public static readonly Linear10PercentEvery3Minutes = deploymentConfig('CodeDeployDefault.LambdaLinear10PercentEvery3Minutes');
public static readonly ALL_AT_ONCE = deploymentConfig('CodeDeployDefault.LambdaAllAtOnce');
public static readonly CANARY_10PERCENT_30MINUTES = deploymentConfig('CodeDeployDefault.LambdaCanary10Percent30Minutes');
public static readonly CANARY_10PERCENT_5MINUTES = deploymentConfig('CodeDeployDefault.LambdaCanary10Percent5Minutes');
public static readonly CANARY_10PERCENT_10MINUTES = deploymentConfig('CodeDeployDefault.LambdaCanary10Percent10Minutes');
public static readonly CANARY_10PERCENT_15MINUTES = deploymentConfig('CodeDeployDefault.LambdaCanary10Percent15Minutes');
public static readonly LINEAR_10PERCENT_EVERY_10MINUTES = deploymentConfig('CodeDeployDefault.LambdaLinear10PercentEvery10Minutes');
public static readonly LINEAR_10PERCENT_EVERY_1MINUTE = deploymentConfig('CodeDeployDefault.LambdaLinear10PercentEvery1Minute');
public static readonly LINEAR_10PERCENT_EVERY_2MINUTES = deploymentConfig('CodeDeployDefault.LambdaLinear10PercentEvery2Minutes');
public static readonly LINEAR_10PERCENT_EVERY_3MINUTES = deploymentConfig('CodeDeployDefault.LambdaLinear10PercentEvery3Minutes');

/**
* Import a custom Deployment Configuration for a Lambda Deployment Group defined outside the CDK.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export class LambdaDeploymentGroup extends cdk.Resource implements ILambdaDeploy
applicationName: this.application.applicationName,
serviceRoleArn: this.role.roleArn,
deploymentGroupName: this.physicalName,
deploymentConfigName: (props.deploymentConfig || LambdaDeploymentConfig.AllAtOnce).deploymentConfigName,
deploymentConfigName: (props.deploymentConfig || LambdaDeploymentConfig.ALL_AT_ONCE).deploymentConfigName,
deploymentStyle: {
deploymentType: 'BLUE_GREEN',
deploymentOption: 'WITH_TRAFFIC_CONTROL'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ export interface ServerDeploymentConfigProps {
* @resource AWS::CodeDeploy::DeploymentConfig
*/
export class ServerDeploymentConfig extends cdk.Resource implements IServerDeploymentConfig {
public static readonly OneAtATime = deploymentConfig('CodeDeployDefault.OneAtATime');
public static readonly HalfAtATime = deploymentConfig('CodeDeployDefault.HalfAtATime');
public static readonly AllAtOnce = deploymentConfig('CodeDeployDefault.AllAtOnce');
public static readonly ONE_AT_A_TIME = deploymentConfig('CodeDeployDefault.OneAtATime');
public static readonly HALF_AT_A_TIME = deploymentConfig('CodeDeployDefault.HalfAtATime');
public static readonly ALL_AT_ONCE = deploymentConfig('CodeDeployDefault.AllAtOnce');

/**
* Import a custom Deployment Configuration for an EC2/on-premise Deployment Group defined either outside the CDK,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ abstract class ServerDeploymentGroupBase extends cdk.Resource implements IServer

constructor(scope: cdk.Construct, id: string, deploymentConfig?: IServerDeploymentConfig, props?: cdk.ResourceProps) {
super(scope, id, props);
this.deploymentConfig = deploymentConfig || ServerDeploymentConfig.OneAtATime;
this.deploymentConfig = deploymentConfig || ServerDeploymentConfig.ONE_AT_A_TIME;
}
}

Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-codedeploy/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { CfnDeploymentGroup } from './codedeploy.generated';
import { AutoRollbackConfig } from './rollback-config';

export function arnForApplication(applicationName: string): string {
return `arn:${Aws.partition}:codedeploy:${Aws.region}:${Aws.accountId}:application:${applicationName}`;
return `arn:${Aws.PARTITION}:codedeploy:${Aws.REGION}:${Aws.ACCOUNT_ID}:application:${applicationName}`;
}

export function arnForDeploymentGroup(applicationName: string, deploymentGroupName: string): string {
return `arn:${Aws.partition}:codedeploy:${Aws.region}:${Aws.accountId}:deploymentgroup:${applicationName}/${deploymentGroupName}`;
return `arn:${Aws.PARTITION}:codedeploy:${Aws.REGION}:${Aws.ACCOUNT_ID}:deploymentgroup:${applicationName}/${deploymentGroupName}`;
}

export function arnForDeploymentConfig(name: string): string {
return `arn:${Aws.partition}:codedeploy:${Aws.region}:${Aws.accountId}:deploymentconfig:${name}`;
return `arn:${Aws.PARTITION}:codedeploy:${Aws.REGION}:${Aws.ACCOUNT_ID}:deploymentconfig:${name}`;
}

export function renderAlarmConfiguration(alarms: cloudwatch.IAlarm[], ignorePollAlarmFailure?: boolean):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const stack = new cdk.Stack(app, 'aws-cdk-codedeploy-lambda');
const handler = new lambda.Function(stack, `Handler`, {
code: lambda.Code.asset(path.join(__dirname, 'handler')),
handler: 'index.handler',
runtime: lambda.Runtime.Nodejs810,
runtime: lambda.Runtime.NODEJS_8_10,
});
const version = handler.addVersion('1');
const blueGreenAlias = new lambda.Alias(stack, `Alias`, {
Expand All @@ -22,17 +22,17 @@ const blueGreenAlias = new lambda.Alias(stack, `Alias`, {
const preHook = new lambda.Function(stack, `PreHook`, {
code: lambda.Code.asset(path.join(__dirname, 'preHook')),
handler: 'index.handler',
runtime: lambda.Runtime.Nodejs810
runtime: lambda.Runtime.NODEJS_8_10
});
const postHook = new lambda.Function(stack, `PostHook`, {
code: lambda.Code.asset(path.join(__dirname, 'postHook')),
handler: 'index.handler',
runtime: lambda.Runtime.Nodejs810
runtime: lambda.Runtime.NODEJS_8_10
});

new codedeploy.LambdaDeploymentGroup(stack, 'BlueGreenDeployment', {
alias: blueGreenAlias,
deploymentConfig: codedeploy.LambdaDeploymentConfig.Linear10PercentEvery1Minute,
deploymentConfig: codedeploy.LambdaDeploymentConfig.LINEAR_10PERCENT_EVERY_1MINUTE,
alarms: [
new cloudwatch.Alarm(stack, 'BlueGreenErrors', {
comparisonOperator: cloudwatch.ComparisonOperator.GREATER_THAN_THRESHOLD,
Expand Down
Loading

0 comments on commit 42b29ef

Please sign in to comment.