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

feat: deprecate "cloudformation" namespace in favor of "CfnXxx" #1311

Merged
merged 13 commits into from
Dec 13, 2018
14 changes: 7 additions & 7 deletions examples/cdk-examples-typescript/advanced-usage/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cloudformation } from '@aws-cdk/aws-cloudformation';
import { CfnStack } from '@aws-cdk/aws-cloudformation';
import ec2 = require('@aws-cdk/aws-ec2');
import iam = require('@aws-cdk/aws-iam');
import s3 = require('@aws-cdk/aws-s3');
Expand Down Expand Up @@ -55,7 +55,7 @@ class EnvContextExample extends cdk.Stack {
// render construct name based on it's availablity zone
const constructName = `InstanceFor${az.replace(/-/g, '').toUpperCase()}`;

new ec2.cloudformation.InstanceResource(this, constructName, {
new ec2.CfnInstance(this, constructName, {
imageId: ami.imageId,
availabilityZone: az,
});
Expand Down Expand Up @@ -90,7 +90,7 @@ class IncludeExample extends cdk.Stack {

// add constructs (and resources) programmatically
new EnvContextExample(parent, 'Example');
new sqs.cloudformation.QueueResource(this, 'CDKQueue', {});
new sqs.CfnQueue(this, 'CDKQueue', {});
}
}

Expand All @@ -104,7 +104,7 @@ class NestedStackExample extends cdk.Stack {
// add an "AWS::CloudFormation::Stack" resource which uses the MongoDB quickstart
// https://aws.amazon.com/quickstart/architecture/mongodb/
// only non-default values are provided here.
new cloudformation.StackResource(this, 'NestedStack', {
new CfnStack(this, 'NestedStack', {
templateUrl: 'https://s3.amazonaws.com/quickstart-reference/mongodb/latest/templates/mongodb-master.template',
parameters: {
KeyPairName: 'my-key-pair',
Expand All @@ -125,10 +125,10 @@ class ResourceReferencesExample extends cdk.Stack {
constructor(parent: cdk.App, name: string, props?: cdk.StackProps) {
super(parent, name, props);

const topic = new sns.cloudformation.TopicResource(this, 'Topic', {});
const queue = new sqs.cloudformation.QueueResource(this, 'Queue', {});
const topic = new sns.CfnTopic(this, 'Topic', {});
const queue = new sqs.CfnQueue(this, 'Queue', {});

new sns.cloudformation.SubscriptionResource(this, 'Subscription', {
new sns.CfnSubscription(this, 'Subscription', {
topicArn: topic.ref, // resolves to { Ref: <topic-id> }
protocol: 'sqs',
endpoint: queue.queueArn // resolves to { "Fn::GetAtt": [ <queue-id>, "Arn" ] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class CognitoChatRoomPool extends cdk.Construct {
super(parent, name);

// Create chat room user pool
const chatPool = new cognito.cloudformation.UserPoolResource(this, 'UserPool', {
const chatPool = new cognito.CfnUserPool(this, 'UserPool', {
adminCreateUserConfig: {
allowAdminCreateUserOnly: false
},
Expand All @@ -26,7 +26,7 @@ export class CognitoChatRoomPool extends cdk.Construct {
});

// Now for the client
new cognito.cloudformation.UserPoolClientResource(this, 'UserPoolClient', {
new cognito.CfnUserPoolClient(this, 'UserPoolClient', {
clientName: 'Chat-Room',
explicitAuthFlows: [ 'ADMIN_NO_SRP_AUTH' ],
refreshTokenValidity: 30,
Expand Down
2 changes: 1 addition & 1 deletion examples/cdk-examples-typescript/cloudformation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class CloudFormationExample extends cdk.Stack {
constructor(parent: cdk.App) {
super(parent);

new sqs.cloudformation.QueueResource(this, 'MyQueue', {
new sqs.CfnQueue(this, 'MyQueue', {
visibilityTimeout: 300
});
}
Expand Down
4 changes: 2 additions & 2 deletions examples/cdk-examples-typescript/custom-resource/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CustomResource } from '@aws-cdk/aws-cloudformation';
import lambda = require('@aws-cdk/aws-lambda');
import { cloudformation as s3 } from '@aws-cdk/aws-s3';
import { CfnBucket } from '@aws-cdk/aws-s3';
import cdk = require('@aws-cdk/cdk');
import fs = require('fs');

Expand Down Expand Up @@ -86,7 +86,7 @@ class FailAfterCreatingStack extends cdk.Stack {
});

// Bucket with an invalid name will fail the deployment and cause a rollback
const bucket = new s3.BucketResource(this, 'FailingBucket', {
const bucket = new CfnBucket(this, 'FailingBucket', {
bucketName: 'hello!@#$^'
});

Expand Down
8 changes: 4 additions & 4 deletions examples/cdk-examples-typescript/resource-overrides/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ResourceOverridesExample extends cdk.Stack {
encryption: s3.BucketEncryption.KmsManaged
});

const bucketResource2 = bucket.findChild('Resource') as s3.cloudformation.BucketResource;
const bucketResource2 = bucket.findChild('Resource') as s3.CfnBucket;
bucketResource2.addPropertyOverride('BucketEncryption.ServerSideEncryptionConfiguration.0.EncryptEverythingAndAlways', true);
bucketResource2.addPropertyDeletionOverride('BucketEncryption.ServerSideEncryptionConfiguration.0.ServerSideEncryptionByDefault');

Expand All @@ -25,8 +25,8 @@ class ResourceOverridesExample extends cdk.Stack {
// Accessing the L1 bucket resource from an L2 bucket
//

const bucketResource = bucket.findChild('Resource') as s3.cloudformation.BucketResource;
const anotherWay = bucket.children.find(c => (c as cdk.Resource).resourceType === 'AWS::S3::Bucket') as s3.cloudformation.BucketResource;
const bucketResource = bucket.findChild('Resource') as s3.CfnBucket;
const anotherWay = bucket.children.find(c => (c as cdk.Resource).resourceType === 'AWS::S3::Bucket') as s3.CfnBucket;
assert.equal(bucketResource, anotherWay);

//
Expand Down Expand Up @@ -108,7 +108,7 @@ class ResourceOverridesExample extends cdk.Stack {
// need to consule the codebase or use the `.map.find` method above
//

const lc = asg.findChild('LaunchConfig') as autoscaling.cloudformation.LaunchConfigurationResource;
const lc = asg.findChild('LaunchConfig') as autoscaling.CfnLaunchConfiguration;
lc.addPropertyOverride('Foo.Bar', 'Hello');
}
}
Expand Down
8 changes: 4 additions & 4 deletions examples/cdk-examples-typescript/sns-sqs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ class CFN extends cdk.Stack {
constructor(parent: cdk.App, name: string) {
super(parent, name);

const topic = new sns.cloudformation.TopicResource(this, 'MyTopic');
const queue = new sqs.cloudformation.QueueResource(this, 'MyQueue');
const topic = new sns.CfnTopic(this, 'MyTopic');
const queue = new sqs.CfnQueue(this, 'MyQueue');

new sns.cloudformation.SubscriptionResource(this, 'TopicToQueue', {
new sns.CfnSubscription(this, 'TopicToQueue', {
topicArn: topic.ref, // ref == arn for topics
endpoint: queue.queueName,
protocol: 'sqs'
Expand All @@ -36,7 +36,7 @@ class CFN extends cdk.Stack {
.addServicePrincipal('sns.amazonaws.com')
.setCondition('ArnEquals', { 'aws:SourceArn': topic.ref }));

new sqs.cloudformation.QueuePolicyResource(this, 'MyQueuePolicy', {
new sqs.CfnQueuePolicy(this, 'MyQueuePolicy', {
policyDocument,
queues: [ queue.ref ]
});
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,6 +1,6 @@
import cdk = require('@aws-cdk/cdk');
import crypto = require('crypto');
import { cloudformation } from './apigateway.generated';
import { CfnDeployment, CfnDeploymentProps } from './apigateway.generated';
import { RestApiRef } from './restapi-ref';

export interface DeploymentProps {
Expand Down Expand Up @@ -103,13 +103,13 @@ export class Deployment extends cdk.Construct implements cdk.IDependable {
}
}

class LatestDeploymentResource extends cloudformation.DeploymentResource {
class LatestDeploymentResource extends CfnDeployment {
private originalLogicalId?: string;
private lazyLogicalIdRequired: boolean;
private lazyLogicalId?: string;
private hashComponents = new Array<any>();

constructor(parent: cdk.Construct, id: string, props: cloudformation.DeploymentResourceProps) {
constructor(parent: cdk.Construct, id: string, props: CfnDeploymentProps) {
super(parent, id, props);

// from this point, don't allow accessing logical ID before synthesis
Expand Down
8 changes: 4 additions & 4 deletions packages/@aws-cdk/aws-apigateway/lib/method.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import cdk = require('@aws-cdk/cdk');
import { cloudformation } from './apigateway.generated';
import { CfnMethod, CfnMethodProps } from './apigateway.generated';
import { Integration } from './integration';
import { MockIntegration } from './integrations/mock';
import { IRestApiResource } from './resource';
Expand Down Expand Up @@ -83,7 +83,7 @@ export class Method extends cdk.Construct {

const defaultMethodOptions = props.resource.defaultMethodOptions || {};

const methodProps: cloudformation.MethodResourceProps = {
const methodProps: CfnMethodProps = {
resourceId: props.resource.resourceId,
restApiId: this.restApi.restApiId,
httpMethod: props.httpMethod,
Expand All @@ -94,7 +94,7 @@ export class Method extends cdk.Construct {
integration: this.renderIntegration(props.integration)
};

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

this.methodId = resource.ref;

Expand Down Expand Up @@ -134,7 +134,7 @@ export class Method extends cdk.Construct {
return this.restApi.executeApiArn(this.httpMethod, this.resource.resourcePath, 'test-invoke-stage');
}

private renderIntegration(integration?: Integration): cloudformation.MethodResource.IntegrationProperty {
private renderIntegration(integration?: Integration): CfnMethod.IntegrationProperty {
if (!integration) {
// use defaultIntegration from API if defined
if (this.resource.defaultIntegration) {
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-apigateway/lib/resource.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import cdk = require('@aws-cdk/cdk');
import { cloudformation } from './apigateway.generated';
import { CfnResource, CfnResourceProps } from './apigateway.generated';
import { Integration } from './integration';
import { Method, MethodOptions } from './method';
import { RestApi } from './restapi';
Expand Down Expand Up @@ -101,12 +101,12 @@ export class Resource extends cdk.Construct implements IRestApiResource {

validateResourcePathPart(props.pathPart);

const resourceProps: cloudformation.ResourceProps = {
const resourceProps: CfnResourceProps = {
restApiId: props.parent.resourceApi.restApiId,
parentId: props.parent.resourceId,
pathPart: props.pathPart
};
const resource = new cloudformation.Resource(this, 'Resource', resourceProps);
const resource = new CfnResource(this, 'Resource', resourceProps);

this.resourceId = resource.resourceId;
this.resourceApi = props.parent.resourceApi;
Expand Down
8 changes: 4 additions & 4 deletions packages/@aws-cdk/aws-apigateway/lib/restapi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import iam = require('@aws-cdk/aws-iam');
import cdk = require('@aws-cdk/cdk');
import { cloudformation } from './apigateway.generated';
import { CfnAccount, CfnRestApi } from './apigateway.generated';
import { Deployment } from './deployment';
import { Integration } from './integration';
import { Method, MethodOptions } from './method';
Expand Down Expand Up @@ -175,7 +175,7 @@ export class RestApi extends RestApiRef implements cdk.IDependable {
constructor(parent: cdk.Construct, id: string, props: RestApiProps = { }) {
super(parent, id);

const resource = new cloudformation.RestApiResource(this, 'Resource', {
const resource = new CfnRestApi(this, 'Resource', {
name: props.restApiName || id,
description: props.description,
policy: props.policy,
Expand Down Expand Up @@ -315,7 +315,7 @@ export class RestApi extends RestApiRef implements cdk.IDependable {
}
}

private configureCloudWatchRole(apiResource: cloudformation.RestApiResource) {
private configureCloudWatchRole(apiResource: CfnRestApi) {
const role = new iam.Role(this, 'CloudWatchRole', {
assumedBy: new iam.ServicePrincipal('apigateway.amazonaws.com'),
managedPolicyArns: [ cdk.ArnUtils.fromComponents({
Expand All @@ -328,7 +328,7 @@ export class RestApi extends RestApiRef implements cdk.IDependable {
}) ]
});

const resource = new cloudformation.AccountResource(this, 'Account', {
const resource = new CfnAccount(this, 'Account', {
cloudWatchRoleArn: role.roleArn
});

Expand Down
10 changes: 5 additions & 5 deletions packages/@aws-cdk/aws-apigateway/lib/stage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import cdk = require('@aws-cdk/cdk');
import { cloudformation } from './apigateway.generated';
import { CfnStage } from './apigateway.generated';
import { Deployment } from './deployment';
import { RestApiRef } from './restapi-ref';
import { parseMethodOptionsPath } from './util';
Expand Down Expand Up @@ -147,7 +147,7 @@ export class Stage extends cdk.Construct implements cdk.IDependable {
}

const cacheClusterSize = props.cacheClusterEnabled ? (props.cacheClusterSize || '0.5') : undefined;
const resource = new cloudformation.StageResource(this, 'Resource', {
const resource = new CfnStage(this, 'Resource', {
stageName: props.stageName || 'prod',
cacheClusterEnabled: props.cacheClusterEnabled,
cacheClusterSize,
Expand Down Expand Up @@ -176,8 +176,8 @@ export class Stage extends cdk.Construct implements cdk.IDependable {
return `https://${this.restApi.restApiId}.execute-api.${new cdk.AwsRegion()}.amazonaws.com/${this.stageName}${path}`;
}

private renderMethodSettings(props: StageProps): cloudformation.StageResource.MethodSettingProperty[] | undefined {
const settings = new Array<cloudformation.StageResource.MethodSettingProperty>();
private renderMethodSettings(props: StageProps): CfnStage.MethodSettingProperty[] | undefined {
const settings = new Array<CfnStage.MethodSettingProperty>();

// extract common method options from the stage props
const commonMethodOptions: MethodDeploymentOptions = {
Expand Down Expand Up @@ -205,7 +205,7 @@ export class Stage extends cdk.Construct implements cdk.IDependable {

return settings.length === 0 ? undefined : settings;

function renderEntry(path: string, options: MethodDeploymentOptions): cloudformation.StageResource.MethodSettingProperty {
function renderEntry(path: string, options: MethodDeploymentOptions): CfnStage.MethodSettingProperty {
if (options.cachingEnabled) {
if (props.cacheClusterEnabled === undefined) {
props.cacheClusterEnabled = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import iam = require('@aws-cdk/aws-iam');
import cdk = require('@aws-cdk/cdk');
import { cloudformation } from './applicationautoscaling.generated';
import { CfnScalableTarget } from './applicationautoscaling.generated';
import { BasicStepScalingPolicyProps, StepScalingPolicy } from './step-scaling-policy';
import { BasicTargetTrackingScalingPolicyProps, TargetTrackingScalingPolicy } from './target-tracking-scaling-policy';

Expand Down Expand Up @@ -74,7 +74,7 @@ export class ScalableTarget extends cdk.Construct {
*/
public readonly role: iam.IRole;

private readonly actions = new Array<cloudformation.ScalableTargetResource.ScheduledActionProperty>();
private readonly actions = new Array<CfnScalableTarget.ScheduledActionProperty>();

constructor(parent: cdk.Construct, id: string, props: ScalableTargetProps) {
super(parent, id);
Expand All @@ -93,7 +93,7 @@ export class ScalableTarget extends cdk.Construct {
assumedBy: new iam.ServicePrincipal('application-autoscaling.amazonaws.com')
});

const resource = new cloudformation.ScalableTargetResource(this, 'Resource', {
const resource = new CfnScalableTarget(this, 'Resource', {
maxCapacity: props.maxCapacity,
minCapacity: props.minCapacity,
resourceId: props.resourceId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import cloudwatch = require('@aws-cdk/aws-cloudwatch');
import cdk = require('@aws-cdk/cdk');
import { cloudformation } from './applicationautoscaling.generated';
import { CfnScalingPolicy } from './applicationautoscaling.generated';
import { ScalableTarget } from './scalable-target';

/**
Expand Down Expand Up @@ -78,12 +78,12 @@ export class StepScalingAction extends cdk.Construct implements cloudwatch.IAlar
*/
public readonly alarmActionArn: string;

private readonly adjustments = new Array<cloudformation.ScalingPolicyResource.StepAdjustmentProperty>();
private readonly adjustments = new Array<CfnScalingPolicy.StepAdjustmentProperty>();

constructor(parent: cdk.Construct, id: string, props: StepScalingActionProps) {
super(parent, id);

const resource = new cloudformation.ScalingPolicyResource(this, 'Resource', {
const resource = new CfnScalingPolicy(this, 'Resource', {
policyName: props.policyName || this.uniqueId,
policyType: 'StepScaling',
stepScalingPolicyConfiguration: {
Expand All @@ -92,7 +92,7 @@ export class StepScalingAction extends cdk.Construct implements cloudwatch.IAlar
minAdjustmentMagnitude: props.minAdjustmentMagnitude,
metricAggregationType: props.metricAggregationType,
stepAdjustments: new cdk.Token(() => this.adjustments),
} as cloudformation.ScalingPolicyResource.StepScalingPolicyConfigurationProperty
} as CfnScalingPolicy.StepScalingPolicyConfigurationProperty
});

this.scalingPolicyArn = resource.scalingPolicyArn;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import cloudwatch = require('@aws-cdk/aws-cloudwatch');
import cdk = require('@aws-cdk/cdk');
import { cloudformation } from './applicationautoscaling.generated';
import { CfnScalingPolicy } from './applicationautoscaling.generated';
import { ScalableTarget } from './scalable-target';

/**
Expand Down Expand Up @@ -118,7 +118,7 @@ export class TargetTrackingScalingPolicy extends cdk.Construct {

super(parent, id);

const resource = new cloudformation.ScalingPolicyResource(this, 'Resource', {
const resource = new CfnScalingPolicy(this, 'Resource', {
policyName: props.policyName || this.uniqueId,
policyType: 'TargetTrackingScaling',
scalingTargetId: props.scalingTarget.scalableTargetId,
Expand All @@ -139,7 +139,7 @@ export class TargetTrackingScalingPolicy extends cdk.Construct {
}
}

function renderCustomMetric(metric?: cloudwatch.Metric): cloudformation.ScalingPolicyResource.CustomizedMetricSpecificationProperty | undefined {
function renderCustomMetric(metric?: cloudwatch.Metric): CfnScalingPolicy.CustomizedMetricSpecificationProperty | undefined {
if (!metric) { return undefined; }
return {
dimensions: metric.dimensionsAsList(),
Expand Down
Loading