Skip to content

Commit

Permalink
fix: rename core classes adding a Cfn prefix (#1960)
Browse files Browse the repository at this point in the history
To better align with our L1 layer that is closely tied to CloudFormation, add the Cfn prefix to classes from the @aws-cdk/cdk package.

BREAKING CHANGE: rename Output to CfnOutput.
BREAKING CHANGE: rename Condition to CfnCondition.
BREAKING CHANGE: rename StackElement to CfnElement.
BREAKING CHANGE: rename Parameter to CfnParameter.
BREAKING CHANGE: rename Resource to CfnResource.
BREAKING CHANGE: rename Rule to CfnRule.
BREAKING CHANGE: rename Mapping to CfnMapping.
BREAKING CHANGE: rename Referenceable to CfnRefElement.
BREAKING CHANGE: rename IConditionExpression to ICfnConditionExpression.
BREAKING CHANGE: rename CfnReference to Reference.

Fixes #1462
Fixes #288
  • Loading branch information
skinny85 authored Mar 14, 2019
1 parent 3117cd3 commit 5886bf6
Show file tree
Hide file tree
Showing 155 changed files with 547 additions and 546 deletions.
8 changes: 4 additions & 4 deletions design/aws-guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ so they can be imported to another stack.
class Xxx extends XxxBase {
public export(): XxxImportProps {
return {
attr1: new cdk.Output(this, 'Attr1', { value: this.attr1 }).makeImportValue().toString(),
attr2: new cdk.Output(this, 'Attr2', { value: this.attr2 }).makeImportValue().toString(),
attr1: new cdk.CfnOutput(this, 'Attr1', { value: this.attr1 }).makeImportValue().toString(),
attr2: new cdk.CfnOutput(this, 'Attr2', { value: this.attr2 }).makeImportValue().toString(),
}
}
}
Expand Down Expand Up @@ -405,8 +405,8 @@ export class Foo extends FooBase implements IAnotherInterface {
// for them so they can be imported to another stack.
public export(): FooAttributes {
return {
fooArn: new cdk.Output(this, 'Arn', { value: this.fooArn }).makeImportValue().toString(), // represent Fn::ImportValue as a string
fooBoo: new cdk.Output(this, 'Boo', { value: this.fooBoo }).makeImportValue().toList() // represent as string[]
fooArn: new cdk.CfnOutput(this, 'Arn', { value: this.fooArn }).makeImportValue().toString(), // represent Fn::ImportValue as a string
fooBoo: new cdk.CfnOutput(this, 'Boo', { value: this.fooBoo }).makeImportValue().toList() // represent as string[]
// ...
}
}
Expand Down
12 changes: 6 additions & 6 deletions packages/@aws-cdk/applet-js/test/test-applet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { App, Construct, Parameter, Stack, StackProps } from '@aws-cdk/cdk';
import { App, CfnParameter, Construct, Stack, StackProps } from '@aws-cdk/cdk';

export interface TestAppletProps extends StackProps {
prop1: string
Expand All @@ -10,11 +10,11 @@ export class TestApplet extends Stack {
constructor(scope: App, id: string, props: TestAppletProps) {
super(scope, id, props);

new Parameter(this, 'P1', { default: this.node.required(props, 'prop1'), type: 'String' });
new Parameter(this, 'P2', { default: this.node.required(props, 'prop2'), type: 'Number' });
new CfnParameter(this, 'P1', { default: this.node.required(props, 'prop1'), type: 'String' });
new CfnParameter(this, 'P2', { default: this.node.required(props, 'prop2'), type: 'Number' });

if (props.prop3) {
new Parameter(this, 'P3', { default: props.prop3.join(','), type: 'StringList' });
new CfnParameter(this, 'P3', { default: props.prop3.join(','), type: 'StringList' });
}
}
}
Expand All @@ -39,6 +39,6 @@ export class NoStackApplet extends Construct {
constructor(scope: Construct, id: string, props: NoStackAppletProps) {
super(scope, id);

new Parameter(this, 'P1', { default: props.argument, type: 'String' });
new CfnParameter(this, 'P1', { default: props.argument, type: 'String' });
}
}
}
4 changes: 2 additions & 2 deletions packages/@aws-cdk/assert/test/test.assertions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,11 @@ function synthesizedStack(fn: (stack: cdk.Stack) => void): cx.SynthesizedStack {
return app.synthesizeStack(stack.name);
}

interface TestResourceProps extends cdk.ResourceProps {
interface TestResourceProps extends cdk.CfnResourceProps {
type: string;
}

class TestResource extends cdk.Resource {
class TestResource extends cdk.CfnResource {
constructor(scope: cdk.Construct, id: string, props: TestResourceProps) {
super(scope, id, props);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/assets-docker/lib/image-asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class DockerImageAsset extends cdk.Construct {
throw new Error(`No 'Dockerfile' found in ${this.directory}`);
}

const imageNameParameter = new cdk.Parameter(this, 'ImageName', {
const imageNameParameter = new cdk.CfnParameter(this, 'ImageName', {
type: 'String',
description: `ECR repository name and tag asset "${this.node.path}"`,
});
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/assets/lib/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ export class Asset extends cdk.Construct {
// the toolkit or by CI/CD when the stack is deployed and will include
// the name of the bucket and the S3 key where the code lives.

const bucketParam = new cdk.Parameter(this, 'S3Bucket', {
const bucketParam = new cdk.CfnParameter(this, 'S3Bucket', {
type: 'String',
description: `S3 bucket for asset "${this.node.path}"`,
});

const keyParam = new cdk.Parameter(this, 'S3VersionKey', {
const keyParam = new cdk.CfnParameter(this, 'S3VersionKey', {
type: 'String',
description: `S3 key for asset version "${this.node.path}"`
});
Expand Down Expand Up @@ -156,7 +156,7 @@ export class Asset extends cdk.Construct {
* @param resourceProperty The property name where this asset is referenced
* (e.g. "Code" for AWS::Lambda::Function)
*/
public addResourceMetadata(resource: cdk.Resource, resourceProperty: string) {
public addResourceMetadata(resource: cdk.CfnResource, resourceProperty: string) {
if (!this.node.getContext(cxapi.ASSET_RESOURCE_METADATA_ENABLED_CONTEXT)) {
return; // not enabled
}
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/assets/test/integ.assets.refs.lit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ class TestStack extends cdk.Stack {
path: path.join(__dirname, 'sample-asset-directory')
});

new cdk.Output(this, 'S3BucketName', { value: asset.s3BucketName });
new cdk.Output(this, 'S3ObjectKey', { value: asset.s3ObjectKey });
new cdk.Output(this, 'S3URL', { value: asset.s3Url });
new cdk.CfnOutput(this, 'S3BucketName', { value: asset.s3BucketName });
new cdk.CfnOutput(this, 'S3ObjectKey', { value: asset.s3ObjectKey });
new cdk.CfnOutput(this, 'S3URL', { value: asset.s3Url });
/// !hide

// we need at least one resource
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/assets/test/test.asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export = {
stack.node.setContext(cxapi.ASSET_RESOURCE_METADATA_ENABLED_CONTEXT, true);

const location = path.join(__dirname, 'sample-asset-directory');
const resource = new cdk.Resource(stack, 'MyResource', { type: 'My::Resource::Type' });
const resource = new cdk.CfnResource(stack, 'MyResource', { type: 'My::Resource::Type' });
const asset = new ZipDirectoryAsset(stack, 'MyAsset', { path: location });

// WHEN
Expand All @@ -195,7 +195,7 @@ export = {
const stack = new cdk.Stack();

const location = path.join(__dirname, 'sample-asset-directory');
const resource = new cdk.Resource(stack, 'MyResource', { type: 'My::Resource::Type' });
const resource = new cdk.CfnResource(stack, 'MyResource', { type: 'My::Resource::Type' });
const asset = new ZipDirectoryAsset(stack, 'MyAsset', { path: location });

// WHEN
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 @@ -230,7 +230,7 @@ export class RestApi extends cdk.Construct implements IRestApi {
*/
public export(): RestApiImportProps {
return {
restApiId: new cdk.Output(this, 'RestApiId', { value: this.restApiId }).makeImportValue().toString()
restApiId: new cdk.CfnOutput(this, 'RestApiId', { value: this.restApiId }).makeImportValue().toString()
};
}

Expand Down Expand Up @@ -317,7 +317,7 @@ export class RestApi extends cdk.Construct implements IRestApi {
...props.deployOptions
});

new cdk.Output(this, 'Endpoint', { value: this.urlForPath() });
new cdk.CfnOutput(this, 'Endpoint', { value: this.urlForPath() });
} else {
if (props.deployOptions) {
throw new Error(`Cannot set 'deployOptions' if 'deploy' is disabled`);
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/test/test.deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export = {
const deployment = new apigateway.Deployment(stack, 'deployment', { api });
api.root.addMethod('GET');

const dep = new cdk.Resource(stack, 'MyResource', { type: 'foo' });
const dep = new cdk.CfnResource(stack, 'MyResource', { type: 'foo' });

// WHEN
deployment.node.addDependency(dep);
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/test/test.restapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ export = {
const stack = new cdk.Stack();
const api = new apigateway.RestApi(stack, 'myapi');
api.root.addMethod('GET');
const resource = new cdk.Resource(stack, 'DependsOnRestApi', { type: 'My::Resource' });
const resource = new cdk.CfnResource(stack, 'DependsOnRestApi', { type: 'My::Resource' });

// WHEN
resource.node.addDependency(api);
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-certificatemanager/lib/certificate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Construct, IConstruct, Output } from '@aws-cdk/cdk';
import { CfnOutput, Construct, IConstruct } from '@aws-cdk/cdk';
import { CfnCertificate } from './certificatemanager.generated';
import { apexDomain } from './util';

Expand Down Expand Up @@ -114,7 +114,7 @@ export class Certificate extends Construct implements ICertificate {
*/
public export(): CertificateImportProps {
return {
certificateArn: new Output(this, 'Arn', { value: this.certificateArn }).makeImportValue().toString()
certificateArn: new CfnOutput(this, 'Arn', { value: this.certificateArn }).makeImportValue().toString()
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class DnsValidatedCertificate extends cdk.Construct implements ICertifica
*/
public export(): CertificateImportProps {
return {
certificateArn: new cdk.Output(this, 'Arn', { value: this.certificateArn }).makeImportValue().toString()
certificateArn: new cdk.CfnOutput(this, 'Arn', { value: this.certificateArn }).makeImportValue().toString()
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export interface PipelineCloudFormationActionProps extends codepipeline.CommonAc
*/
export abstract class PipelineCloudFormationAction extends codepipeline.Action {
/**
* Output artifact containing the CloudFormation call response
* CfnOutput artifact containing the CloudFormation call response
*
* Only present if configured by passing `outputFileName`.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SucceedingStack extends cdk.Stack {
});

// Publish the custom resource output
new cdk.Output(this, 'ResponseMessage', {
new cdk.CfnOutput(this, 'ResponseMessage', {
description: 'The message that came back from the Custom Resource',
value: resource.response
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const app = new cdk.App();

const stack = new cdk.Stack(app, `aws-cdk-cloudwatch`);

const queue = new cdk.Resource(stack, 'queue', { type: 'AWS::SQS::Queue' });
const queue = new cdk.CfnResource(stack, 'queue', { type: 'AWS::SQS::Queue' });

const metric = new cloudwatch.Metric({
namespace: 'AWS/SQS',
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codebuild/lib/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ export class Project extends ProjectBase {
*/
public export(): ProjectImportProps {
return {
projectName: new cdk.Output(this, 'ProjectName', { value: this.projectName }).makeImportValue().toString(),
projectName: new cdk.CfnOutput(this, 'ProjectName', { value: this.projectName }).makeImportValue().toString(),
};
}

Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codecommit/lib/pipeline-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { IRepository } from './repository';
export interface CommonPipelineSourceActionProps extends codepipeline.CommonActionProps {
/**
* The name of the source's output artifact.
* Output artifacts are used by CodePipeline as inputs into other actions.
* CfnOutput artifacts are used by CodePipeline as inputs into other actions.
*
* @default a name will be auto-generated
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codecommit/lib/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ export class Repository extends RepositoryBase {
*/
public export(): RepositoryImportProps {
return {
repositoryName: new cdk.Output(this, 'RepositoryName', { value: this.repositoryName }).makeImportValue().toString()
repositoryName: new cdk.CfnOutput(this, 'RepositoryName', { value: this.repositoryName }).makeImportValue().toString()
};
}

Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codedeploy/lib/lambda/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class LambdaApplication extends cdk.Construct implements ILambdaApplicati

public export(): LambdaApplicationImportProps {
return {
applicationName: new cdk.Output(this, 'ApplicationName', { value: this.applicationName }).makeImportValue().toString()
applicationName: new cdk.CfnOutput(this, 'ApplicationName', { value: this.applicationName }).makeImportValue().toString()
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export class LambdaDeploymentGroup extends cdk.Construct implements ILambdaDeplo
public export(): LambdaDeploymentGroupImportProps {
return {
application: this.application,
deploymentGroupName: new cdk.Output(this, 'DeploymentGroupName', {
deploymentGroupName: new cdk.CfnOutput(this, 'DeploymentGroupName', {
value: this.deploymentGroupName
}).makeImportValue().toString()
};
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codedeploy/lib/server/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class ServerApplication extends cdk.Construct implements IServerApplicati

public export(): ServerApplicationImportProps {
return {
applicationName: new cdk.Output(this, 'ApplicationName', { value: this.applicationName }).makeImportValue().toString()
applicationName: new cdk.CfnOutput(this, 'ApplicationName', { value: this.applicationName }).makeImportValue().toString()
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export class ServerDeploymentConfig extends cdk.Construct implements IServerDepl

public export(): ServerDeploymentConfigImportProps {
return {
deploymentConfigName: new cdk.Output(this, 'DeploymentConfigName', {
deploymentConfigName: new cdk.CfnOutput(this, 'DeploymentConfigName', {
value: this.deploymentConfigName,
}).makeImportValue().toString(),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ export class ServerDeploymentGroup extends ServerDeploymentGroupBase {
public export(): ServerDeploymentGroupImportProps {
return {
application: this.application,
deploymentGroupName: new cdk.Output(this, 'DeploymentGroupName', {
deploymentGroupName: new cdk.CfnOutput(this, 'DeploymentGroupName', {
value: this.deploymentGroupName
}).makeImportValue().toString(),
deploymentConfig: this.deploymentConfig,
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codepipeline-api/lib/artifact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class Artifact {

/**
* Returns an ArtifactPath for a file within this artifact.
* Output is in the form "<artifact-name>::<file-name>"
* CfnOutput is in the form "<artifact-name>::<file-name>"
* @param fileName The name of the file
*/
public atPath(fileName: string): ArtifactPath {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface SourceActionProps extends CommonActionProps {

/**
* The name of the source's output artifact.
* Output artifacts are used by CodePipeline as inputs into other actions.
* CfnOutput artifacts are used by CodePipeline as inputs into other actions.
*/
outputArtifactName: string;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { CfnWebhook } from './codepipeline.generated';
*/
export interface GitHubSourceActionProps extends actions.CommonActionProps {
/**
* The name of the source's output artifact. Output artifacts are used by CodePipeline as
* The name of the source's output artifact. CfnOutput artifacts are used by CodePipeline as
* inputs into other actions.
*/
outputArtifactName: string;
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-codepipeline/lib/jenkins-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ export abstract class BaseJenkinsProvider extends cdk.Construct implements IJenk

public export(): JenkinsProviderImportProps {
return {
providerName: new cdk.Output(this, 'JenkinsProviderName', {
providerName: new cdk.CfnOutput(this, 'JenkinsProviderName', {
value: this.providerName,
}).makeImportValue().toString(),
serverUrl: new cdk.Output(this, 'JenkinsServerUrl', {
serverUrl: new cdk.CfnOutput(this, 'JenkinsServerUrl', {
value: this.serverUrl,
}).makeImportValue().toString(),
version: new cdk.Output(this, 'JenkinsProviderVersion', {
version: new cdk.CfnOutput(this, 'JenkinsProviderVersion', {
value: this.version,
}).makeImportValue().toString(),
};
Expand Down
10 changes: 5 additions & 5 deletions packages/@aws-cdk/aws-cognito/lib/user-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,10 @@ export class UserPool extends cdk.Construct implements IUserPool {

public export(): UserPoolImportProps {
return {
userPoolId: new cdk.Output(this, 'UserPoolId', { value: this.userPoolId }).makeImportValue().toString(),
userPoolArn: new cdk.Output(this, 'UserPoolArn', { value: this.userPoolArn }).makeImportValue().toString(),
userPoolProviderName: new cdk.Output(this, 'UserPoolProviderName', { value: this.userPoolProviderName }).makeImportValue().toString(),
userPoolProviderUrl: new cdk.Output(this, 'UserPoolProviderUrl', { value: this.userPoolProviderUrl }).makeImportValue().toString()
userPoolId: new cdk.CfnOutput(this, 'UserPoolId', { value: this.userPoolId }).makeImportValue().toString(),
userPoolArn: new cdk.CfnOutput(this, 'UserPoolArn', { value: this.userPoolArn }).makeImportValue().toString(),
userPoolProviderName: new cdk.CfnOutput(this, 'UserPoolProviderName', { value: this.userPoolProviderName }).makeImportValue().toString(),
userPoolProviderUrl: new cdk.CfnOutput(this, 'UserPoolProviderUrl', { value: this.userPoolProviderUrl }).makeImportValue().toString()
};
}

Expand Down Expand Up @@ -529,4 +529,4 @@ class ImportedUserPool extends cdk.Construct implements IUserPool {
public export(): UserPoolImportProps {
return this.props;
}
}
}
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-ec2/lib/security-group.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Construct, IConstruct, Output, Token } from '@aws-cdk/cdk';
import { CfnOutput, Construct, IConstruct, Token } from '@aws-cdk/cdk';
import { Connections, IConnectable } from './connections';
import { CfnSecurityGroup, CfnSecurityGroupEgress, CfnSecurityGroupIngress } from './ec2.generated';
import { IPortRange, ISecurityGroupRule } from './security-group-rule';
Expand Down Expand Up @@ -296,7 +296,7 @@ export class SecurityGroup extends SecurityGroupBase {
*/
public export(): SecurityGroupImportProps {
return {
securityGroupId: new Output(this, 'SecurityGroupId', { value: this.securityGroupId }).makeImportValue().toString()
securityGroupId: new CfnOutput(this, 'SecurityGroupId', { value: this.securityGroupId }).makeImportValue().toString()
};
}

Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-ec2/lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class ExportSubnetGroup {

private exportIds(scope: cdk.Construct, name: string): string[] | undefined {
if (this.subnets.length === 0) { return undefined; }
return new cdk.StringListOutput(scope, name, { values: this.subnets.map(s => s.subnetId) }).makeImportValues().map(x => x.toString());
return new cdk.StringListCfnOutput(scope, name, { values: this.subnets.map(s => s.subnetId) }).makeImportValues().map(x => x.toString());
}

/**
Expand Down
Loading

0 comments on commit 5886bf6

Please sign in to comment.