Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(core): additional api cleanups #2972

Merged
merged 5 commits into from
Jun 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-apigateway/lib/api-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ export class ApiKey extends Resource implements IApiKey {
description: props.description,
enabled: props.enabled || true,
generateDistinctId: props.generateDistinctId,
name: this.physicalName.value,
name: this.physicalName,
stageKeys: this.renderStageKeys(props.resources)
});

this.keyId = resource.refAsString;
this.keyId = resource.ref;
}

private renderStageKeys(resources: RestApi[] | undefined): CfnApiKey.StageKeyProperty[] | undefined {
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-apigateway/lib/deployment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Construct, DeletionPolicy, Lazy, Resource, Stack } from '@aws-cdk/cdk';
import { CfnDeletionPolicy, Construct, Lazy, Resource, Stack } from '@aws-cdk/cdk';
import crypto = require('crypto');
import { CfnDeployment, CfnDeploymentProps } from './apigateway.generated';
import { IRestApi } from './restapi';
Expand Down Expand Up @@ -72,11 +72,11 @@ export class Deployment extends Resource {
});

if (props.retainDeployments) {
this.resource.options.deletionPolicy = DeletionPolicy.Retain;
this.resource.options.deletionPolicy = CfnDeletionPolicy.Retain;
}

this.api = props.api;
this.deploymentId = Lazy.stringValue({ produce: () => this.resource.refAsString });
this.deploymentId = Lazy.stringValue({ produce: () => this.resource.ref });
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/lib/method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class Method extends Resource {

const resource = new CfnMethod(this, 'Resource', methodProps);

this.methodId = resource.refAsString;
this.methodId = resource.ref;

props.resource.restApi._attachMethod(this);

Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/lib/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export class Resource extends ResourceBase {
};
const resource = new CfnResource(this, 'Resource', resourceProps);

this.resourceId = resource.refAsString;
this.resourceId = resource.ref;
this.restApi = props.parent.restApi;

// render resource path (special case for root)
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-apigateway/lib/restapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export class RestApi extends Resource implements IRestApi {
});

const resource = new CfnRestApi(this, 'Resource', {
name: this.physicalName.value!,
name: this.physicalName,
description: props.description,
policy: props.policy,
failOnWarnings: props.failOnWarnings,
Expand All @@ -215,7 +215,7 @@ export class RestApi extends Resource implements IRestApi {
parameters: props.parameters,
});

this.restApiId = resource.refAsString;
this.restApiId = resource.ref;

this.configureDeployment(props);

Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/lib/stage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export class Stage extends Resource {
methodSettings,
});

this.stageName = resource.refAsString;
this.stageName = resource.ref;
this.restApi = props.deployment.api;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/lib/usage-plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export class UsagePlan extends Resource {

this.apiStages.push(...(props.apiStages || []));

this.usagePlanId = resource.refAsString;
this.usagePlanId = resource.ref;

// Add ApiKey when
if (props.apiKey) {
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-apigateway/lib/vpc-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ export class VpcLink extends Resource {
});

const cfnResource = new CfnVpcLink(this, 'Resource', {
name: this.physicalName.value!,
name: this.physicalName,
description: props.description,
targetArns: Lazy.listValue({ produce: () => this.renderTargets() })
});

this.vpcLinkId = cfnResource.refAsString;
this.vpcLinkId = cfnResource.ref;

if (props.targets) {
this.addTargets(...props.targets);
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@
"props-physical-name:@aws-cdk/aws-apigateway.MethodProps",
"props-physical-name:@aws-cdk/aws-apigateway.ProxyResourceProps",
"props-physical-name:@aws-cdk/aws-apigateway.ResourceProps",
"props-physical-name:@aws-cdk/aws-apigateway.StageProps",
"props-physical-name:@aws-cdk/aws-apigateway.UsagePlanProps",
"props-physical-name-type:@aws-cdk/aws-apigateway.StageProps.stageName",
"props-physical-name:@aws-cdk/aws-apigateway.LambdaRestApiProps"
]
},
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/test/test.lambda-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export = {
runtime: lambda.Runtime.Nodejs810,
});
const alias = new lambda.Alias(stack, 'alias', {
aliasName: cdk.PhysicalName.of('my-alias'),
aliasName: 'my-alias',
version: new lambda.Version(stack, 'version', {
lambda: handler
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class ScalableTarget extends Resource implements IScalableTarget {
serviceNamespace: props.serviceNamespace
});

this.scalableTargetId = resource.refAsString;
this.scalableTargetId = resource.ref;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class StepScalingAction extends cdk.Construct {
} as CfnScalingPolicy.StepScalingPolicyConfigurationProperty
});

this.scalingPolicyArn = resource.refAsString;
this.scalingPolicyArn = resource.ref;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export class TargetTrackingScalingPolicy extends cdk.Construct {
}
});

this.scalingPolicyArn = resource.refAsString;
this.scalingPolicyArn = resource.ref;
}
}

Expand Down
10 changes: 5 additions & 5 deletions packages/@aws-cdk/aws-autoscaling/lib/auto-scaling-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import elbv2 = require('@aws-cdk/aws-elasticloadbalancingv2');
import iam = require('@aws-cdk/aws-iam');
import sns = require('@aws-cdk/aws-sns');

import { AutoScalingRollingUpdate, Construct, Duration, Fn, IResource, Lazy, Resource, Stack, Tag } from '@aws-cdk/cdk';
import { CfnAutoScalingRollingUpdate, Construct, Duration, Fn, IResource, Lazy, Resource, Stack, Tag } from '@aws-cdk/cdk';
import { CfnAutoScalingGroup, CfnAutoScalingGroupProps, CfnLaunchConfiguration } from './autoscaling.generated';
import { BasicLifecycleHookProps, LifecycleHook } from './lifecycle-hook';
import { BasicScheduledActionProps, ScheduledAction } from './scheduled-action';
Expand Down Expand Up @@ -390,7 +390,7 @@ export class AutoScalingGroup extends AutoScalingGroupBase implements
keyName: props.keyName,
instanceType: props.instanceType.toString(),
securityGroups: securityGroupsToken,
iamInstanceProfile: iamProfile.refAsString,
iamInstanceProfile: iamProfile.ref,
userData: userDataToken,
associatePublicIpAddress: props.associatePublicIpAddress,
spotPrice: props.spotPrice,
Expand All @@ -415,7 +415,7 @@ export class AutoScalingGroup extends AutoScalingGroupBase implements
minSize: minCapacity.toString(),
maxSize: maxCapacity.toString(),
desiredCapacity: desiredCapacity.toString(),
launchConfigurationName: launchConfig.refAsString,
launchConfigurationName: launchConfig.ref,
loadBalancerNames: Lazy.listValue({ produce: () => this.loadBalancerNames }, { omitEmpty: true }),
targetGroupArns: Lazy.listValue({ produce: () => this.targetGroupArns }, { omitEmpty: true }),
notificationConfigurations: !props.notificationsTopic ? undefined : [
Expand All @@ -438,7 +438,7 @@ export class AutoScalingGroup extends AutoScalingGroupBase implements

this.autoScalingGroup = new CfnAutoScalingGroup(this, 'ASG', asgProps);
this.osType = machineImage.os.type;
this.autoScalingGroupName = this.autoScalingGroup.refAsString;
this.autoScalingGroupName = this.autoScalingGroup.ref;
this.autoScalingGroupArn = Stack.of(this).formatArn({
service: 'autoscaling',
resource: 'autoScalingGroup:*:autoScalingGroupName',
Expand Down Expand Up @@ -661,7 +661,7 @@ export enum ScalingProcess {
/**
* Render the rolling update configuration into the appropriate object
*/
function renderRollingUpdateConfig(config: RollingUpdateConfiguration = {}): AutoScalingRollingUpdate {
function renderRollingUpdateConfig(config: RollingUpdateConfiguration = {}): CfnAutoScalingRollingUpdate {
const waitOnResourceSignals = config.minSuccessfulInstancesPercent !== undefined ? true : false;
const pauseTime = config.pauseTime || (waitOnResourceSignals ? Duration.minutes(5) : Duration.seconds(0));

Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-autoscaling/lib/lifecycle-hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export class LifecycleHook extends Resource implements ILifecycleHook {
autoScalingGroupName: props.autoScalingGroup.autoScalingGroupName,
defaultResult: props.defaultResult,
heartbeatTimeout: props.heartbeatTimeout && props.heartbeatTimeout.toSeconds(),
lifecycleHookName: this.physicalName.value,
lifecycleHookName: this.physicalName,
lifecycleTransition: props.lifecycleTransition,
notificationMetadata: props.notificationMetadata,
notificationTargetArn: targetProps.notificationTargetArn,
Expand All @@ -118,7 +118,7 @@ export class LifecycleHook extends Resource implements ILifecycleHook {
// lifecycle hook.
resource.node.addDependency(this.role);

this.lifecycleHookName = resource.refAsString;
this.lifecycleHookName = resource.ref;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class StepScalingAction extends cdk.Construct {
stepAdjustments: cdk.Lazy.anyValue({ produce: () => this.adjustments }),
});

this.scalingPolicyArn = resource.refAsString;
this.scalingPolicyArn = resource.ref;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export class TargetTrackingScalingPolicy extends cdk.Construct {
}
});

this.scalingPolicyArn = this.resource.refAsString;
this.scalingPolicyArn = this.resource.ref;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class Certificate extends Resource implements ICertificate {
domainValidationOptions: allDomainNames.map(domainValidationOption),
});

this.certificateArn = cert.refAsString;
this.certificateArn = cert.ref;

/**
* Return the domain validation options for the given domain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import sns = require('@aws-cdk/aws-sns');
import ssm = require('@aws-cdk/aws-ssm');
import cdk = require('@aws-cdk/cdk');
import { Token } from '@aws-cdk/cdk';
import { AwsCustomResource } from '../lib';

const app = new cdk.App();
Expand Down Expand Up @@ -46,8 +47,8 @@ const getParameter = new AwsCustomResource(stack, 'GetParameter', {
}
});

new cdk.CfnOutput(stack, 'MessageId', { value: snsPublish.getData('MessageId') });
new cdk.CfnOutput(stack, 'TopicArn', { value: listTopics.getData('Topics.0.TopicArn') });
new cdk.CfnOutput(stack, 'ParameterValue', { value: getParameter.getData('Parameter.Value') });
new cdk.CfnOutput(stack, 'MessageId', { value: Token.asString(snsPublish.getData('MessageId')) });
new cdk.CfnOutput(stack, 'TopicArn', { value: Token.asString(listTopics.getData('Topics.0.TopicArn')) });
new cdk.CfnOutput(stack, 'ParameterValue', { value: Token.asString(getParameter.getData('Parameter.Value')) });

app.synth();
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-cloudfront/lib/web_distribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ export class CloudFrontWebDistribution extends cdk.Construct implements IDistrib

const distribution = new CfnDistribution(this, 'CFDistribution', { distributionConfig });
this.domainName = distribution.attrDomainName;
this.distributionId = distribution.refAsString;
this.distributionId = distribution.ref;
}

private toBehavior(input: BehaviorWithOrigin, protoPolicy?: ViewerProtocolPolicy) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ new cloudfront.CloudFrontWebDistribution(stack, 'MyDistribution', {
]
});

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const dist = new cloudfront.CloudFrontWebDistribution(stack, 'Distribution', {
behaviors: [{ isDefaultBehavior: true }],
s3OriginSource: {
s3BucketSource: bucket,
originAccessIdentityId: oai.refAsString,
originAccessIdentityId: oai.ref,
},
}]
});
Expand Down
8 changes: 4 additions & 4 deletions packages/@aws-cdk/aws-cloudtrail/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import iam = require('@aws-cdk/aws-iam');
import kms = require('@aws-cdk/aws-kms');
import logs = require('@aws-cdk/aws-logs');
import s3 = require('@aws-cdk/aws-s3');
import { Construct, PhysicalName, Resource, ResourceIdentifiers, Stack } from '@aws-cdk/cdk';
import { Construct, PhysicalName, Resource, Stack } from '@aws-cdk/cdk';
import { CfnTrail } from './cloudtrail.generated';

// AWS::CloudTrail CloudFormation Resources:
Expand Down Expand Up @@ -175,7 +175,7 @@ export class Trail extends Resource {
enableLogFileValidation: props.enableFileValidation == null ? true : props.enableFileValidation,
isMultiRegionTrail: props.isMultiRegionTrail == null ? true : props.isMultiRegionTrail,
includeGlobalServiceEvents: props.includeGlobalServiceEvents == null ? true : props.includeGlobalServiceEvents,
trailName: this.physicalName.value,
trailName: this.physicalName,
kmsKeyId: props.kmsKey && props.kmsKey.keyArn,
s3BucketName: s3bucket.bucketName,
s3KeyPrefix: props.s3KeyPrefix,
Expand All @@ -185,13 +185,13 @@ export class Trail extends Resource {
eventSelectors: this.eventSelectors
});

const resourceIdentifiers = new ResourceIdentifiers(this, {
const resourceIdentifiers = this.getCrossEnvironmentAttributes({
arn: trail.attrArn,
name: trail.trailName || '',
arnComponents: {
service: 'cloudtrail',
resource: 'trail',
resourceName: this.physicalName.value,
resourceName: this.physicalName,
},
});
this.trailArn = resourceIdentifiers.arn;
Expand Down
10 changes: 5 additions & 5 deletions packages/@aws-cdk/aws-cloudwatch/lib/alarm.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Construct, IResource, Lazy, Resource, ResourceIdentifiers, Stack } from '@aws-cdk/cdk';
import { Construct, IResource, Lazy, Resource, Stack } from '@aws-cdk/cdk';
import { IAlarmAction } from './alarm-action';
import { CfnAlarm } from './cloudwatch.generated';
import { HorizontalAnnotation } from './graph';
Expand Down Expand Up @@ -126,7 +126,7 @@ export class Alarm extends Resource implements IAlarm {
const alarm = new CfnAlarm(this, 'Resource', {
// Meta
alarmDescription: props.alarmDescription,
alarmName: this.physicalName.value,
alarmName: this.physicalName,

// Evaluation
comparisonOperator,
Expand All @@ -151,13 +151,13 @@ export class Alarm extends Resource implements IAlarm {
})
});

const resourceIdentifiers = new ResourceIdentifiers(this, {
const resourceIdentifiers = this.getCrossEnvironmentAttributes({
arn: alarm.attrArn,
name: alarm.refAsString,
name: alarm.ref,
arnComponents: {
service: 'cloudwatch',
resource: 'alarm',
resourceName: this.physicalName.value,
resourceName: this.physicalName,
sep: ':',
},
});
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-cloudwatch/lib/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class Dashboard extends Resource {
});

new CfnDashboard(this, 'Resource', {
dashboardName: this.physicalName.value,
dashboardName: this.physicalName,
dashboardBody: Lazy.stringValue({ produce: () => {
const column = new Column(...this.rows);
column.position(0, 0);
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codebuild/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ const vpc = new ec2.Vpc(stack, 'MyVPC');
const securityGroup = new ec2.SecurityGroup(stack, 'SecurityGroup1', {
allowAllOutbound: true,
description: 'Example',
groupName: 'MySecurityGroup',
securityGroupName: 'MySecurityGroup',
vpc: vpc,
});
new codebuild.Project(stack, 'MyProject', {
Expand Down
Loading