diff --git a/docs/src/aws-construct-lib.rst b/docs/src/aws-construct-lib.rst index 4f71791a92c3f..79b08c204a720 100644 --- a/docs/src/aws-construct-lib.rst +++ b/docs/src/aws-construct-lib.rst @@ -122,9 +122,9 @@ the AWS Construct and patch the underlying resources. AWS constructs, such as :py:class:`Topic <@aws-cdk/aws-sns.Topic>`, encapsulate one or more AWS CloudFormation resources behind their APIs. These resources are -also represented as constructs under the ``cloudformation`` namespace in each +also represented as ``CfnXxx`` constructs in each library. For example, the :py:class:`@aws-cdk/aws-s3.Bucket` construct -encapsulates the :py:class:`@aws-cdk/aws-s3.cloudformation.BucketResource`. When +encapsulates the :py:class:`@aws-cdk/aws-s3.CfnBucket`. When a stack that includes an AWS construct is synthesized, the CloudFormation definition of the underlying resources are included in the resulting template. @@ -167,11 +167,11 @@ given an :py:class:`s3.Bucket <@aws-cdk/s3.Bucket>` construct: const bucket = new s3.Bucket(this, 'MyBucket'); // we use our knowledge that the main construct is called "Resource" and - // that it's actual type is s3.cloudformation.BucketResource; const - const bucketResource = bucket.findChild('Resource') as s3.cloudformation.BucketResource; + // that it's actual type is s3.CfnBucket; const + const bucketResource = bucket.findChild('Resource') as s3.CfnBucket; At this point, ``bucketResource`` represents the low-level CloudFormation resource of type -:py:class:`s3.cloudformation.BucketResource <@aws-cdk/aws-s3.cloudformation.BucketResource>` +:py:class:`s3.CfnBucket <@aws-cdk/aws-s3.CfnBucket>` encapsulated by our bucket. :py:meth:`construct.findChild(id) <@aws-cdk/cdk.Construct.findChild>` will fail @@ -186,7 +186,7 @@ type: const bucketResource = bucket.children.find(c => (c as cdk.Resource).resourceType === 'AWS::S3::Bucket') - as s3.cloudformation.BucketResource; + as s3.CfnBucket; From that point, users are interacting with CloudFormation resource classes (which extend :py:class:`cdk.Resource <@aws-cdk/cdk.Resource>`), so we will look @@ -203,7 +203,7 @@ For example, this code: .. code-block:: ts - const bucketResource = bucket.findChild('Resource') as s3.cloudformation.BucketResource; + const bucketResource = bucket.findChild('Resource') as s3.CfnBucket; bucketResource.options.metadata = { MetadataKey: 'MetadataValue' }; bucketResource.options.updatePolicy = { @@ -321,7 +321,7 @@ to delete values: encryption: s3.BucketEncryption.KmsManaged }); - const bucketResource = bucket.findChild('Resource') as s3.cloudformation.BucketResource; + const bucketResource = bucket.findChild('Resource') as s3.CfnBucket; bucketResource.addPropertyOverride('BucketEncryption.ServerSideEncryptionConfiguration.0.EncryptEverythingAndAlways', true); bucketResource.addPropertyDeletionOverride('BucketEncryption.ServerSideEncryptionConfiguration.0.ServerSideEncryptionByDefault'); @@ -349,19 +349,18 @@ Directly Defining CloudFormation Resources ------------------------------------------- It is also possible to explicitly define CloudFormation resources in your stack. -To that end, instantiate one of the constructs under the ``cloudformation`` -namespace of the dedicated library. +To that end, instantiate one of the ``CfnXxx`` constructs of the dedicated library. .. code-block:: ts - new s3.cloudformation.BucketResource(this, 'MyBucket', { + new s3.CfnBucket(this, 'MyBucket', { analyticsConfigurations: [ // ... ] }); In the rare case where you want to define a resource that doesn't have a -corresponding ``cloudformation`` class (such as a new resource that was not yet +corresponding ``CfnXxx`` class (such as a new resource that was not yet published in the CloudFormation resource specification), you can instantiate the :py:class:`cdk.Resource <@aws-cdk/cdk.Resource>` object: diff --git a/docs/src/cloudformation.rst b/docs/src/cloudformation.rst index e037640b6af05..9ad929c32430f 100644 --- a/docs/src/cloudformation.rst +++ b/docs/src/cloudformation.rst @@ -21,9 +21,9 @@ the :py:class:`@aws-cdk/aws-sns.Topic` construct can be used to define SNS Topics, etc. Under the hood, these constructs are implemented using CloudFormation resources, -which are available under the **cloudformation** namespace of each library. For +which are available under the **CfnXxx** classes in each library. For example, the :py:class:`@aws-cdk/aws-s3.Bucket` construct uses the -:py:class:`@aws-cdk/aws-s3.cloudformation.BucketResource` resource (as well as +:py:class:`@aws-cdk/aws-s3.CfnBucket` resource (as well as other resources, depending on what bucket APIs are used). .. important:: @@ -39,7 +39,7 @@ Resources CloudFormation resource classes are automatically generated from the `AWS CloudFormation Resource Specification `_ -and available under the **cloudformation** namespace of each AWS library. Their +and available under the **CfnXxx** classes of each AWS library. Their API matches 1:1 with how you would use these resources in CloudFormation. When defining CloudFormation resource, the **props** argument of the class @@ -51,11 +51,11 @@ resource encrypted with an AWS managed key you can directly specify the `KmsMasterKeyId `_ property. -.. code-block:: js +.. code-block:: ts - import { cloudformation } from '@aws-cdk/aws-sqs'; + import sqs = require('@aws-cdk/aws-sqs'); - new cloudformation.QueueResource(this, 'MyQueueResource', { + new sqs.CfnQueue(this, 'MyQueueResource', { kmsMasterKeyId: 'alias/aws/sqs' }); @@ -82,14 +82,14 @@ use one of the properties available on the resource object. The following example configures a |LAM| function's dead letter queue to use a the ARN of an |SQS| queue resource. -.. code-block:: js +.. code-block:: ts - import { cloudformation as sqscfn } from '@aws-cdk/aws-sqs'; - import { cloudformation as lambdacfn } from '@aws-cdk/aws-lambda'; + import sqs = require('@aws-cdk/aws-sqs'); + import lambda = require('@aws-cdk/aws-lambda'); - const dlq = new sqscfn.QueueResource(this, { name: 'DLQ' }); + const dlq = new sqs.CfnQueue(this, { name: 'DLQ' }); - new lambdacfn.FunctionResource(this, { + new lambda.CfnFunction(this, { deadLetterConfig: { targetArn: dlq.queueArn } @@ -118,13 +118,13 @@ Parameters .. NEEDS SOME INTRO TEXT -.. code-block:: js +.. code-block:: ts - import { cloudformation } from '@aws-cdk/aws-sns'; + import sns = require('@aws-cdk/aws-sns'); import cdk = require('@aws-cdk/cdk'); const p = new cdk.Parameter(this, 'MyParam', { type: 'String' }); - new cloudformation.TopicResource(this, 'MyTopic', { displayName: p.ref }); + new sns.CfnTopic(this, 'MyTopic', { displayName: p.ref }); .. _outputs: @@ -135,10 +135,10 @@ Outputs .. code-block:: js - import { cloudformation } from '@aws-cdk/aws-sqs'; + import sqs = require('@aws-cdk/aws-sqs'); import cdk = require('@aws-cdk/cdk'); - const queue = new cloudformation.QueueResource(this, 'MyQueue'); + const queue = new sqs.CfnQueue(this, 'MyQueue'); const out = new cdk.Output(this, 'MyQueueArn', { value: queue.queueArn }); const import = out.makeImportValue(); @@ -153,13 +153,13 @@ Conditions .. code-block:: js - import { cloudformation } from '@aws-cdk/aws-sqs'; + import sqs = require('@aws-cdk/aws-sqs'); import cdk = require('@aws-cdk/cdk'); const cond = new cdk.Condition(this, 'MyCondition', { expression: new cdk.FnIf(...) }); - const queue = new cloudformation.QueueResource(this, 'MyQueue'); + const queue = new sqs.CfnQueue(this, 'MyQueue'); queue.options.condition = cond; .. _intrinsic_functions: diff --git a/examples/cdk-examples-typescript/advanced-usage/index.ts b/examples/cdk-examples-typescript/advanced-usage/index.ts index 356b634bf73fe..5c27436deb4aa 100644 --- a/examples/cdk-examples-typescript/advanced-usage/index.ts +++ b/examples/cdk-examples-typescript/advanced-usage/index.ts @@ -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'); @@ -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, }); @@ -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', {}); } } @@ -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', @@ -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: } protocol: 'sqs', endpoint: queue.queueArn // resolves to { "Fn::GetAtt": [ , "Arn" ] } diff --git a/examples/cdk-examples-typescript/chat-app/cognito-chat-room-pool.ts b/examples/cdk-examples-typescript/chat-app/cognito-chat-room-pool.ts index 74d3c5bd77981..148384e5ed4c2 100644 --- a/examples/cdk-examples-typescript/chat-app/cognito-chat-room-pool.ts +++ b/examples/cdk-examples-typescript/chat-app/cognito-chat-room-pool.ts @@ -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 }, @@ -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, diff --git a/examples/cdk-examples-typescript/cloudformation/index.ts b/examples/cdk-examples-typescript/cloudformation/index.ts index f849b004e6b20..e6c9776f541b7 100644 --- a/examples/cdk-examples-typescript/cloudformation/index.ts +++ b/examples/cdk-examples-typescript/cloudformation/index.ts @@ -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 }); } diff --git a/examples/cdk-examples-typescript/custom-resource/index.ts b/examples/cdk-examples-typescript/custom-resource/index.ts index b33fdb391671a..bf1d716d0ab81 100644 --- a/examples/cdk-examples-typescript/custom-resource/index.ts +++ b/examples/cdk-examples-typescript/custom-resource/index.ts @@ -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'); @@ -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!@#$^' }); diff --git a/examples/cdk-examples-typescript/resource-overrides/index.ts b/examples/cdk-examples-typescript/resource-overrides/index.ts index 28242156cee2a..eda4a6b6fae2a 100644 --- a/examples/cdk-examples-typescript/resource-overrides/index.ts +++ b/examples/cdk-examples-typescript/resource-overrides/index.ts @@ -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'); @@ -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); // @@ -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'); } } diff --git a/examples/cdk-examples-typescript/sns-sqs/index.ts b/examples/cdk-examples-typescript/sns-sqs/index.ts index ee08629aae682..6957a48f28cc6 100644 --- a/examples/cdk-examples-typescript/sns-sqs/index.ts +++ b/examples/cdk-examples-typescript/sns-sqs/index.ts @@ -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' @@ -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 ] }); diff --git a/packages/@aws-cdk/aws-apigateway/lib/deployment.ts b/packages/@aws-cdk/aws-apigateway/lib/deployment.ts index 3ad0911511d74..e5a371650e141 100644 --- a/packages/@aws-cdk/aws-apigateway/lib/deployment.ts +++ b/packages/@aws-cdk/aws-apigateway/lib/deployment.ts @@ -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 { @@ -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(); - 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 diff --git a/packages/@aws-cdk/aws-apigateway/lib/method.ts b/packages/@aws-cdk/aws-apigateway/lib/method.ts index 8d6306963a9ac..efc39df09f01d 100644 --- a/packages/@aws-cdk/aws-apigateway/lib/method.ts +++ b/packages/@aws-cdk/aws-apigateway/lib/method.ts @@ -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'; @@ -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, @@ -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; @@ -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) { diff --git a/packages/@aws-cdk/aws-apigateway/lib/resource.ts b/packages/@aws-cdk/aws-apigateway/lib/resource.ts index c4c1d62724e2e..9928bb5087526 100644 --- a/packages/@aws-cdk/aws-apigateway/lib/resource.ts +++ b/packages/@aws-cdk/aws-apigateway/lib/resource.ts @@ -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'; @@ -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; diff --git a/packages/@aws-cdk/aws-apigateway/lib/restapi.ts b/packages/@aws-cdk/aws-apigateway/lib/restapi.ts index a0db6063b556e..e5ea1172c130b 100644 --- a/packages/@aws-cdk/aws-apigateway/lib/restapi.ts +++ b/packages/@aws-cdk/aws-apigateway/lib/restapi.ts @@ -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'; @@ -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, @@ -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({ @@ -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 }); diff --git a/packages/@aws-cdk/aws-apigateway/lib/stage.ts b/packages/@aws-cdk/aws-apigateway/lib/stage.ts index 80cbafd443937..a2bac5bf90e2b 100644 --- a/packages/@aws-cdk/aws-apigateway/lib/stage.ts +++ b/packages/@aws-cdk/aws-apigateway/lib/stage.ts @@ -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'; @@ -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, @@ -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(); + private renderMethodSettings(props: StageProps): CfnStage.MethodSettingProperty[] | undefined { + const settings = new Array(); // extract common method options from the stage props const commonMethodOptions: MethodDeploymentOptions = { @@ -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; diff --git a/packages/@aws-cdk/aws-applicationautoscaling/lib/scalable-target.ts b/packages/@aws-cdk/aws-applicationautoscaling/lib/scalable-target.ts index 3f089474a12a0..1a0fbac75c00a 100644 --- a/packages/@aws-cdk/aws-applicationautoscaling/lib/scalable-target.ts +++ b/packages/@aws-cdk/aws-applicationautoscaling/lib/scalable-target.ts @@ -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'; @@ -74,7 +74,7 @@ export class ScalableTarget extends cdk.Construct { */ public readonly role: iam.IRole; - private readonly actions = new Array(); + private readonly actions = new Array(); constructor(parent: cdk.Construct, id: string, props: ScalableTargetProps) { super(parent, id); @@ -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, diff --git a/packages/@aws-cdk/aws-applicationautoscaling/lib/step-scaling-action.ts b/packages/@aws-cdk/aws-applicationautoscaling/lib/step-scaling-action.ts index 75ec22c9e6a0b..917a71ab98197 100644 --- a/packages/@aws-cdk/aws-applicationautoscaling/lib/step-scaling-action.ts +++ b/packages/@aws-cdk/aws-applicationautoscaling/lib/step-scaling-action.ts @@ -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'; /** @@ -78,12 +78,12 @@ export class StepScalingAction extends cdk.Construct implements cloudwatch.IAlar */ public readonly alarmActionArn: string; - private readonly adjustments = new Array(); + private readonly adjustments = new Array(); 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: { @@ -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; diff --git a/packages/@aws-cdk/aws-applicationautoscaling/lib/target-tracking-scaling-policy.ts b/packages/@aws-cdk/aws-applicationautoscaling/lib/target-tracking-scaling-policy.ts index 655ddf09d065b..4747e1bb0aaec 100644 --- a/packages/@aws-cdk/aws-applicationautoscaling/lib/target-tracking-scaling-policy.ts +++ b/packages/@aws-cdk/aws-applicationautoscaling/lib/target-tracking-scaling-policy.ts @@ -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'; /** @@ -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, @@ -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(), diff --git a/packages/@aws-cdk/aws-autoscaling/lib/auto-scaling-group.ts b/packages/@aws-cdk/aws-autoscaling/lib/auto-scaling-group.ts index ea9fd6b91ef49..0ce9a18e26d4f 100644 --- a/packages/@aws-cdk/aws-autoscaling/lib/auto-scaling-group.ts +++ b/packages/@aws-cdk/aws-autoscaling/lib/auto-scaling-group.ts @@ -6,7 +6,7 @@ import iam = require('@aws-cdk/aws-iam'); import sns = require('@aws-cdk/aws-sns'); import cdk = require('@aws-cdk/cdk'); -import { cloudformation } from './autoscaling.generated'; +import { CfnAutoScalingGroup, CfnAutoScalingGroupProps, CfnLaunchConfiguration } from './autoscaling.generated'; import { BasicLifecycleHookProps, LifecycleHook } from './lifecycle-hook'; import { BasicScheduledActionProps, ScheduledAction } from './scheduled-action'; import { BasicStepScalingPolicyProps, StepScalingPolicy } from './step-scaling-policy'; @@ -189,7 +189,7 @@ export class AutoScalingGroup extends cdk.Construct implements IAutoScalingGroup public readonly autoScalingGroupName: string; private readonly userDataLines = new Array(); - private readonly autoScalingGroup: cloudformation.AutoScalingGroupResource; + private readonly autoScalingGroup: CfnAutoScalingGroup; private readonly securityGroup: ec2.SecurityGroupRef; private readonly securityGroups: ec2.SecurityGroupRef[] = []; private readonly loadBalancerNames: string[] = []; @@ -216,7 +216,7 @@ export class AutoScalingGroup extends cdk.Construct implements IAutoScalingGroup assumedBy: new iam.ServicePrincipal('ec2.amazonaws.com') }); - const iamProfile = new iam.cloudformation.InstanceProfileResource(this, 'InstanceProfile', { + const iamProfile = new iam.CfnInstanceProfile(this, 'InstanceProfile', { roles: [ this.role.roleName ] }); @@ -225,7 +225,7 @@ export class AutoScalingGroup extends cdk.Construct implements IAutoScalingGroup const userDataToken = new cdk.Token(() => new cdk.FnBase64((machineImage.os.createUserData(this.userDataLines)))); const securityGroupsToken = new cdk.Token(() => this.securityGroups.map(sg => sg.securityGroupId)); - const launchConfig = new cloudformation.LaunchConfigurationResource(this, 'LaunchConfig', { + const launchConfig = new CfnLaunchConfiguration(this, 'LaunchConfig', { imageId: machineImage.imageId, keyName: props.keyName, instanceType: props.instanceType.toString(), @@ -247,7 +247,7 @@ export class AutoScalingGroup extends cdk.Construct implements IAutoScalingGroup throw new Error(`Should have minSize (${minSize}) <= desiredCapacity (${desiredCapacity}) <= maxSize (${maxSize})`); } - const asgProps: cloudformation.AutoScalingGroupResourceProps = { + const asgProps: CfnAutoScalingGroupProps = { cooldown: props.cooldownSeconds !== undefined ? `${props.cooldownSeconds}` : undefined, minSize: minSize.toString(), maxSize: maxSize.toString(), @@ -274,7 +274,7 @@ export class AutoScalingGroup extends cdk.Construct implements IAutoScalingGroup const subnets = props.vpc.subnets(props.vpcPlacement); asgProps.vpcZoneIdentifier = subnets.map(n => n.subnetId); - this.autoScalingGroup = new cloudformation.AutoScalingGroupResource(this, 'ASG', asgProps); + this.autoScalingGroup = new CfnAutoScalingGroup(this, 'ASG', asgProps); this.osType = machineImage.os.type; this.autoScalingGroupName = this.autoScalingGroup.autoScalingGroupName; diff --git a/packages/@aws-cdk/aws-autoscaling/lib/lifecycle-hook.ts b/packages/@aws-cdk/aws-autoscaling/lib/lifecycle-hook.ts index 200a6b7045a41..46f7cb018b1c6 100644 --- a/packages/@aws-cdk/aws-autoscaling/lib/lifecycle-hook.ts +++ b/packages/@aws-cdk/aws-autoscaling/lib/lifecycle-hook.ts @@ -2,7 +2,7 @@ import api = require('@aws-cdk/aws-autoscaling-api'); import iam = require('@aws-cdk/aws-iam'); import cdk = require('@aws-cdk/cdk'); import { IAutoScalingGroup } from './auto-scaling-group'; -import { cloudformation } from './autoscaling.generated'; +import { CfnLifecycleHook } from './autoscaling.generated'; import { LazyDependable } from './util'; /** @@ -85,7 +85,7 @@ export class LifecycleHook extends cdk.Construct implements api.ILifecycleHook { const targetProps = props.notificationTarget.asLifecycleHookTarget(this); - const resource = new cloudformation.LifecycleHookResource(this, 'Resource', { + const resource = new CfnLifecycleHook(this, 'Resource', { autoScalingGroupName: props.autoScalingGroup.autoScalingGroupName, defaultResult: props.defaultResult, heartbeatTimeout: props.heartbeatTimeoutSec, diff --git a/packages/@aws-cdk/aws-autoscaling/lib/scheduled-action.ts b/packages/@aws-cdk/aws-autoscaling/lib/scheduled-action.ts index bf47ede41da2c..d6ead67ad2023 100644 --- a/packages/@aws-cdk/aws-autoscaling/lib/scheduled-action.ts +++ b/packages/@aws-cdk/aws-autoscaling/lib/scheduled-action.ts @@ -1,7 +1,7 @@ import cdk = require('@aws-cdk/cdk'); import { IAutoScalingGroup } from './auto-scaling-group'; -import { cloudformation } from './autoscaling.generated'; +import { CfnScheduledAction } from './autoscaling.generated'; /** * Properties for a scheduled scaling action @@ -93,7 +93,7 @@ export class ScheduledAction extends cdk.Construct { throw new Error('At least one of minCapacity, maxCapacity, or desiredCapacity is required'); } - new cloudformation.ScheduledActionResource(this, 'Resource', { + new CfnScheduledAction(this, 'Resource', { autoScalingGroupName: props.autoScalingGroup.autoScalingGroupName, startTime: formatISO(props.startTime), endTime: formatISO(props.endTime), diff --git a/packages/@aws-cdk/aws-autoscaling/lib/step-scaling-action.ts b/packages/@aws-cdk/aws-autoscaling/lib/step-scaling-action.ts index 646308b49dddd..6c9f397f7f8ed 100644 --- a/packages/@aws-cdk/aws-autoscaling/lib/step-scaling-action.ts +++ b/packages/@aws-cdk/aws-autoscaling/lib/step-scaling-action.ts @@ -1,7 +1,7 @@ import cloudwatch = require('@aws-cdk/aws-cloudwatch'); import cdk = require('@aws-cdk/cdk'); import { IAutoScalingGroup } from './auto-scaling-group'; -import { cloudformation } from './autoscaling.generated'; +import { CfnScalingPolicy } from './autoscaling.generated'; /** * Properties for a scaling policy @@ -71,12 +71,12 @@ export class StepScalingAction extends cdk.Construct implements cloudwatch.IAlar */ public readonly alarmActionArn: string; - private readonly adjustments = new Array(); + private readonly adjustments = new Array(); constructor(parent: cdk.Construct, id: string, props: StepScalingActionProps) { super(parent, id); - const resource = new cloudformation.ScalingPolicyResource(this, 'Resource', { + const resource = new CfnScalingPolicy(this, 'Resource', { policyType: 'StepScaling', autoScalingGroupName: props.autoScalingGroup.autoScalingGroupName, cooldown: props.cooldownSeconds !== undefined ? `${props.cooldownSeconds}` : undefined, diff --git a/packages/@aws-cdk/aws-autoscaling/lib/target-tracking-scaling-policy.ts b/packages/@aws-cdk/aws-autoscaling/lib/target-tracking-scaling-policy.ts index 73ae29da57b29..591cada43800d 100644 --- a/packages/@aws-cdk/aws-autoscaling/lib/target-tracking-scaling-policy.ts +++ b/packages/@aws-cdk/aws-autoscaling/lib/target-tracking-scaling-policy.ts @@ -1,7 +1,7 @@ import cloudwatch = require('@aws-cdk/aws-cloudwatch'); import cdk = require('@aws-cdk/cdk'); import { IAutoScalingGroup } from './auto-scaling-group'; -import { cloudformation } from './autoscaling.generated'; +import { CfnScalingPolicy } from './autoscaling.generated'; /** * Base interface for target tracking props @@ -107,7 +107,7 @@ export class TargetTrackingScalingPolicy extends cdk.Construct implements cdk.ID /** * The resource object */ - private resource: cloudformation.ScalingPolicyResource; + private resource: CfnScalingPolicy; constructor(parent: cdk.Construct, id: string, props: TargetTrackingScalingPolicyProps) { if ((props.customMetric === undefined) === (props.predefinedMetric === undefined)) { @@ -128,7 +128,7 @@ export class TargetTrackingScalingPolicy extends cdk.Construct implements cdk.ID super(parent, id); - this.resource = new cloudformation.ScalingPolicyResource(this, 'Resource', { + this.resource = new CfnScalingPolicy(this, 'Resource', { policyType: 'TargetTrackingScaling', autoScalingGroupName: props.autoScalingGroup.autoScalingGroupName, cooldown: props.cooldownSeconds !== undefined ? `${props.cooldownSeconds}` : undefined, @@ -156,7 +156,7 @@ export class TargetTrackingScalingPolicy extends cdk.Construct implements cdk.ID } } -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(), diff --git a/packages/@aws-cdk/aws-certificatemanager/lib/certificate.ts b/packages/@aws-cdk/aws-certificatemanager/lib/certificate.ts index aa0838d28b424..c3fac839df84f 100644 --- a/packages/@aws-cdk/aws-certificatemanager/lib/certificate.ts +++ b/packages/@aws-cdk/aws-certificatemanager/lib/certificate.ts @@ -1,6 +1,6 @@ import { Construct } from '@aws-cdk/cdk'; import { CertificateRef } from './certificate-ref'; -import { cloudformation } from './certificatemanager.generated'; +import { CfnCertificate } from './certificatemanager.generated'; import { apexDomain } from './util'; /** @@ -59,7 +59,7 @@ export class Certificate extends CertificateRef { const allDomainNames = [props.domainName].concat(props.subjectAlternativeNames || []); - const cert = new cloudformation.CertificateResource(this, 'Resource', { + const cert = new CfnCertificate(this, 'Resource', { domainName: props.domainName, subjectAlternativeNames: props.subjectAlternativeNames, domainValidationOptions: allDomainNames.map(domainValidationOption), @@ -72,7 +72,7 @@ export class Certificate extends CertificateRef { * * Closes over props. */ - function domainValidationOption(domainName: string): cloudformation.CertificateResource.DomainValidationOptionProperty { + function domainValidationOption(domainName: string): CfnCertificate.DomainValidationOptionProperty { const overrideDomain = props.validationDomains && props.validationDomains[domainName]; return { domainName, diff --git a/packages/@aws-cdk/aws-cloudformation/lib/custom-resource.ts b/packages/@aws-cdk/aws-cloudformation/lib/custom-resource.ts index 9c4fae592a51b..475ba73f8afa5 100644 --- a/packages/@aws-cdk/aws-cloudformation/lib/custom-resource.ts +++ b/packages/@aws-cdk/aws-cloudformation/lib/custom-resource.ts @@ -1,7 +1,7 @@ import lambda = require('@aws-cdk/aws-lambda'); import sns = require('@aws-cdk/aws-sns'); import cdk = require('@aws-cdk/cdk'); -import { cloudformation } from './cloudformation.generated'; +import { CfnCustomResource } from './cloudformation.generated'; /** * Collection of arbitrary properties @@ -62,7 +62,7 @@ export interface CustomResourceProps { * that hides the choice of provider, and accepts a strongly-typed properties * object with the properties your provider accepts. */ -export class CustomResource extends cloudformation.CustomResource { +export class CustomResource extends CfnCustomResource { // Needs to be implemented using inheritance because we must override the `renderProperties` // The generated props classes will never render properties that they don't know about. diff --git a/packages/@aws-cdk/aws-cloudformation/test/integ.trivial-lambda-resource.ts b/packages/@aws-cdk/aws-cloudformation/test/integ.trivial-lambda-resource.ts index e5a38bd07793e..3055be69a307d 100644 --- a/packages/@aws-cdk/aws-cloudformation/test/integ.trivial-lambda-resource.ts +++ b/packages/@aws-cdk/aws-cloudformation/test/integ.trivial-lambda-resource.ts @@ -1,7 +1,7 @@ import lambda = require('@aws-cdk/aws-lambda'); import cdk = require('@aws-cdk/cdk'); import fs = require('fs'); -import cloudformation = require('../lib'); +import { CustomResource } from '../lib'; interface DemoResourceProps { /** @@ -21,7 +21,7 @@ class DemoResource extends cdk.Construct { constructor(parent: cdk.Construct, name: string, props: DemoResourceProps) { super(parent, name); - const resource = new cloudformation.CustomResource(this, 'Resource', { + const resource = new CustomResource(this, 'Resource', { lambdaProvider: new lambda.SingletonFunction(this, 'Singleton', { uuid: 'f7d4f730-4ee1-11e8-9c2d-fa7ae01bbebc', // This makes the demo only work as top-level TypeScript program, but that's fine for now diff --git a/packages/@aws-cdk/aws-cloudfront/lib/web_distribution.ts b/packages/@aws-cdk/aws-cloudfront/lib/web_distribution.ts index 456c3a0e7021a..d8f575d67b303 100644 --- a/packages/@aws-cdk/aws-cloudfront/lib/web_distribution.ts +++ b/packages/@aws-cdk/aws-cloudfront/lib/web_distribution.ts @@ -1,7 +1,7 @@ import route53 = require('@aws-cdk/aws-route53'); import s3 = require('@aws-cdk/aws-s3'); import cdk = require('@aws-cdk/cdk'); -import { cloudformation } from './cloudfront.generated'; +import { CfnCloudFrontOriginAccessIdentity, CfnDistribution } from './cloudfront.generated'; export enum HttpVersion { HTTP1_1 = "http1.1", @@ -242,7 +242,7 @@ export interface S3OriginConfig { /** * The optional origin identity cloudfront will use when calling your s3 bucket. */ - readonly originAccessIdentity?: cloudformation.CloudFrontOriginAccessIdentityResource + readonly originAccessIdentity?: CfnCloudFrontOriginAccessIdentity } /** @@ -328,7 +328,7 @@ export interface Behavior { * @default none (no cookies - no headers) * */ - forwardedValues?: cloudformation.DistributionResource.ForwardedValuesProperty; + forwardedValues?: CfnDistribution.ForwardedValuesProperty; /** * The minimum amount of time that you want objects to stay in the cache @@ -431,7 +431,7 @@ export interface CloudFrontWebDistributionProps { /** * How CloudFront should handle requests that are no successful (eg PageNotFound) */ - errorConfigurations?: cloudformation.DistributionResource.CustomErrorResponseProperty[]; + errorConfigurations?: CfnDistribution.CustomErrorResponseProperty[]; /** * Optional AWS WAF WebACL to associate with this CloudFront distribution @@ -526,7 +526,7 @@ export class CloudFrontWebDistribution extends cdk.Construct implements route53. constructor(parent: cdk.Construct, name: string, props: CloudFrontWebDistributionProps) { super(parent, name); - const distributionConfig: cloudformation.DistributionResource.DistributionConfigProperty = { + const distributionConfig: CfnDistribution.DistributionConfigProperty = { comment: props.comment, enabled: true, defaultRootObject: props.defaultRootObject !== undefined ? props.defaultRootObject : "index.html", @@ -540,7 +540,7 @@ export class CloudFrontWebDistribution extends cdk.Construct implements route53. const behaviors: BehaviorWithOrigin[] = []; - const origins: cloudformation.DistributionResource.OriginProperty[] = []; + const origins: CfnDistribution.OriginProperty[] = []; let originIndex = 1; for (const originConfig of props.originConfigs) { @@ -552,10 +552,10 @@ export class CloudFrontWebDistribution extends cdk.Construct implements route53. throw new Error("There cannot be both an s3OriginSource and a customOriginSource in the same SourceConfiguration."); } - const originHeaders: cloudformation.DistributionResource.OriginCustomHeaderProperty[] = []; + const originHeaders: CfnDistribution.OriginCustomHeaderProperty[] = []; if (originConfig.originHeaders) { Object.keys(originConfig.originHeaders).forEach(key => { - const oHeader: cloudformation.DistributionResource.OriginCustomHeaderProperty = { + const oHeader: CfnDistribution.OriginCustomHeaderProperty = { headerName: key, headerValue: originConfig.originHeaders![key] }; @@ -563,7 +563,7 @@ export class CloudFrontWebDistribution extends cdk.Construct implements route53. }); } - const originProperty: cloudformation.DistributionResource.OriginProperty = { + const originProperty: CfnDistribution.OriginProperty = { id: originId, domainName: originConfig.s3OriginSource ? originConfig.s3OriginSource.s3BucketSource.domainName : @@ -611,12 +611,12 @@ export class CloudFrontWebDistribution extends cdk.Construct implements route53. throw new Error("There can only be one default behavior across all sources. [ One default behavior per distribution ]."); } distributionConfig.defaultCacheBehavior = this.toBehavior(defaultBehaviors[0]); - const otherBehaviors: cloudformation.DistributionResource.CacheBehaviorProperty[] = []; + const otherBehaviors: CfnDistribution.CacheBehaviorProperty[] = []; for (const behavior of behaviors.filter(b => !b.isDefaultBehavior)) { if (!behavior.pathPattern) { throw new Error("pathPattern is required for all non-default behaviors"); } - otherBehaviors.push(this.toBehavior(behavior) as cloudformation.DistributionResource.CacheBehaviorProperty); + otherBehaviors.push(this.toBehavior(behavior) as CfnDistribution.CacheBehaviorProperty); } distributionConfig.cacheBehaviors = otherBehaviors; @@ -655,7 +655,7 @@ export class CloudFrontWebDistribution extends cdk.Construct implements route53. }; } - const distribution = new cloudformation.DistributionResource(this, 'CFDistribution', { distributionConfig }); + const distribution = new CfnDistribution(this, 'CFDistribution', { distributionConfig }); this.domainName = distribution.distributionDomainName; this.distributionId = distribution.distributionId; } diff --git a/packages/@aws-cdk/aws-cloudtrail/lib/index.ts b/packages/@aws-cdk/aws-cloudtrail/lib/index.ts index 48929535daeb8..8c625b9d6fd91 100644 --- a/packages/@aws-cdk/aws-cloudtrail/lib/index.ts +++ b/packages/@aws-cdk/aws-cloudtrail/lib/index.ts @@ -3,7 +3,7 @@ import kms = require('@aws-cdk/aws-kms'); import logs = require('@aws-cdk/aws-logs'); import s3 = require('@aws-cdk/aws-s3'); import cdk = require('@aws-cdk/cdk'); -import { cloudformation } from './cloudtrail.generated'; +import { CfnTrail } from './cloudtrail.generated'; // AWS::CloudTrail CloudFormation Resources: export * from './cloudtrail.generated'; @@ -144,7 +144,7 @@ export class CloudTrail extends cdk.Construct { .setCondition("StringEquals", {'s3:x-amz-acl': "bucket-owner-full-control"})); if (props.sendToCloudWatchLogs) { - const logGroup = new logs.cloudformation.LogGroupResource(this, "LogGroup", { + const logGroup = new logs.CfnLogGroup(this, "LogGroup", { retentionInDays: props.cloudWatchLogsRetentionTimeDays || LogRetention.OneYear }); this.cloudWatchLogsGroupArn = logGroup.logGroupArn; @@ -167,7 +167,7 @@ export class CloudTrail extends cdk.Construct { } // TODO: not all regions support validation. Use service configuration data to fail gracefully - const trail = new cloudformation.TrailResource(this, 'Resource', { + const trail = new CfnTrail(this, 'Resource', { isLogging: true, enableLogFileValidation: props.enableFileValidation == null ? true : props.enableFileValidation, isMultiRegionTrail: props.isMultiRegionTrail == null ? true : props.isMultiRegionTrail, @@ -182,7 +182,7 @@ export class CloudTrail extends cdk.Construct { eventSelectors: this.eventSelectors }); this.cloudTrailArn = trail.trailArn; - const s3BucketPolicy = s3bucket.findChild("Policy").findChild("Resource") as s3.cloudformation.BucketPolicyResource; + const s3BucketPolicy = s3bucket.findChild("Policy").findChild("Resource") as s3.CfnBucketPolicy; trail.addDependency(s3BucketPolicy); } diff --git a/packages/@aws-cdk/aws-cloudwatch/lib/alarm.ts b/packages/@aws-cdk/aws-cloudwatch/lib/alarm.ts index b88c1a9abdad5..6c05caad19bbc 100644 --- a/packages/@aws-cdk/aws-cloudwatch/lib/alarm.ts +++ b/packages/@aws-cdk/aws-cloudwatch/lib/alarm.ts @@ -1,5 +1,5 @@ import { Construct, Token } from '@aws-cdk/cdk'; -import { cloudformation } from './cloudwatch.generated'; +import { CfnAlarm } from './cloudwatch.generated'; import { HorizontalAnnotation } from './graph'; import { Dimension, Metric, Statistic, Unit } from './metric'; import { parseStatistic } from './util.statistic'; @@ -145,7 +145,7 @@ export class Alarm extends Construct { const comparisonOperator = props.comparisonOperator || ComparisonOperator.GreaterThanOrEqualToThreshold; - const alarm = new cloudformation.AlarmResource(this, 'Resource', { + const alarm = new CfnAlarm(this, 'Resource', { // Meta alarmDescription: props.alarmDescription, alarmName: props.alarmName, diff --git a/packages/@aws-cdk/aws-cloudwatch/lib/dashboard.ts b/packages/@aws-cdk/aws-cloudwatch/lib/dashboard.ts index cd99e6e4bd1bb..ee690a8129a27 100644 --- a/packages/@aws-cdk/aws-cloudwatch/lib/dashboard.ts +++ b/packages/@aws-cdk/aws-cloudwatch/lib/dashboard.ts @@ -1,5 +1,5 @@ import { CloudFormationJSON, Construct, Stack, Token } from "@aws-cdk/cdk"; -import { cloudformation } from './cloudwatch.generated'; +import { CfnDashboard } from './cloudwatch.generated'; import { Column, Row } from "./layout"; import { IWidget } from "./widget"; @@ -17,7 +17,7 @@ export interface DashboardProps { */ export class Dashboard extends Construct { private readonly rows: IWidget[] = []; - private readonly dashboard: cloudformation.DashboardResource; + private readonly dashboard: CfnDashboard; constructor(parent: Construct, name: string, props?: DashboardProps) { super(parent, name); @@ -28,7 +28,7 @@ export class Dashboard extends Construct { // See: https://github.com/awslabs/aws-cdk/issues/213 const dashboardName = (props && props.dashboardName) || new Token(() => this.generateDashboardName()); - this.dashboard = new cloudformation.DashboardResource(this, 'Resource', { + this.dashboard = new CfnDashboard(this, 'Resource', { dashboardName, dashboardBody: new Token(() => { const column = new Column(...this.rows); diff --git a/packages/@aws-cdk/aws-codebuild/lib/artifacts.ts b/packages/@aws-cdk/aws-codebuild/lib/artifacts.ts index e6b66a63ac9a4..c7302042d946c 100644 --- a/packages/@aws-cdk/aws-codebuild/lib/artifacts.ts +++ b/packages/@aws-cdk/aws-codebuild/lib/artifacts.ts @@ -1,5 +1,5 @@ import s3 = require('@aws-cdk/aws-s3'); -import { cloudformation } from './codebuild.generated'; +import { CfnProject } from './codebuild.generated'; import { Project } from './project'; /** @@ -28,7 +28,7 @@ export abstract class BuildArtifacts { return; } - public toArtifactsJSON(): cloudformation.ProjectResource.ArtifactsProperty { + public toArtifactsJSON(): CfnProject.ArtifactsProperty { const artifactsProp = this.toArtifactsProperty(); return { artifactIdentifier: this.identifier, diff --git a/packages/@aws-cdk/aws-codebuild/lib/project.ts b/packages/@aws-cdk/aws-codebuild/lib/project.ts index df61a04ab8fc1..12b72d3450aeb 100644 --- a/packages/@aws-cdk/aws-codebuild/lib/project.ts +++ b/packages/@aws-cdk/aws-codebuild/lib/project.ts @@ -9,7 +9,7 @@ import kms = require('@aws-cdk/aws-kms'); import s3 = require('@aws-cdk/aws-s3'); import cdk = require('@aws-cdk/cdk'); import { BuildArtifacts, CodePipelineBuildArtifacts, NoBuildArtifacts } from './artifacts'; -import { cloudformation } from './codebuild.generated'; +import { CfnProject } from './codebuild.generated'; import { CommonPipelineBuildActionProps, CommonPipelineTestActionProps, PipelineBuildAction, PipelineTestAction @@ -493,7 +493,7 @@ export class Project extends ProjectRef { assumedBy: new iam.ServicePrincipal('codebuild.amazonaws.com') }); - let cache: cloudformation.ProjectResource.ProjectCacheProperty | undefined; + let cache: CfnProject.ProjectCacheProperty | undefined; if (props.cacheBucket) { const cacheDir = props.cacheDir != null ? props.cacheDir : new cdk.AwsNoValue(); cache = { @@ -549,7 +549,7 @@ export class Project extends ProjectRef { this.validateCodePipelineSettings(artifacts); - const resource = new cloudformation.ProjectResource(this, 'Resource', { + const resource = new CfnProject(this, 'Resource', { description: props.description, source: sourceJson, artifacts: artifacts.toArtifactsJSON(), @@ -649,7 +649,7 @@ export class Project extends ProjectRef { private renderEnvironment(env: BuildEnvironment = {}, projectVars: { [name: string]: BuildEnvironmentVariable } = {}): - cloudformation.ProjectResource.EnvironmentProperty { + CfnProject.EnvironmentProperty { const vars: { [name: string]: BuildEnvironmentVariable } = {}; const containerVars = env.environmentVariables || {}; @@ -683,13 +683,13 @@ export class Project extends ProjectRef { }; } - private renderSecondarySources(): cloudformation.ProjectResource.SourceProperty[] | undefined { + private renderSecondarySources(): CfnProject.SourceProperty[] | undefined { return this._secondarySources.length === 0 ? undefined : this._secondarySources.map((secondarySource) => secondarySource.toSourceJSON()); } - private renderSecondaryArtifacts(): cloudformation.ProjectResource.ArtifactsProperty[] | undefined { + private renderSecondaryArtifacts(): CfnProject.ArtifactsProperty[] | undefined { return this._secondaryArtifacts.length === 0 ? undefined : this._secondaryArtifacts.map((secondaryArtifact) => secondaryArtifact.toArtifactsJSON()); diff --git a/packages/@aws-cdk/aws-codebuild/lib/source.ts b/packages/@aws-cdk/aws-codebuild/lib/source.ts index 7e4d9bd2b1150..181767b46a2c9 100644 --- a/packages/@aws-cdk/aws-codebuild/lib/source.ts +++ b/packages/@aws-cdk/aws-codebuild/lib/source.ts @@ -2,7 +2,7 @@ import codecommit = require('@aws-cdk/aws-codecommit'); import iam = require('@aws-cdk/aws-iam'); import s3 = require('@aws-cdk/aws-s3'); import cdk = require('@aws-cdk/cdk'); -import { cloudformation } from './codebuild.generated'; +import { CfnProject } from './codebuild.generated'; import { Project } from './project'; /** @@ -37,7 +37,7 @@ export abstract class BuildSource { return; } - public toSourceJSON(): cloudformation.ProjectResource.SourceProperty { + public toSourceJSON(): CfnProject.SourceProperty { const sourceProp = this.toSourceProperty(); return { sourceIdentifier: this.identifier, diff --git a/packages/@aws-cdk/aws-codecommit/lib/repository.ts b/packages/@aws-cdk/aws-codecommit/lib/repository.ts index 718fd1abd0a8c..a49022376e0e3 100644 --- a/packages/@aws-cdk/aws-codecommit/lib/repository.ts +++ b/packages/@aws-cdk/aws-codecommit/lib/repository.ts @@ -1,7 +1,7 @@ import actions = require('@aws-cdk/aws-codepipeline-api'); import events = require('@aws-cdk/aws-events'); import cdk = require('@aws-cdk/cdk'); -import { cloudformation } from './codecommit.generated'; +import { CfnRepository } from './codecommit.generated'; import { CommonPipelineSourceActionProps, PipelineSourceAction } from './pipeline-action'; /** @@ -222,13 +222,13 @@ export interface RepositoryProps { * Provides a CodeCommit Repository */ export class Repository extends RepositoryRef { - private readonly repository: cloudformation.RepositoryResource; - private readonly triggers = new Array(); + private readonly repository: CfnRepository; + private readonly triggers = new Array(); constructor(parent: cdk.Construct, name: string, props: RepositoryProps) { super(parent, name); - this.repository = new cloudformation.RepositoryResource(this, 'Resource', { + this.repository = new CfnRepository(this, 'Resource', { repositoryName: props.repositoryName, repositoryDescription: props.description, triggers: this.triggers diff --git a/packages/@aws-cdk/aws-codedeploy/lib/application.ts b/packages/@aws-cdk/aws-codedeploy/lib/application.ts index a4c4988d2af89..fb5c7f2049c51 100644 --- a/packages/@aws-cdk/aws-codedeploy/lib/application.ts +++ b/packages/@aws-cdk/aws-codedeploy/lib/application.ts @@ -1,5 +1,5 @@ import cdk = require('@aws-cdk/cdk'); -import { cloudformation } from './codedeploy.generated'; +import { CfnApplication } from './codedeploy.generated'; /** * Properties of a reference to a CodeDeploy EC2/on-premise Application. @@ -84,7 +84,7 @@ export class ServerApplication extends ServerApplicationRef { constructor(parent: cdk.Construct, id: string, props?: ServerApplicationProps) { super(parent, id); - const resource = new cloudformation.ApplicationResource(this, 'Resource', { + const resource = new CfnApplication(this, 'Resource', { applicationName: props && props.applicationName, computePlatform: 'Server', }); diff --git a/packages/@aws-cdk/aws-codedeploy/lib/deployment-config.ts b/packages/@aws-cdk/aws-codedeploy/lib/deployment-config.ts index 320cb9a99f6ac..20e85708926ce 100644 --- a/packages/@aws-cdk/aws-codedeploy/lib/deployment-config.ts +++ b/packages/@aws-cdk/aws-codedeploy/lib/deployment-config.ts @@ -1,5 +1,5 @@ import cdk = require('@aws-cdk/cdk'); -import { cloudformation } from './codedeploy.generated'; +import { CfnDeploymentConfig } from './codedeploy.generated'; /** * The Deployment Configuration of an EC2/on-premise Deployment Group. @@ -121,7 +121,7 @@ export class ServerDeploymentConfig extends ServerDeploymentConfigRef { constructor(parent: cdk.Construct, id: string, props: ServerDeploymentConfigProps) { super(parent, id); - const resource = new cloudformation.DeploymentConfigResource(this, 'Resource', { + const resource = new CfnDeploymentConfig(this, 'Resource', { deploymentConfigName: props.deploymentConfigName, minimumHealthyHosts: this.minimumHealthyHosts(props), }); @@ -131,7 +131,7 @@ export class ServerDeploymentConfig extends ServerDeploymentConfigRef { } private minimumHealthyHosts(props: ServerDeploymentConfigProps): - cloudformation.DeploymentConfigResource.MinimumHealthyHostsProperty { + CfnDeploymentConfig.MinimumHealthyHostsProperty { if (props.minHealthyHostCount === undefined && props.minHealthyHostPercentage === undefined) { throw new Error('At least one of minHealthyHostCount or minHealthyHostPercentage must be specified when creating ' + 'a custom Server DeploymentConfig'); diff --git a/packages/@aws-cdk/aws-codedeploy/lib/deployment-group.ts b/packages/@aws-cdk/aws-codedeploy/lib/deployment-group.ts index 0e506a776d186..95b3557ad70c7 100644 --- a/packages/@aws-cdk/aws-codedeploy/lib/deployment-group.ts +++ b/packages/@aws-cdk/aws-codedeploy/lib/deployment-group.ts @@ -7,7 +7,7 @@ import iam = require('@aws-cdk/aws-iam'); import s3 = require("@aws-cdk/aws-s3"); import cdk = require("@aws-cdk/cdk"); import { ServerApplication, ServerApplicationRef } from "./application"; -import { cloudformation } from './codedeploy.generated'; +import { CfnDeploymentGroup } from './codedeploy.generated'; import { IServerDeploymentConfig, ServerDeploymentConfig } from "./deployment-config"; import { CommonPipelineDeployActionProps, PipelineDeployAction } from "./pipeline-action"; @@ -314,7 +314,7 @@ export class ServerDeploymentGroup extends ServerDeploymentGroupRef { this.alarms = props.alarms || []; - const resource = new cloudformation.DeploymentGroupResource(this, 'Resource', { + const resource = new CfnDeploymentGroup(this, 'Resource', { applicationName: this.application.applicationName, deploymentGroupName: props.deploymentGroupName, serviceRoleArn: this.role.roleArn, @@ -406,7 +406,7 @@ export class ServerDeploymentGroup extends ServerDeploymentGroupRef { } private loadBalancerInfo(lbProvider?: codedeploylb.ILoadBalancer): - cloudformation.DeploymentGroupResource.LoadBalancerInfoProperty | undefined { + CfnDeploymentGroup.LoadBalancerInfoProperty | undefined { if (!lbProvider) { return undefined; } @@ -430,7 +430,7 @@ export class ServerDeploymentGroup extends ServerDeploymentGroupRef { } private ec2TagSet(tagSet?: InstanceTagSet): - cloudformation.DeploymentGroupResource.EC2TagSetProperty | undefined { + CfnDeploymentGroup.EC2TagSetProperty | undefined { if (!tagSet || tagSet.instanceTagGroups.length === 0) { return undefined; } @@ -439,14 +439,14 @@ export class ServerDeploymentGroup extends ServerDeploymentGroupRef { ec2TagSetList: tagSet.instanceTagGroups.map(tagGroup => { return { ec2TagGroup: this.tagGroup2TagsArray(tagGroup) as - cloudformation.DeploymentGroupResource.EC2TagFilterProperty[], + CfnDeploymentGroup.EC2TagFilterProperty[], }; }), }; } private onPremiseTagSet(tagSet?: InstanceTagSet): - cloudformation.DeploymentGroupResource.OnPremisesTagSetProperty | undefined { + CfnDeploymentGroup.OnPremisesTagSetProperty | undefined { if (!tagSet || tagSet.instanceTagGroups.length === 0) { return undefined; } @@ -455,7 +455,7 @@ export class ServerDeploymentGroup extends ServerDeploymentGroupRef { onPremisesTagSetList: tagSet.instanceTagGroups.map(tagGroup => { return { onPremisesTagGroup: this.tagGroup2TagsArray(tagGroup) as - cloudformation.DeploymentGroupResource.TagFilterProperty[], + CfnDeploymentGroup.TagFilterProperty[], }; }), }; @@ -499,7 +499,7 @@ export class ServerDeploymentGroup extends ServerDeploymentGroupRef { } private renderAlarmConfiguration(ignorePollAlarmFailure?: boolean): - cloudformation.DeploymentGroupResource.AlarmConfigurationProperty | undefined { + CfnDeploymentGroup.AlarmConfigurationProperty | undefined { return this.alarms.length === 0 ? undefined : { @@ -510,7 +510,7 @@ export class ServerDeploymentGroup extends ServerDeploymentGroupRef { } private renderAutoRollbackConfiguration(autoRollbackConfig: AutoRollbackConfig = {}): - cloudformation.DeploymentGroupResource.AutoRollbackConfigurationProperty | undefined { + CfnDeploymentGroup.AutoRollbackConfigurationProperty | undefined { const events = new Array(); // we roll back failed deployments by default diff --git a/packages/@aws-cdk/aws-codepipeline/lib/github-source-action.ts b/packages/@aws-cdk/aws-codepipeline/lib/github-source-action.ts index 66e4590048423..398c52f12d35a 100644 --- a/packages/@aws-cdk/aws-codepipeline/lib/github-source-action.ts +++ b/packages/@aws-cdk/aws-codepipeline/lib/github-source-action.ts @@ -1,6 +1,6 @@ import actions = require('@aws-cdk/aws-codepipeline-api'); import cdk = require('@aws-cdk/cdk'); -import { cloudformation } from './codepipeline.generated'; +import { CfnWebhook } from './codepipeline.generated'; /** * Construction properties of the {@link GitHubSourceAction GitHub source action}. @@ -73,7 +73,7 @@ export class GitHubSourceAction extends actions.SourceAction { }); if (!props.pollForSourceChanges) { - new cloudformation.WebhookResource(this, 'WebhookResource', { + new CfnWebhook(this, 'WebhookResource', { authentication: 'GITHUB_HMAC', authenticationConfiguration: { secretToken: props.oauthToken, diff --git a/packages/@aws-cdk/aws-codepipeline/lib/pipeline.ts b/packages/@aws-cdk/aws-codepipeline/lib/pipeline.ts index 5399c01191cc7..4baa3aff60dd7 100644 --- a/packages/@aws-cdk/aws-codepipeline/lib/pipeline.ts +++ b/packages/@aws-cdk/aws-codepipeline/lib/pipeline.ts @@ -3,7 +3,7 @@ import events = require('@aws-cdk/aws-events'); import iam = require('@aws-cdk/aws-iam'); import s3 = require('@aws-cdk/aws-s3'); import cdk = require('@aws-cdk/cdk'); -import { cloudformation } from './codepipeline.generated'; +import { CfnPipeline } from './codepipeline.generated'; import { CrossRegionScaffoldStack } from './cross-region-scaffold-stack'; import { CommonStageProps, Stage, StagePlacement } from './stage'; @@ -83,7 +83,7 @@ export class Pipeline extends cdk.Construct implements cpapi.IPipeline { private readonly stages = new Array(); private eventsRole?: iam.Role; - private readonly pipelineResource: cloudformation.PipelineResource; + private readonly pipelineResource: CfnPipeline; private readonly crossRegionReplicationBuckets: { [region: string]: string }; private readonly artifactStores: { [region: string]: any }; private readonly _crossRegionScaffoldStacks: { [region: string]: CrossRegionScaffoldStack } = {}; @@ -107,7 +107,7 @@ export class Pipeline extends cdk.Construct implements cpapi.IPipeline { assumedBy: new iam.ServicePrincipal('codepipeline.amazonaws.com') }); - const codePipeline = new cloudformation.PipelineResource(this, 'Resource', { + const codePipeline = new CfnPipeline(this, 'Resource', { artifactStore: new cdk.Token(() => this.renderArtifactStore()) as any, stages: new cdk.Token(() => this.renderStages()) as any, roleArn: this.role.roleArn, @@ -431,8 +431,8 @@ export class Pipeline extends cdk.Construct implements cpapi.IPipeline { return []; } - private renderArtifactStore(): cloudformation.PipelineResource.ArtifactStoreProperty { - let encryptionKey: cloudformation.PipelineResource.EncryptionKeyProperty | undefined; + private renderArtifactStore(): CfnPipeline.ArtifactStoreProperty { + let encryptionKey: CfnPipeline.EncryptionKeyProperty | undefined; const bucketKey = this.artifactBucket.encryptionKey; if (bucketKey) { encryptionKey = { @@ -453,7 +453,7 @@ export class Pipeline extends cdk.Construct implements cpapi.IPipeline { }; } - private renderStages(): cloudformation.PipelineResource.StageDeclarationProperty[] { + private renderStages(): CfnPipeline.StageDeclarationProperty[] { // handle cross-region CodePipeline overrides here let crossRegion = false; this.stages.forEach((stage, i) => { diff --git a/packages/@aws-cdk/aws-codepipeline/lib/stage.ts b/packages/@aws-cdk/aws-codepipeline/lib/stage.ts index 683ca1464bf9e..bd1faa6398c80 100644 --- a/packages/@aws-cdk/aws-codepipeline/lib/stage.ts +++ b/packages/@aws-cdk/aws-codepipeline/lib/stage.ts @@ -1,7 +1,7 @@ import cpapi = require('@aws-cdk/aws-codepipeline-api'); import events = require('@aws-cdk/aws-events'); import cdk = require('@aws-cdk/cdk'); -import { cloudformation } from './codepipeline.generated'; +import { CfnPipeline } from './codepipeline.generated'; import { Pipeline } from './pipeline'; /** @@ -109,7 +109,7 @@ export class Stage extends cdk.Construct implements cpapi.IStage, cpapi.IInterna return this.validateHasActions(); } - public render(): cloudformation.PipelineResource.StageDeclarationProperty { + public render(): CfnPipeline.StageDeclarationProperty { return { name: this.id, actions: this._actions.map(action => this.renderAction(action)), @@ -149,7 +149,7 @@ export class Stage extends cdk.Construct implements cpapi.IStage, cpapi.IInterna return (this.pipeline as any)._findInputArtifact(this, action); } - private renderAction(action: cpapi.Action): cloudformation.PipelineResource.ActionDeclarationProperty { + private renderAction(action: cpapi.Action): CfnPipeline.ActionDeclarationProperty { return { name: action.id, inputArtifacts: action._inputArtifacts.map(a => ({ name: a.name })), diff --git a/packages/@aws-cdk/aws-dynamodb/lib/table.ts b/packages/@aws-cdk/aws-dynamodb/lib/table.ts index 783718303cea0..7fae70dfa3dbd 100644 --- a/packages/@aws-cdk/aws-dynamodb/lib/table.ts +++ b/packages/@aws-cdk/aws-dynamodb/lib/table.ts @@ -2,7 +2,7 @@ import appscaling = require('@aws-cdk/aws-applicationautoscaling'); import iam = require('@aws-cdk/aws-iam'); import cdk = require('@aws-cdk/cdk'); import { Construct, TagManager, Tags, Token } from '@aws-cdk/cdk'; -import { cloudformation as dynamodb } from './dynamodb.generated'; +import { CfnTable } from './dynamodb.generated'; import { EnableScalingProps, IScalableTableAttribute } from './scalable-attribute-api'; import { ScalableTableAttribute } from './scalable-table-attribute'; @@ -160,12 +160,12 @@ export class Table extends Construct { public readonly tableName: string; public readonly tableStreamArn: string; - private readonly table: dynamodb.TableResource; + private readonly table: CfnTable; - private readonly keySchema = new Array(); - private readonly attributeDefinitions = new Array(); - private readonly globalSecondaryIndexes = new Array(); - private readonly localSecondaryIndexes = new Array(); + private readonly keySchema = new Array(); + private readonly attributeDefinitions = new Array(); + private readonly globalSecondaryIndexes = new Array(); + private readonly localSecondaryIndexes = new Array(); private readonly secondaryIndexNames: string[] = []; private readonly nonKeyAttributes: string[] = []; @@ -180,7 +180,7 @@ export class Table extends Construct { constructor(parent: Construct, name: string, props: TableProps = {}) { super(parent, name); - this.table = new dynamodb.TableResource(this, 'Resource', { + this.table = new CfnTable(this, 'Resource', { tableName: props.tableName, keySchema: this.keySchema, attributeDefinitions: this.attributeDefinitions, @@ -481,9 +481,9 @@ export class Table extends Construct { }); } - private buildIndexKeySchema(partitionKey: Attribute, sortKey?: Attribute): dynamodb.TableResource.KeySchemaProperty[] { + private buildIndexKeySchema(partitionKey: Attribute, sortKey?: Attribute): CfnTable.KeySchemaProperty[] { this.registerAttribute(partitionKey); - const indexKeySchema: dynamodb.TableResource.KeySchemaProperty[] = [ + const indexKeySchema: CfnTable.KeySchemaProperty[] = [ { attributeName: partitionKey.name, keyType: HASH_KEY_TYPE } ]; @@ -495,7 +495,7 @@ export class Table extends Construct { return indexKeySchema; } - private buildIndexProjection(props: SecondaryIndexProps): dynamodb.TableResource.ProjectionProperty { + private buildIndexProjection(props: SecondaryIndexProps): CfnTable.ProjectionProperty { if (props.projectionType === ProjectionType.Include && !props.nonKeyAttributes) { // https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-projectionobject.html throw new Error(`non-key attributes should be specified when using ${ProjectionType.Include} projection type`); diff --git a/packages/@aws-cdk/aws-ec2/lib/security-group.ts b/packages/@aws-cdk/aws-ec2/lib/security-group.ts index c2d64f1eaa544..8c7f8479fee3f 100644 --- a/packages/@aws-cdk/aws-ec2/lib/security-group.ts +++ b/packages/@aws-cdk/aws-ec2/lib/security-group.ts @@ -1,6 +1,6 @@ import { Construct, ITaggable, Output, TagManager, Tags, Token } from '@aws-cdk/cdk'; import { Connections, IConnectable } from './connections'; -import { cloudformation } from './ec2.generated'; +import { CfnSecurityGroup, CfnSecurityGroupEgress, CfnSecurityGroupIngress } from './ec2.generated'; import { IPortRange, ISecurityGroupRule } from './security-group-rule'; import { VpcNetworkRef } from './vpc-ref'; @@ -40,7 +40,7 @@ export abstract class SecurityGroupRef extends Construct implements ISecurityGro // Skip duplicates if (this.tryFindChild(id) === undefined) { - new cloudformation.SecurityGroupIngressResource(this, id, { + new CfnSecurityGroupIngress(this, id, { groupId: this.securityGroupId, ...peer.toIngressRuleJSON(), ...connection.toRuleJSON(), @@ -58,7 +58,7 @@ export abstract class SecurityGroupRef extends Construct implements ISecurityGro // Skip duplicates if (this.tryFindChild(id) === undefined) { - new cloudformation.SecurityGroupEgressResource(this, id, { + new CfnSecurityGroupEgress(this, id, { groupId: this.securityGroupId, ...peer.toEgressRuleJSON(), ...connection.toRuleJSON(), @@ -156,9 +156,9 @@ export class SecurityGroup extends SecurityGroupRef implements ITaggable { */ public readonly tags: TagManager; - private readonly securityGroup: cloudformation.SecurityGroupResource; - private readonly directIngressRules: cloudformation.SecurityGroupResource.IngressProperty[] = []; - private readonly directEgressRules: cloudformation.SecurityGroupResource.EgressProperty[] = []; + private readonly securityGroup: CfnSecurityGroup; + private readonly directIngressRules: CfnSecurityGroup.IngressProperty[] = []; + private readonly directEgressRules: CfnSecurityGroup.EgressProperty[] = []; private readonly allowAllOutbound: boolean; @@ -170,7 +170,7 @@ export class SecurityGroup extends SecurityGroupRef implements ITaggable { this.allowAllOutbound = props.allowAllOutbound !== false; - this.securityGroup = new cloudformation.SecurityGroupResource(this, 'Resource', { + this.securityGroup = new CfnSecurityGroup(this, 'Resource', { groupName: props.groupName, groupDescription, securityGroupIngress: new Token(() => this.directIngressRules), @@ -246,7 +246,7 @@ export class SecurityGroup extends SecurityGroupRef implements ITaggable { /** * Add a direct ingress rule */ - private addDirectIngressRule(rule: cloudformation.SecurityGroupResource.IngressProperty) { + private addDirectIngressRule(rule: CfnSecurityGroup.IngressProperty) { if (!this.hasIngressRule(rule)) { this.directIngressRules.push(rule); } @@ -255,14 +255,14 @@ export class SecurityGroup extends SecurityGroupRef implements ITaggable { /** * Return whether the given ingress rule exists on the group */ - private hasIngressRule(rule: cloudformation.SecurityGroupResource.IngressProperty): boolean { + private hasIngressRule(rule: CfnSecurityGroup.IngressProperty): boolean { return this.directIngressRules.findIndex(r => ingressRulesEqual(r, rule)) > -1; } /** * Add a direct egress rule */ - private addDirectEgressRule(rule: cloudformation.SecurityGroupResource.EgressProperty) { + private addDirectEgressRule(rule: CfnSecurityGroup.EgressProperty) { if (!this.hasEgressRule(rule)) { this.directEgressRules.push(rule); } @@ -271,7 +271,7 @@ export class SecurityGroup extends SecurityGroupRef implements ITaggable { /** * Return whether the given egress rule exists on the group */ - private hasEgressRule(rule: cloudformation.SecurityGroupResource.EgressProperty): boolean { + private hasEgressRule(rule: CfnSecurityGroup.EgressProperty): boolean { return this.directEgressRules.findIndex(r => egressRulesEqual(r, rule)) > -1; } @@ -391,7 +391,7 @@ class ImportedSecurityGroup extends SecurityGroupRef { /** * Compare two ingress rules for equality the same way CloudFormation would (discarding description) */ -function ingressRulesEqual(a: cloudformation.SecurityGroupResource.IngressProperty, b: cloudformation.SecurityGroupResource.IngressProperty) { +function ingressRulesEqual(a: CfnSecurityGroup.IngressProperty, b: CfnSecurityGroup.IngressProperty) { return a.cidrIp === b.cidrIp && a.cidrIpv6 === b.cidrIpv6 && a.fromPort === b.fromPort @@ -405,7 +405,7 @@ function ingressRulesEqual(a: cloudformation.SecurityGroupResource.IngressProper /** * Compare two egress rules for equality the same way CloudFormation would (discarding description) */ -function egressRulesEqual(a: cloudformation.SecurityGroupResource.EgressProperty, b: cloudformation.SecurityGroupResource.EgressProperty) { +function egressRulesEqual(a: CfnSecurityGroup.EgressProperty, b: CfnSecurityGroup.EgressProperty) { return a.cidrIp === b.cidrIp && a.cidrIpv6 === b.cidrIpv6 && a.fromPort === b.fromPort diff --git a/packages/@aws-cdk/aws-ec2/lib/vpc.ts b/packages/@aws-cdk/aws-ec2/lib/vpc.ts index 20bb8407210b8..04a9a97882316 100644 --- a/packages/@aws-cdk/aws-ec2/lib/vpc.ts +++ b/packages/@aws-cdk/aws-ec2/lib/vpc.ts @@ -1,5 +1,6 @@ import cdk = require('@aws-cdk/cdk'); -import { cloudformation } from './ec2.generated'; +import { CfnEIP, CfnInternetGateway, CfnNatGateway, CfnRoute } from './ec2.generated'; +import { CfnRouteTable, CfnSubnet, CfnSubnetRouteTableAssociation, CfnVPC, CfnVPCGatewayAttachment } from './ec2.generated'; import { NetworkBuilder } from './network-util'; import { DEFAULT_SUBNET_NAME, subnetId } from './util'; import { SubnetType, VpcNetworkRef, VpcPlacementStrategy, VpcSubnetRef } from './vpc-ref'; @@ -241,7 +242,7 @@ export class VpcNetwork extends VpcNetworkRef implements cdk.ITaggable { /** * The VPC resource */ - private resource: cloudformation.VPCResource; + private resource: CfnVPC; /** * The NetworkBuilder @@ -283,7 +284,7 @@ export class VpcNetwork extends VpcNetworkRef implements cdk.ITaggable { const instanceTenancy = props.defaultInstanceTenancy || 'default'; // Define a VPC using the provided CIDR range - this.resource = new cloudformation.VPCResource(this, 'Resource', { + this.resource = new CfnVPC(this, 'Resource', { cidrBlock, enableDnsHostnames, enableDnsSupport, @@ -309,11 +310,11 @@ export class VpcNetwork extends VpcNetworkRef implements cdk.ITaggable { // Create an Internet Gateway and attach it if necessary if (allowOutbound) { - const igw = new cloudformation.InternetGatewayResource(this, 'IGW', { + const igw = new CfnInternetGateway(this, 'IGW', { tags: new cdk.TagManager(this), }); this.internetDependencies.push(igw); - const att = new cloudformation.VPCGatewayAttachmentResource(this, 'VPCGW', { + const att = new CfnVPCGatewayAttachment(this, 'VPCGW', { internetGatewayId: igw.ref, vpcId: this.resource.ref }); @@ -512,7 +513,7 @@ export class VpcSubnet extends VpcSubnetRef implements cdk.ITaggable { this.tags.setTag(NAME_TAG, this.path, {overwrite: false}); this.availabilityZone = props.availabilityZone; - const subnet = new cloudformation.SubnetResource(this, 'Subnet', { + const subnet = new CfnSubnet(this, 'Subnet', { vpcId: props.vpcId, cidrBlock: props.cidrBlock, availabilityZone: props.availabilityZone, @@ -520,14 +521,14 @@ export class VpcSubnet extends VpcSubnetRef implements cdk.ITaggable { tags: this.tags, }); this.subnetId = subnet.subnetId; - const table = new cloudformation.RouteTableResource(this, 'RouteTable', { + const table = new CfnRouteTable(this, 'RouteTable', { vpcId: props.vpcId, tags: new cdk.TagManager(this), }); this.routeTableId = table.ref; // Associate the public route table for this subnet, to this subnet - const routeAssoc = new cloudformation.SubnetRouteTableAssociationResource(this, 'RouteTableAssociation', { + const routeAssoc = new CfnSubnetRouteTableAssociation(this, 'RouteTableAssociation', { subnetId: this.subnetId, routeTableId: table.ref }); @@ -536,7 +537,7 @@ export class VpcSubnet extends VpcSubnetRef implements cdk.ITaggable { } protected addDefaultRouteToNAT(natGatewayId: string) { - new cloudformation.RouteResource(this, `DefaultRoute`, { + new CfnRoute(this, `DefaultRoute`, { routeTableId: this.routeTableId, destinationCidrBlock: '0.0.0.0/0', natGatewayId @@ -548,9 +549,9 @@ export class VpcSubnet extends VpcSubnetRef implements cdk.ITaggable { * on the IGW's attachment to the VPC. */ protected addDefaultRouteToIGW( - gateway: cloudformation.InternetGatewayResource, - gatewayAttachment: cloudformation.VPCGatewayAttachmentResource) { - const route = new cloudformation.RouteResource(this, `DefaultRoute`, { + gateway: CfnInternetGateway, + gatewayAttachment: CfnVPCGatewayAttachment) { + const route = new CfnRoute(this, `DefaultRoute`, { routeTableId: this.routeTableId, destinationCidrBlock: '0.0.0.0/0', gatewayId: gateway.ref @@ -572,8 +573,8 @@ export class VpcPublicSubnet extends VpcSubnet { * on the IGW's attachment to the VPC. */ public addDefaultIGWRouteEntry( - gateway: cloudformation.InternetGatewayResource, - gatewayAttachment: cloudformation.VPCGatewayAttachmentResource) { + gateway: CfnInternetGateway, + gatewayAttachment: CfnVPCGatewayAttachment) { this.addDefaultRouteToIGW(gateway, gatewayAttachment); } @@ -584,9 +585,9 @@ export class VpcPublicSubnet extends VpcSubnet { */ public addNatGateway() { // Create a NAT Gateway in this public subnet - const ngw = new cloudformation.NatGatewayResource(this, `NATGateway`, { + const ngw = new CfnNatGateway(this, `NATGateway`, { subnetId: this.subnetId, - allocationId: new cloudformation.EIPResource(this, `EIP`, { + allocationId: new CfnEIP(this, `EIP`, { domain: 'vpc' }).eipAllocationId, tags: new cdk.TagManager(this), diff --git a/packages/@aws-cdk/aws-ecr/lib/repository.ts b/packages/@aws-cdk/aws-ecr/lib/repository.ts index f77e9232ac539..ee624946368d5 100644 --- a/packages/@aws-cdk/aws-ecr/lib/repository.ts +++ b/packages/@aws-cdk/aws-ecr/lib/repository.ts @@ -1,6 +1,6 @@ import iam = require('@aws-cdk/aws-iam'); import cdk = require('@aws-cdk/cdk'); -import { cloudformation } from './ecr.generated'; +import { CfnRepository } from './ecr.generated'; import { CountType, LifecycleRule, TagStatus } from './lifecycle'; import { RepositoryBase } from "./repository-ref"; @@ -51,7 +51,7 @@ export class Repository extends RepositoryBase { constructor(parent: cdk.Construct, id: string, props: RepositoryProps = {}) { super(parent, id); - const resource = new cloudformation.RepositoryResource(this, 'Resource', { + const resource = new CfnRepository(this, 'Resource', { repositoryName: props.repositoryName, // It says "Text", but they actually mean "Object". repositoryPolicyText: new cdk.Token(() => this.policyDocument), @@ -110,7 +110,7 @@ export class Repository extends RepositoryBase { /** * Render the life cycle policy object */ - private renderLifecyclePolicy(): cloudformation.RepositoryResource.LifecyclePolicyProperty | undefined { + private renderLifecyclePolicy(): CfnRepository.LifecyclePolicyProperty | undefined { let lifecyclePolicyText: any; if (this.lifecycleRules.length === 0 && !this.registryId) { return undefined; } diff --git a/packages/@aws-cdk/aws-ecs/lib/base/base-service.ts b/packages/@aws-cdk/aws-ecs/lib/base/base-service.ts index ba434018de764..abd1ae07fcbdb 100644 --- a/packages/@aws-cdk/aws-ecs/lib/base/base-service.ts +++ b/packages/@aws-cdk/aws-ecs/lib/base/base-service.ts @@ -5,7 +5,7 @@ import elbv2 = require('@aws-cdk/aws-elasticloadbalancingv2'); import iam = require('@aws-cdk/aws-iam'); import cdk = require('@aws-cdk/cdk'); import { NetworkMode, TaskDefinition } from '../base/task-definition'; -import { cloudformation } from '../ecs.generated'; +import { CfnService } from '../ecs.generated'; import { ScalableTaskCount } from './scalable-task-count'; /** @@ -88,9 +88,9 @@ export abstract class BaseService extends cdk.Construct */ public readonly taskDefinition: TaskDefinition; - protected loadBalancers = new Array(); - protected networkConfiguration?: cloudformation.ServiceResource.NetworkConfigurationProperty; - private readonly resource: cloudformation.ServiceResource; + protected loadBalancers = new Array(); + protected networkConfiguration?: CfnService.NetworkConfigurationProperty; + private readonly resource: CfnService; private scalableTaskCount?: ScalableTaskCount; constructor(parent: cdk.Construct, @@ -103,7 +103,7 @@ export abstract class BaseService extends cdk.Construct this.taskDefinition = taskDefinition; - this.resource = new cloudformation.ServiceResource(this, "Service", { + this.resource = new CfnService(this, "Service", { desiredCount: props.desiredCount, serviceName: props.serviceName, loadBalancers: new cdk.Token(() => this.loadBalancers), diff --git a/packages/@aws-cdk/aws-ecs/lib/base/task-definition.ts b/packages/@aws-cdk/aws-ecs/lib/base/task-definition.ts index c90edf81d98a4..7c10a4cbc3653 100644 --- a/packages/@aws-cdk/aws-ecs/lib/base/task-definition.ts +++ b/packages/@aws-cdk/aws-ecs/lib/base/task-definition.ts @@ -1,7 +1,7 @@ import iam = require('@aws-cdk/aws-iam'); import cdk = require('@aws-cdk/cdk'); import { ContainerDefinition, ContainerDefinitionProps } from '../container-definition'; -import { cloudformation } from '../ecs.generated'; +import { CfnTaskDefinition } from '../ecs.generated'; import { isEc2Compatible, isFargateCompatible } from '../util'; /** @@ -141,7 +141,7 @@ export class TaskDefinition extends cdk.Construct { /** * All volumes */ - private readonly volumes: cloudformation.TaskDefinitionResource.VolumeProperty[] = []; + private readonly volumes: CfnTaskDefinition.VolumeProperty[] = []; /** * Execution role for this task definition @@ -153,7 +153,7 @@ export class TaskDefinition extends cdk.Construct { /** * Placement constraints for task instances */ - private readonly placementConstraints = new Array(); + private readonly placementConstraints = new Array(); constructor(parent: cdk.Construct, name: string, props: TaskDefinitionProps) { super(parent, name); @@ -185,7 +185,7 @@ export class TaskDefinition extends cdk.Construct { assumedBy: new iam.ServicePrincipal('ecs-tasks.amazonaws.com'), }); - const taskDef = new cloudformation.TaskDefinitionResource(this, 'Resource', { + const taskDef = new CfnTaskDefinition(this, 'Resource', { containerDefinitions: new cdk.Token(() => this.containers.map(x => x.renderContainerDefinition())), volumes: new cdk.Token(() => this.volumes), executionRoleArn: new cdk.Token(() => this.executionRole && this.executionRole.roleArn), @@ -297,7 +297,7 @@ export class TaskDefinition extends cdk.Construct { /** * Render the placement constraints */ - private renderPlacementConstraint(pc: PlacementConstraint): cloudformation.TaskDefinitionResource.TaskDefinitionPlacementConstraintProperty { + private renderPlacementConstraint(pc: PlacementConstraint): CfnTaskDefinition.TaskDefinitionPlacementConstraintProperty { return { type: pc.type, expression: pc.expression diff --git a/packages/@aws-cdk/aws-ecs/lib/cluster.ts b/packages/@aws-cdk/aws-ecs/lib/cluster.ts index 37fedc3503a66..faa7288f26c05 100644 --- a/packages/@aws-cdk/aws-ecs/lib/cluster.ts +++ b/packages/@aws-cdk/aws-ecs/lib/cluster.ts @@ -4,7 +4,7 @@ import ec2 = require('@aws-cdk/aws-ec2'); import iam = require('@aws-cdk/aws-iam'); import cdk = require('@aws-cdk/cdk'); import { InstanceDrainHook } from './drain-hook/instance-drain-hook'; -import { cloudformation } from './ecs.generated'; +import { CfnCluster } from './ecs.generated'; /** * Properties to define an ECS cluster @@ -62,7 +62,7 @@ export class Cluster extends cdk.Construct implements ICluster { constructor(parent: cdk.Construct, name: string, props: ClusterProps) { super(parent, name); - const cluster = new cloudformation.ClusterResource(this, 'Resource', {clusterName: props.clusterName}); + const cluster = new CfnCluster(this, 'Resource', {clusterName: props.clusterName}); this.vpc = props.vpc; this.clusterArn = cluster.clusterArn; diff --git a/packages/@aws-cdk/aws-ecs/lib/container-definition.ts b/packages/@aws-cdk/aws-ecs/lib/container-definition.ts index 1de953589df77..dfcbaf07959d0 100644 --- a/packages/@aws-cdk/aws-ecs/lib/container-definition.ts +++ b/packages/@aws-cdk/aws-ecs/lib/container-definition.ts @@ -2,7 +2,7 @@ import iam = require('@aws-cdk/aws-iam'); import cdk = require('@aws-cdk/cdk'); import { NetworkMode, TaskDefinition } from './base/task-definition'; import { IContainerImage } from './container-image'; -import { cloudformation } from './ecs.generated'; +import { CfnTaskDefinition } from './ecs.generated'; import { LinuxParameters } from './linux-parameters'; import { LogDriver } from './log-drivers/log-driver'; @@ -351,7 +351,7 @@ export class ContainerDefinition extends cdk.Construct { /** * Render this container definition to a CloudFormation object */ - public renderContainerDefinition(): cloudformation.TaskDefinitionResource.ContainerDefinitionProperty { + public renderContainerDefinition(): CfnTaskDefinition.ContainerDefinitionProperty { return { command: this.props.command, cpu: this.props.cpu, @@ -442,7 +442,7 @@ function renderKV(env: {[key: string]: string}, keyName: string, valueName: stri return ret; } -function renderHealthCheck(hc: HealthCheck): cloudformation.TaskDefinitionResource.HealthCheckProperty { +function renderHealthCheck(hc: HealthCheck): CfnTaskDefinition.HealthCheckProperty { return { command: getHealthCheckCommand(hc), interval: hc.intervalSeconds !== undefined ? hc.intervalSeconds : 30, @@ -517,7 +517,7 @@ export enum UlimitName { Stack = "stack" } -function renderUlimit(ulimit: Ulimit): cloudformation.TaskDefinitionResource.UlimitProperty { +function renderUlimit(ulimit: Ulimit): CfnTaskDefinition.UlimitProperty { return { name: ulimit.name, softLimit: ulimit.softLimit, @@ -568,7 +568,7 @@ export enum Protocol { Udp = "udp", } -function renderPortMapping(pm: PortMapping): cloudformation.TaskDefinitionResource.PortMappingProperty { +function renderPortMapping(pm: PortMapping): CfnTaskDefinition.PortMappingProperty { return { containerPort: pm.containerPort, hostPort: pm.hostPort, @@ -589,7 +589,7 @@ export interface MountPoint { sourceVolume: string, } -function renderMountPoint(mp: MountPoint): cloudformation.TaskDefinitionResource.MountPointProperty { +function renderMountPoint(mp: MountPoint): CfnTaskDefinition.MountPointProperty { return { containerPath: mp.containerPath, readOnly: mp.readOnly, @@ -612,7 +612,7 @@ export interface VolumeFrom { readOnly: boolean, } -function renderVolumeFrom(vf: VolumeFrom): cloudformation.TaskDefinitionResource.VolumeFromProperty { +function renderVolumeFrom(vf: VolumeFrom): CfnTaskDefinition.VolumeFromProperty { return { sourceContainer: vf.sourceContainer, readOnly: vf.readOnly, diff --git a/packages/@aws-cdk/aws-ecs/lib/ec2/ec2-service.ts b/packages/@aws-cdk/aws-ecs/lib/ec2/ec2-service.ts index 36fe21501c959..d28def8fcaf5f 100644 --- a/packages/@aws-cdk/aws-ecs/lib/ec2/ec2-service.ts +++ b/packages/@aws-cdk/aws-ecs/lib/ec2/ec2-service.ts @@ -5,7 +5,7 @@ import cdk = require('@aws-cdk/cdk'); import { BaseService, BaseServiceProps } from '../base/base-service'; import { NetworkMode, TaskDefinition } from '../base/task-definition'; import { ICluster } from '../cluster'; -import { cloudformation } from '../ecs.generated'; +import { CfnService } from '../ecs.generated'; import { isEc2Compatible } from '../util'; /** @@ -67,8 +67,8 @@ export class Ec2Service extends BaseService implements elb.ILoadBalancerTarget { */ public readonly clusterName: string; - private readonly constraints: cloudformation.ServiceResource.PlacementConstraintProperty[]; - private readonly strategies: cloudformation.ServiceResource.PlacementStrategyProperty[]; + private readonly constraints: CfnService.PlacementConstraintProperty[]; + private readonly strategies: CfnService.PlacementStrategyProperty[]; private readonly daemon: boolean; private readonly cluster: ICluster; diff --git a/packages/@aws-cdk/aws-ecs/lib/linux-parameters.ts b/packages/@aws-cdk/aws-ecs/lib/linux-parameters.ts index e3cdb39ba74f2..04f47572e22e7 100644 --- a/packages/@aws-cdk/aws-ecs/lib/linux-parameters.ts +++ b/packages/@aws-cdk/aws-ecs/lib/linux-parameters.ts @@ -1,4 +1,4 @@ -import { cloudformation } from './ecs.generated'; +import { CfnTaskDefinition } from './ecs.generated'; /** * Linux parameter setup in a container @@ -69,7 +69,7 @@ export class LinuxParameters { /** * Render the Linux parameters to a CloudFormation object */ - public renderLinuxParameters(): cloudformation.TaskDefinitionResource.LinuxParametersProperty { + public renderLinuxParameters(): CfnTaskDefinition.LinuxParametersProperty { return { initProcessEnabled: this.initProcessEnabled, sharedMemorySize: this.sharedMemorySize, @@ -107,7 +107,7 @@ export interface Device { permissions?: DevicePermission[] } -function renderDevice(device: Device): cloudformation.TaskDefinitionResource.DeviceProperty { +function renderDevice(device: Device): CfnTaskDefinition.DeviceProperty { return { containerPath: device.containerPath, hostPath: device.hostPath, @@ -135,7 +135,7 @@ export interface Tmpfs { mountOptions?: TmpfsMountOption[], } -function renderTmpfs(tmpfs: Tmpfs): cloudformation.TaskDefinitionResource.TmpfsProperty { +function renderTmpfs(tmpfs: Tmpfs): CfnTaskDefinition.TmpfsProperty { return { containerPath: tmpfs.containerPath, size: tmpfs.size, diff --git a/packages/@aws-cdk/aws-ecs/lib/log-drivers/aws-log-driver.ts b/packages/@aws-cdk/aws-ecs/lib/log-drivers/aws-log-driver.ts index 4627788911382..0a5a445d7e5c0 100644 --- a/packages/@aws-cdk/aws-ecs/lib/log-drivers/aws-log-driver.ts +++ b/packages/@aws-cdk/aws-ecs/lib/log-drivers/aws-log-driver.ts @@ -1,7 +1,7 @@ import logs = require('@aws-cdk/aws-logs'); import cdk = require('@aws-cdk/cdk'); import { ContainerDefinition } from '../container-definition'; -import { cloudformation } from '../ecs.generated'; +import { CfnTaskDefinition } from '../ecs.generated'; import { LogDriver } from "./log-driver"; /** @@ -72,7 +72,7 @@ export class AwsLogDriver extends LogDriver { /** * Return the log driver CloudFormation JSON */ - public renderLogDriver(): cloudformation.TaskDefinitionResource.LogConfigurationProperty { + public renderLogDriver(): CfnTaskDefinition.LogConfigurationProperty { return { logDriver: 'awslogs', options: removeEmpty({ diff --git a/packages/@aws-cdk/aws-ecs/lib/log-drivers/log-driver.ts b/packages/@aws-cdk/aws-ecs/lib/log-drivers/log-driver.ts index 49e7a5c2e225b..bca87e561aa68 100644 --- a/packages/@aws-cdk/aws-ecs/lib/log-drivers/log-driver.ts +++ b/packages/@aws-cdk/aws-ecs/lib/log-drivers/log-driver.ts @@ -1,6 +1,6 @@ import cdk = require('@aws-cdk/cdk'); import { ContainerDefinition } from '../container-definition'; -import { cloudformation } from '../ecs.generated'; +import { CfnTaskDefinition } from '../ecs.generated'; /** * Base class for log drivers @@ -9,7 +9,7 @@ export abstract class LogDriver extends cdk.Construct { /** * Return the log driver CloudFormation JSON */ - public abstract renderLogDriver(): cloudformation.TaskDefinitionResource.LogConfigurationProperty; + public abstract renderLogDriver(): CfnTaskDefinition.LogConfigurationProperty; /** * Called when the log driver is configured on a container diff --git a/packages/@aws-cdk/aws-elasticloadbalancing/lib/load-balancer.ts b/packages/@aws-cdk/aws-elasticloadbalancing/lib/load-balancer.ts index 75ba6921676e9..72573fc92697c 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancing/lib/load-balancer.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancing/lib/load-balancer.ts @@ -2,7 +2,7 @@ import codedeploy = require('@aws-cdk/aws-codedeploy-api'); import { AnyIPv4, Connections, IConnectable, IPortRange, SecurityGroup, SecurityGroupRef, TcpPort, VpcNetworkRef, VpcSubnetRef } from '@aws-cdk/aws-ec2'; import cdk = require('@aws-cdk/cdk'); -import { cloudformation } from './elasticloadbalancing.generated'; +import { CfnLoadBalancer } from './elasticloadbalancing.generated'; /** * Construction properties for a LoadBalancer @@ -197,9 +197,9 @@ export class LoadBalancer extends cdk.Construct implements IConnectable, codedep */ public readonly listenerPorts: ListenerPort[] = []; - private readonly elb: cloudformation.LoadBalancerResource; + private readonly elb: CfnLoadBalancer; private readonly securityGroup: SecurityGroup; - private readonly listeners: cloudformation.LoadBalancerResource.ListenersProperty[] = []; + private readonly listeners: CfnLoadBalancer.ListenersProperty[] = []; private readonly instancePorts: number[] = []; private readonly targets: ILoadBalancerTarget[] = []; @@ -213,7 +213,7 @@ export class LoadBalancer extends cdk.Construct implements IConnectable, codedep // Depending on whether the ELB has public or internal IPs, pick the right backend subnets const subnets: VpcSubnetRef[] = props.internetFacing ? props.vpc.publicSubnets : props.vpc.privateSubnets; - this.elb = new cloudformation.LoadBalancerResource(this, 'Resource', { + this.elb = new CfnLoadBalancer(this, 'Resource', { securityGroups: [ this.securityGroup.securityGroupId ], subnets: subnets.map(s => s.subnetId), listeners: new cdk.Token(() => this.listeners), @@ -378,7 +378,7 @@ function ifUndefinedLazy(x: T | undefined, def: () => T): T { /** * Turn health check parameters into a parameter blob for the LB */ -function healthCheckToJSON(healthCheck: HealthCheck): cloudformation.LoadBalancerResource.HealthCheckProperty { +function healthCheckToJSON(healthCheck: HealthCheck): CfnLoadBalancer.HealthCheckProperty { const protocol = ifUndefined(healthCheck.protocol, ifUndefined(tryWellKnownProtocol(healthCheck.port), LoadBalancingProtocol.Tcp)); diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-listener-certificate.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-listener-certificate.ts index 239cdd545d744..59265225c0e83 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-listener-certificate.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-listener-certificate.ts @@ -1,5 +1,5 @@ import cdk = require('@aws-cdk/cdk'); -import { cloudformation } from '../elasticloadbalancingv2.generated'; +import { CfnListenerCertificate } from '../elasticloadbalancingv2.generated'; import { IApplicationListener } from './application-listener'; /** @@ -31,7 +31,7 @@ export class ApplicationListenerCertificate extends cdk.Construct implements cdk constructor(parent: cdk.Construct, id: string, props: ApplicationListenerCertificateProps) { super(parent, id); - const resource = new cloudformation.ListenerCertificateResource(this, 'Resource', { + const resource = new CfnListenerCertificate(this, 'Resource', { listenerArn: props.listener.listenerArn, certificates: props.certificateArns.map(certificateArn => ({ certificateArn })), }); diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-listener-rule.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-listener-rule.ts index c8c301bb11c74..4b69d8acf6612 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-listener-rule.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-listener-rule.ts @@ -1,5 +1,5 @@ import cdk = require('@aws-cdk/cdk'); -import { cloudformation } from '../elasticloadbalancingv2.generated'; +import { CfnListenerRule } from '../elasticloadbalancingv2.generated'; import { IApplicationListener } from './application-listener'; import { IApplicationTargetGroup } from './application-target-group'; @@ -82,7 +82,7 @@ export class ApplicationListenerRule extends cdk.Construct implements cdk.IDepen this.listener = props.listener; - const resource = new cloudformation.ListenerRuleResource(this, 'Resource', { + const resource = new CfnListenerRule(this, 'Resource', { listenerArn: props.listener.listenerArn, priority: props.priority, conditions: new cdk.Token(() => this.renderConditions()), diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-listener.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-listener.ts index af212853acea7..25cf2a2b506e0 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-listener.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-listener.ts @@ -1,5 +1,5 @@ import cdk = require('@aws-cdk/cdk'); -import { cloudformation } from '../elasticloadbalancingv2.generated'; +import { CfnListener } from '../elasticloadbalancingv2.generated'; import { ITargetGroup } from './base-target-group'; /** @@ -13,7 +13,7 @@ export abstract class BaseListener extends cdk.Construct implements cdk.IDependa constructor(parent: cdk.Construct, id: string, additionalProps: any) { super(parent, id); - const resource = new cloudformation.ListenerResource(this, 'Resource', { + const resource = new CfnListener(this, 'Resource', { ...additionalProps, defaultActions: new cdk.Token(() => this.defaultActions), }); diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-load-balancer.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-load-balancer.ts index 1a43a4cc7fd95..e36b003896456 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-load-balancer.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-load-balancer.ts @@ -1,7 +1,7 @@ import ec2 = require('@aws-cdk/aws-ec2'); import route53 = require('@aws-cdk/aws-route53'); import cdk = require('@aws-cdk/cdk'); -import { cloudformation } from '../elasticloadbalancingv2.generated'; +import { CfnLoadBalancer } from '../elasticloadbalancingv2.generated'; import { Attributes, ifUndefined, renderAttributes } from './util'; /** @@ -103,7 +103,7 @@ export abstract class BaseLoadBalancer extends cdk.Construct implements route53. this.vpc = baseProps.vpc; - const resource = new cloudformation.LoadBalancerResource(this, 'Resource', { + const resource = new CfnLoadBalancer(this, 'Resource', { loadBalancerName: baseProps.loadBalancerName, subnets: subnets.map(s => s.subnetId), scheme: internetFacing ? 'internet-facing' : 'internal', diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-target-group.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-target-group.ts index d433af0ae2c63..4574d4485f7b4 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-target-group.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-target-group.ts @@ -1,7 +1,7 @@ import codedeploy = require('@aws-cdk/aws-codedeploy-api'); import ec2 = require('@aws-cdk/aws-ec2'); import cdk = require('@aws-cdk/cdk'); -import { cloudformation } from '../elasticloadbalancingv2.generated'; +import { CfnTargetGroup } from '../elasticloadbalancingv2.generated'; import { Protocol, TargetType } from './enums'; import { Attributes, LazyDependable, renderAttributes } from './util'; @@ -200,7 +200,7 @@ export abstract class BaseTargetGroup extends cdk.Construct implements ITargetGr /** * The target group resource */ - private readonly resource: cloudformation.TargetGroupResource; + private readonly resource: CfnTargetGroup; constructor(parent: cdk.Construct, id: string, baseProps: BaseTargetGroupProps, additionalProps: any) { super(parent, id); @@ -212,7 +212,7 @@ export abstract class BaseTargetGroup extends cdk.Construct implements ITargetGr this.healthCheck = baseProps.healthCheck || {}; this.targetType = baseProps.targetType; - this.resource = new cloudformation.TargetGroupResource(this, 'Resource', { + this.resource = new CfnTargetGroup(this, 'Resource', { targetGroupName: baseProps.targetGroupName, targetGroupAttributes: new cdk.Token(() => renderAttributes(this.attributes)), targetType: new cdk.Token(() => this.targetType), diff --git a/packages/@aws-cdk/aws-events/lib/rule.ts b/packages/@aws-cdk/aws-events/lib/rule.ts index 3d9ff6716b18f..e64171b6402fb 100644 --- a/packages/@aws-cdk/aws-events/lib/rule.ts +++ b/packages/@aws-cdk/aws-events/lib/rule.ts @@ -1,6 +1,6 @@ import { Construct, FnConcat, Token } from '@aws-cdk/cdk'; import { EventPattern } from './event-pattern'; -import { cloudformation } from './events.generated'; +import { CfnRule } from './events.generated'; import { TargetInputTemplate } from './input-options'; import { EventRuleRef } from './rule-ref'; import { IEventRuleTarget } from './target'; @@ -66,14 +66,14 @@ export interface EventRuleProps { export class EventRule extends EventRuleRef { public readonly ruleArn: string; - private readonly targets = new Array(); + private readonly targets = new Array(); private readonly eventPattern: EventPattern = { }; private scheduleExpression?: string; constructor(parent: Construct, name: string, props: EventRuleProps = { }) { super(parent, name); - const resource = new cloudformation.RuleResource(this, 'Resource', { + const resource = new CfnRule(this, 'Resource', { name: props.ruleName, description: props.description, state: props.enabled == null ? 'ENABLED' : (props.enabled ? 'ENABLED' : 'DISABLED'), @@ -113,7 +113,7 @@ export class EventRule extends EventRuleRef { inputTransformer: renderTransformer(), }); - function renderTransformer(): cloudformation.RuleResource.InputTransformerProperty | undefined { + function renderTransformer(): CfnRule.InputTransformerProperty | undefined { if (!inputOptions) { return undefined; } diff --git a/packages/@aws-cdk/aws-events/lib/target.ts b/packages/@aws-cdk/aws-events/lib/target.ts index 864347f518102..0e191ea1401f5 100644 --- a/packages/@aws-cdk/aws-events/lib/target.ts +++ b/packages/@aws-cdk/aws-events/lib/target.ts @@ -1,4 +1,4 @@ -import { cloudformation } from './events.generated'; +import { CfnRule } from './events.generated'; export interface EventRuleTargetProps { /** @@ -25,20 +25,20 @@ export interface EventRuleTargetProps { * The Amazon ECS task definition and task count to use, if the event target * is an Amazon ECS task. */ - ecsParameters?: cloudformation.RuleResource.EcsParametersProperty; + ecsParameters?: CfnRule.EcsParametersProperty; /** * Settings that control shard assignment, when the target is a Kinesis * stream. If you don't include this parameter, eventId is used as the * partition key. */ - kinesisParameters?: cloudformation.RuleResource.KinesisParametersProperty; + kinesisParameters?: CfnRule.KinesisParametersProperty; /** * Parameters used when the rule invokes Amazon EC2 Systems Manager Run * Command. */ - runCommandParameters?: cloudformation.RuleResource.RunCommandParametersProperty; + runCommandParameters?: CfnRule.RunCommandParametersProperty; } /** diff --git a/packages/@aws-cdk/aws-iam/lib/group.ts b/packages/@aws-cdk/aws-iam/lib/group.ts index fc1ab3dc99613..4f3cda702641f 100644 --- a/packages/@aws-cdk/aws-iam/lib/group.ts +++ b/packages/@aws-cdk/aws-iam/lib/group.ts @@ -1,5 +1,5 @@ import { Construct } from '@aws-cdk/cdk'; -import { cloudformation } from './iam.generated'; +import { CfnGroup } from './iam.generated'; import { IPrincipal, Policy } from './policy'; import { ArnPrincipal, PolicyPrincipal, PolicyStatement } from './policy-document'; import { User } from './user'; @@ -59,7 +59,7 @@ export class Group extends Construct implements IPrincipal { this.managedPolicies = props.managedPolicyArns || []; - const group = new cloudformation.GroupResource(this, 'Resource', { + const group = new CfnGroup(this, 'Resource', { groupName: props.groupName, managedPolicyArns: undefinedIfEmpty(() => this.managedPolicies), path: props.path, diff --git a/packages/@aws-cdk/aws-iam/lib/policy.ts b/packages/@aws-cdk/aws-iam/lib/policy.ts index 15b017a62dd34..1857ddc866728 100644 --- a/packages/@aws-cdk/aws-iam/lib/policy.ts +++ b/packages/@aws-cdk/aws-iam/lib/policy.ts @@ -1,6 +1,6 @@ import { Construct, IDependable, Token } from '@aws-cdk/cdk'; import { Group } from './group'; -import { cloudformation } from './iam.generated'; +import { CfnPolicy } from './iam.generated'; import { PolicyDocument, PolicyPrincipal, PolicyStatement } from './policy-document'; import { Role } from './role'; import { User } from './user'; @@ -106,7 +106,7 @@ export class Policy extends Construct implements IDependable { constructor(parent: Construct, name: string, props: PolicyProps = {}) { super(parent, name); - const resource = new cloudformation.PolicyResource(this, 'Resource', { + const resource = new CfnPolicy(this, 'Resource', { policyDocument: this.document, policyName: new Token(() => this.policyName), roles: undefinedIfEmpty(() => this.roles.map(r => r.roleName)), diff --git a/packages/@aws-cdk/aws-iam/lib/role.ts b/packages/@aws-cdk/aws-iam/lib/role.ts index 65da3d1fe9cae..7b377ef30b427 100644 --- a/packages/@aws-cdk/aws-iam/lib/role.ts +++ b/packages/@aws-cdk/aws-iam/lib/role.ts @@ -1,5 +1,5 @@ import { Construct, IDependable } from '@aws-cdk/cdk'; -import { cloudformation } from './iam.generated'; +import { CfnRole } from './iam.generated'; import { IPrincipal, Policy } from './policy'; import { ArnPrincipal, PolicyDocument, PolicyPrincipal, PolicyStatement } from './policy-document'; import { AttachedPolicies, undefinedIfEmpty } from './util'; @@ -125,7 +125,7 @@ export class Role extends Construct implements IRole { validateMaxSessionDuration(props.maxSessionDurationSec); - const role = new cloudformation.RoleResource(this, 'Resource', { + const role = new CfnRole(this, 'Resource', { assumeRolePolicyDocument: this.assumeRolePolicy as any, managedPolicyArns: undefinedIfEmpty(() => this.managedPolicyArns), policies: _flatten(props.inlinePolicies), @@ -143,7 +143,7 @@ export class Role extends Construct implements IRole { if (policies == null || Object.keys(policies).length === 0) { return undefined; } - const result = new Array(); + const result = new Array(); for (const policyName of Object.keys(policies)) { const policyDocument = policies[policyName]; result.push({ policyName, policyDocument }); diff --git a/packages/@aws-cdk/aws-iam/lib/user.ts b/packages/@aws-cdk/aws-iam/lib/user.ts index 10ae2fa483d98..c2cc0c84faa1a 100644 --- a/packages/@aws-cdk/aws-iam/lib/user.ts +++ b/packages/@aws-cdk/aws-iam/lib/user.ts @@ -1,6 +1,6 @@ import { Construct } from '@aws-cdk/cdk'; import { Group } from './group'; -import { cloudformation } from './iam.generated'; +import { CfnUser } from './iam.generated'; import { IPrincipal, Policy } from './policy'; import { ArnPrincipal, PolicyPrincipal, PolicyStatement } from './policy-document'; import { AttachedPolicies, undefinedIfEmpty } from './util'; @@ -87,7 +87,7 @@ export class User extends Construct implements IPrincipal { constructor(parent: Construct, name: string, props: UserProps = {}) { super(parent, name); - const user = new cloudformation.UserResource(this, 'Resource', { + const user = new CfnUser(this, 'Resource', { userName: props.userName, groups: undefinedIfEmpty(() => this.groups), managedPolicyArns: undefinedIfEmpty(() => this.managedPolicyArns), @@ -139,7 +139,7 @@ export class User extends Construct implements IPrincipal { this.defaultPolicy.addStatement(statement); } - private parseLoginProfile(props: UserProps): cloudformation.UserResource.LoginProfileProperty | undefined { + private parseLoginProfile(props: UserProps): CfnUser.LoginProfileProperty | undefined { if (props.password) { return { password: props.password, diff --git a/packages/@aws-cdk/aws-iam/test/test.legacy-resources.ts b/packages/@aws-cdk/aws-iam/test/test.legacy-resources.ts new file mode 100644 index 0000000000000..c47da3d7a7215 --- /dev/null +++ b/packages/@aws-cdk/aws-iam/test/test.legacy-resources.ts @@ -0,0 +1,24 @@ +import cdk = require('@aws-cdk/cdk'); +import { Test } from 'nodeunit'; +import iam = require('../lib'); + +export = { + 'cloudformation XxxResource emits a warning'(test: Test) { + const app = new cdk.App(); + const stack = new cdk.Stack(app, 'test-stack'); + + new iam.cloudformation.UserResource(stack, 'LegacyResource', { + userName: 'MyUserName' + }); + + const out = app.synthesizeStack('test-stack'); + + const warnings = out.metadata['/test-stack/LegacyResource'].filter(md => md.type === 'aws:cdk:warning'); + test.deepEqual(warnings.length, 1); + test.deepEqual(warnings[0].data, + 'DEPRECATION: \"cloudformation.UserResource\" will be deprecated in a future release in ' + + 'favor of \"CfnUser\" (see https://github.com/awslabs/aws-cdk/issues/878)'); + + test.done(); + } +}; \ No newline at end of file diff --git a/packages/@aws-cdk/aws-kinesis/lib/stream.ts b/packages/@aws-cdk/aws-kinesis/lib/stream.ts index 4a8fc4a755c8f..fb0a550872cae 100644 --- a/packages/@aws-cdk/aws-kinesis/lib/stream.ts +++ b/packages/@aws-cdk/aws-kinesis/lib/stream.ts @@ -2,7 +2,7 @@ import iam = require('@aws-cdk/aws-iam'); import kms = require('@aws-cdk/aws-kms'); import logs = require('@aws-cdk/aws-logs'); import cdk = require('@aws-cdk/cdk'); -import { cloudformation } from './kinesis.generated'; +import { CfnStream } from './kinesis.generated'; /** * A reference to a stream. The easiest way to instantiate is to call @@ -283,7 +283,7 @@ export class Stream extends StreamRef { public readonly streamName: string; public readonly encryptionKey?: kms.EncryptionKeyRef; - private readonly stream: cloudformation.StreamResource; + private readonly stream: CfnStream; constructor(parent: cdk.Construct, name: string, props: StreamProps = {}) { super(parent, name); @@ -296,7 +296,7 @@ export class Stream extends StreamRef { const { streamEncryption, encryptionKey } = this.parseEncryption(props); - this.stream = new cloudformation.StreamResource(this, "Resource", { + this.stream = new CfnStream(this, "Resource", { name: props.streamName, retentionPeriodHours, shardCount, @@ -314,7 +314,7 @@ export class Stream extends StreamRef { * user's configuration. */ private parseEncryption(props: StreamProps): { - streamEncryption?: cloudformation.StreamResource.StreamEncryptionProperty, + streamEncryption?: CfnStream.StreamEncryptionProperty, encryptionKey?: kms.EncryptionKeyRef } { @@ -335,7 +335,7 @@ export class Stream extends StreamRef { description: `Created by ${this.path}` }); - const streamEncryption: cloudformation.StreamResource.StreamEncryptionProperty = { + const streamEncryption: CfnStream.StreamEncryptionProperty = { encryptionType: 'KMS', keyId: encryptionKey.keyArn }; diff --git a/packages/@aws-cdk/aws-kms/lib/alias.ts b/packages/@aws-cdk/aws-kms/lib/alias.ts index 17aaf042b2d24..9f05844243d13 100644 --- a/packages/@aws-cdk/aws-kms/lib/alias.ts +++ b/packages/@aws-cdk/aws-kms/lib/alias.ts @@ -1,6 +1,6 @@ import { Construct } from '@aws-cdk/cdk'; import { EncryptionKeyRef } from './key'; -import { cloudformation } from './kms.generated'; +import { CfnAlias } from './kms.generated'; const REQUIRED_ALIAS_PREFIX = 'alias/'; const DISALLOWED_PREFIX = REQUIRED_ALIAS_PREFIX + 'AWS'; @@ -51,7 +51,7 @@ export class EncryptionKeyAlias extends Construct { throw new Error(`Alias cannot start with ${DISALLOWED_PREFIX}: ${props.alias}`); } - const resource = new cloudformation.AliasResource(this, 'Resource', { + const resource = new CfnAlias(this, 'Resource', { aliasName: props.alias, targetKeyId: props.key.keyArn }); diff --git a/packages/@aws-cdk/aws-kms/lib/key.ts b/packages/@aws-cdk/aws-kms/lib/key.ts index 004e576199e11..999b69ce7e10d 100644 --- a/packages/@aws-cdk/aws-kms/lib/key.ts +++ b/packages/@aws-cdk/aws-kms/lib/key.ts @@ -1,7 +1,7 @@ import { PolicyDocument, PolicyStatement } from '@aws-cdk/aws-iam'; import { Construct, DeletionPolicy, Output, resolve } from '@aws-cdk/cdk'; import { EncryptionKeyAlias } from './alias'; -import { cloudformation } from './kms.generated'; +import { CfnKey } from './kms.generated'; export interface EncryptionKeyRefProps { /** @@ -128,7 +128,7 @@ export class EncryptionKey extends EncryptionKeyRef { this.allowAccountToAdmin(); } - const resource = new cloudformation.KeyResource(this, 'Resource', { + const resource = new CfnKey(this, 'Resource', { description: props.description, enableKeyRotation: props.enableKeyRotation, enabled: props.enabled, diff --git a/packages/@aws-cdk/aws-lambda/lib/alias.ts b/packages/@aws-cdk/aws-lambda/lib/alias.ts index 297cfad57b825..3170a95bc2f4b 100644 --- a/packages/@aws-cdk/aws-lambda/lib/alias.ts +++ b/packages/@aws-cdk/aws-lambda/lib/alias.ts @@ -2,7 +2,7 @@ import iam = require('@aws-cdk/aws-iam'); import cdk = require('@aws-cdk/cdk'); import { FunctionRef } from './lambda-ref'; import { FunctionVersion } from './lambda-version'; -import { cloudformation } from './lambda.generated'; +import { CfnAlias } from './lambda.generated'; import { Permission } from './permission'; /** @@ -85,7 +85,7 @@ export class Alias extends FunctionRef { this.underlyingLambda = props.version.lambda; - const alias = new cloudformation.AliasResource(this, 'Resource', { + const alias = new CfnAlias(this, 'Resource', { name: props.aliasName, description: props.description, functionName: this.underlyingLambda.functionName, diff --git a/packages/@aws-cdk/aws-lambda/lib/code.ts b/packages/@aws-cdk/aws-lambda/lib/code.ts index 33dfc544e7869..22237682d22ea 100644 --- a/packages/@aws-cdk/aws-lambda/lib/code.ts +++ b/packages/@aws-cdk/aws-lambda/lib/code.ts @@ -2,7 +2,7 @@ import assets = require('@aws-cdk/assets'); import s3 = require('@aws-cdk/aws-s3'); import fs = require('fs'); import { Function as Func } from './lambda'; -import { cloudformation } from './lambda.generated'; +import { CfnFunction } from './lambda.generated'; export abstract class Code { /** @@ -54,7 +54,7 @@ export abstract class Code { * Called during stack synthesis to render the CodePropery for the * Lambda function. */ - public abstract toJSON(): cloudformation.FunctionResource.CodeProperty; + public abstract toJSON(): CfnFunction.CodeProperty; /** * Called when the lambda is initialized to allow this object to @@ -81,7 +81,7 @@ export class S3Code extends Code { this.bucketName = bucket.bucketName; } - public toJSON(): cloudformation.FunctionResource.CodeProperty { + public toJSON(): CfnFunction.CodeProperty { return { s3Bucket: this.bucketName, s3Key: this.key, @@ -108,7 +108,7 @@ export class InlineCode extends Code { } } - public toJSON(): cloudformation.FunctionResource.CodeProperty { + public toJSON(): CfnFunction.CodeProperty { return { zipFile: this.code }; @@ -156,7 +156,7 @@ export class AssetCode extends Code { } } - public toJSON(): cloudformation.FunctionResource.CodeProperty { + public toJSON(): CfnFunction.CodeProperty { return { s3Bucket: this.asset!.s3BucketName, s3Key: this.asset!.s3ObjectKey diff --git a/packages/@aws-cdk/aws-lambda/lib/event-source-mapping.ts b/packages/@aws-cdk/aws-lambda/lib/event-source-mapping.ts index 1f6326362dcb7..481658dda5853 100644 --- a/packages/@aws-cdk/aws-lambda/lib/event-source-mapping.ts +++ b/packages/@aws-cdk/aws-lambda/lib/event-source-mapping.ts @@ -1,6 +1,6 @@ import cdk = require('@aws-cdk/cdk'); import { FunctionRef } from './lambda-ref'; -import { cloudformation } from './lambda.generated'; +import { CfnEventSourceMapping } from './lambda.generated'; export interface EventSourceMappingProps { /** @@ -58,7 +58,7 @@ export class EventSourceMapping extends cdk.Construct { constructor(parent: cdk.Construct, id: string, props: EventSourceMappingProps) { super(parent, id); - new cloudformation.EventSourceMappingResource(this, 'Resource', { + new CfnEventSourceMapping(this, 'Resource', { batchSize: props.batchSize, enabled: props.enabled, eventSourceArn: props.eventSourceArn, diff --git a/packages/@aws-cdk/aws-lambda/lib/lambda-ref.ts b/packages/@aws-cdk/aws-lambda/lib/lambda-ref.ts index 14e3bd76cf75f..58ae13e62af25 100644 --- a/packages/@aws-cdk/aws-lambda/lib/lambda-ref.ts +++ b/packages/@aws-cdk/aws-lambda/lib/lambda-ref.ts @@ -8,7 +8,7 @@ import s3n = require('@aws-cdk/aws-s3-notifications'); import stepfunctions = require('@aws-cdk/aws-stepfunctions'); import cdk = require('@aws-cdk/cdk'); import { IEventSource } from './event-source'; -import { cloudformation } from './lambda.generated'; +import { CfnPermission } from './lambda.generated'; import { Permission } from './permission'; import { CommonPipelineInvokeActionProps, PipelineInvokeAction } from './pipeline-action'; @@ -175,7 +175,7 @@ export abstract class FunctionRef extends cdk.Construct const principal = this.parsePermissionPrincipal(permission.principal); const action = permission.action || 'lambda:InvokeFunction'; - new cloudformation.PermissionResource(this, id, { + new CfnPermission(this, id, { action, principal, functionName: this.functionName, diff --git a/packages/@aws-cdk/aws-lambda/lib/lambda-version.ts b/packages/@aws-cdk/aws-lambda/lib/lambda-version.ts index ca574771ee146..d2e058e3d7729 100644 --- a/packages/@aws-cdk/aws-lambda/lib/lambda-version.ts +++ b/packages/@aws-cdk/aws-lambda/lib/lambda-version.ts @@ -1,6 +1,6 @@ import { Construct } from '@aws-cdk/cdk'; import { FunctionRef } from './lambda-ref'; -import { cloudformation } from './lambda.generated'; +import { CfnVersion } from './lambda.generated'; /** * Properties for a new Lambda version @@ -58,7 +58,7 @@ export class FunctionVersion extends Construct { constructor(parent: Construct, name: string, props: FunctionVersionProps) { super(parent, name); - const version = new cloudformation.VersionResource(this, 'Resource', { + const version = new CfnVersion(this, 'Resource', { codeSha256: props.codeSha256, description: props.description, functionName: props.lambda.functionName diff --git a/packages/@aws-cdk/aws-lambda/lib/lambda.ts b/packages/@aws-cdk/aws-lambda/lib/lambda.ts index e7760707f5369..237e8a9e6b4e0 100644 --- a/packages/@aws-cdk/aws-lambda/lib/lambda.ts +++ b/packages/@aws-cdk/aws-lambda/lib/lambda.ts @@ -5,7 +5,7 @@ import cdk = require('@aws-cdk/cdk'); import { Code } from './code'; import { FunctionRef } from './lambda-ref'; import { FunctionVersion } from './lambda-version'; -import { cloudformation } from './lambda.generated'; +import { CfnFunction } from './lambda.generated'; import { Runtime } from './runtime'; /** @@ -241,7 +241,7 @@ export class Function extends FunctionRef { this.role.addToPolicy(statement); } - const resource = new cloudformation.FunctionResource(this, 'Resource', { + const resource = new CfnFunction(this, 'Resource', { functionName: props.functionName, description: props.description, code: new cdk.Token(() => props.code.toJSON()), @@ -321,7 +321,7 @@ export class Function extends FunctionRef { * Returns the VpcConfig that should be added to the * Lambda creation properties. */ - private configureVpc(props: FunctionProps): cloudformation.FunctionResource.VpcConfigProperty | undefined { + private configureVpc(props: FunctionProps): CfnFunction.VpcConfigProperty | undefined { if ((props.securityGroup || props.allowAllOutbound !== undefined) && !props.vpc) { throw new Error(`Cannot configure 'securityGroup' or 'allowAllOutbound' without configuring a VPC`); } diff --git a/packages/@aws-cdk/aws-logs/lib/cross-account-destination.ts b/packages/@aws-cdk/aws-logs/lib/cross-account-destination.ts index 3843a08c6e0b0..46e4adbf5dfd8 100644 --- a/packages/@aws-cdk/aws-logs/lib/cross-account-destination.ts +++ b/packages/@aws-cdk/aws-logs/lib/cross-account-destination.ts @@ -1,7 +1,7 @@ import iam = require('@aws-cdk/aws-iam'); import cdk = require('@aws-cdk/cdk'); import { LogGroupRef } from './log-group'; -import { cloudformation } from './logs.generated'; +import { CfnDestination } from './logs.generated'; import { ILogSubscriptionDestination, LogSubscriptionDestination } from './subscription-filter'; export interface CrossAccountDestinationProps { @@ -54,7 +54,7 @@ export class CrossAccountDestination extends cdk.Construct implements ILogSubscr /** * The inner resource */ - private readonly resource: cloudformation.DestinationResource; + private readonly resource: CfnDestination; constructor(parent: cdk.Construct, id: string, props: CrossAccountDestinationProps) { super(parent, id); @@ -62,7 +62,7 @@ export class CrossAccountDestination extends cdk.Construct implements ILogSubscr // In the underlying model, the name is not optional, but we make it so anyway. const destinationName = props.destinationName || new cdk.Token(() => this.generateUniqueName()); - this.resource = new cloudformation.DestinationResource(this, 'Resource', { + this.resource = new CfnDestination(this, 'Resource', { destinationName, // Must be stringified policy destinationPolicy: new cdk.Token(() => this.stringifiedPolicyDocument()), diff --git a/packages/@aws-cdk/aws-logs/lib/log-group.ts b/packages/@aws-cdk/aws-logs/lib/log-group.ts index ef50acd8f2694..bf27df4338963 100644 --- a/packages/@aws-cdk/aws-logs/lib/log-group.ts +++ b/packages/@aws-cdk/aws-logs/lib/log-group.ts @@ -2,7 +2,7 @@ import cloudwatch = require('@aws-cdk/aws-cloudwatch'); import iam = require('@aws-cdk/aws-iam'); import cdk = require('@aws-cdk/cdk'); import { LogStream } from './log-stream'; -import { cloudformation } from './logs.generated'; +import { CfnLogGroup } from './logs.generated'; import { MetricFilter } from './metric-filter'; import { FilterPattern, IFilterPattern } from './pattern'; import { ILogSubscriptionDestination, SubscriptionFilter } from './subscription-filter'; @@ -191,7 +191,7 @@ export class LogGroup extends LogGroupRef { throw new Error(`retentionInDays must be positive, got ${retentionInDays}`); } - const resource = new cloudformation.LogGroupResource(this, 'Resource', { + const resource = new CfnLogGroup(this, 'Resource', { logGroupName: props.logGroupName, retentionInDays, }); diff --git a/packages/@aws-cdk/aws-logs/lib/log-stream.ts b/packages/@aws-cdk/aws-logs/lib/log-stream.ts index c44cfd4431e30..6387bad4e9e45 100644 --- a/packages/@aws-cdk/aws-logs/lib/log-stream.ts +++ b/packages/@aws-cdk/aws-logs/lib/log-stream.ts @@ -1,6 +1,6 @@ import cdk = require('@aws-cdk/cdk'); import { LogGroupRef } from './log-group'; -import { cloudformation } from './logs.generated'; +import { CfnLogStream } from './logs.generated'; /** * Properties for importing a LogStream @@ -79,7 +79,7 @@ export class LogStream extends LogStreamRef { constructor(parent: cdk.Construct, id: string, props: LogStreamProps) { super(parent, id); - const resource = new cloudformation.LogStreamResource(this, 'Resource', { + const resource = new CfnLogStream(this, 'Resource', { logGroupName: props.logGroup.logGroupName, logStreamName: props.logStreamName }); diff --git a/packages/@aws-cdk/aws-logs/lib/metric-filter.ts b/packages/@aws-cdk/aws-logs/lib/metric-filter.ts index 068df9e032873..9e3881df94b54 100644 --- a/packages/@aws-cdk/aws-logs/lib/metric-filter.ts +++ b/packages/@aws-cdk/aws-logs/lib/metric-filter.ts @@ -1,6 +1,6 @@ import cdk = require('@aws-cdk/cdk'); import { LogGroupRef } from './log-group'; -import { cloudformation } from './logs.generated'; +import { CfnMetricFilter } from './logs.generated'; import { IFilterPattern } from './pattern'; /** @@ -67,7 +67,7 @@ export class MetricFilter extends cdk.Construct { // > transformations, you must specify multiple metric filters. // // https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-metricfilter.html - new cloudformation.MetricFilterResource(this, 'Resource', { + new CfnMetricFilter(this, 'Resource', { logGroupName: props.logGroup.logGroupName, filterPattern: props.filterPattern.logPatternString, metricTransformations: [{ diff --git a/packages/@aws-cdk/aws-logs/lib/subscription-filter.ts b/packages/@aws-cdk/aws-logs/lib/subscription-filter.ts index 67728cb155436..c5f7850807ce0 100644 --- a/packages/@aws-cdk/aws-logs/lib/subscription-filter.ts +++ b/packages/@aws-cdk/aws-logs/lib/subscription-filter.ts @@ -1,7 +1,7 @@ import iam = require('@aws-cdk/aws-iam'); import cdk = require('@aws-cdk/cdk'); import { LogGroupRef } from './log-group'; -import { cloudformation } from './logs.generated'; +import { CfnSubscriptionFilter } from './logs.generated'; import { IFilterPattern } from './pattern'; /** @@ -69,7 +69,7 @@ export class SubscriptionFilter extends cdk.Construct { const destProps = props.destination.logSubscriptionDestination(props.logGroup); - new cloudformation.SubscriptionFilterResource(this, 'Resource', { + new CfnSubscriptionFilter(this, 'Resource', { logGroupName: props.logGroup.logGroupName, destinationArn: destProps.arn, roleArn: destProps.role && destProps.role.roleArn, diff --git a/packages/@aws-cdk/aws-quickstarts/lib/database.ts b/packages/@aws-cdk/aws-quickstarts/lib/database.ts index 69d582b48afda..7ef5ef5a04e46 100644 --- a/packages/@aws-cdk/aws-quickstarts/lib/database.ts +++ b/packages/@aws-cdk/aws-quickstarts/lib/database.ts @@ -28,14 +28,14 @@ export class SqlServer extends cdk.Construct implements ec2.IConnectable { description: 'Database security group', }); - const subnetGroup = new rds.cloudformation.DBSubnetGroupResource(this, 'Subnet', { + const subnetGroup = new rds.CfnDBSubnetGroup(this, 'Subnet', { subnetIds: props.vpc.privateSubnets.map(privateSubnet => privateSubnet.subnetId), dbSubnetGroupDescription: 'Database subnet group', }); const allocatedStorage = props.allocatedStorage !== undefined ? props.allocatedStorage : 200; - new rds.cloudformation.DBInstanceResource(this, 'Resource', { + new rds.CfnDBInstance(this, 'Resource', { allocatedStorage: allocatedStorage.toString(), dbInstanceClass: props.instanceClass || 'db.m4.large', engine: props.engine || 'sqlserver-se', diff --git a/packages/@aws-cdk/aws-quickstarts/lib/rdgw.ts b/packages/@aws-cdk/aws-quickstarts/lib/rdgw.ts index 54b9bc688e9d2..e1832d83fb9b5 100644 --- a/packages/@aws-cdk/aws-quickstarts/lib/rdgw.ts +++ b/packages/@aws-cdk/aws-quickstarts/lib/rdgw.ts @@ -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 cdk = require('@aws-cdk/cdk'); @@ -42,7 +42,7 @@ export class RemoteDesktopGateway extends cdk.Construct implements ec2.IConnecta RDGWInstanceType: props.rdgwInstanceType, }; - const nestedStack = new cloudformation.StackResource(this, 'Resource', { + const nestedStack = new CfnStack(this, 'Resource', { templateUrl: 'https://s3.amazonaws.com/quickstart-reference/microsoft/rdgateway/latest/templates/rdgw-standalone.template', parameters: params }); diff --git a/packages/@aws-cdk/aws-rds/lib/cluster-parameter-group.ts b/packages/@aws-cdk/aws-rds/lib/cluster-parameter-group.ts index 1dae82310634b..0b59400fc5c5c 100644 --- a/packages/@aws-cdk/aws-rds/lib/cluster-parameter-group.ts +++ b/packages/@aws-cdk/aws-rds/lib/cluster-parameter-group.ts @@ -1,7 +1,7 @@ import cdk = require('@aws-cdk/cdk'); import { ClusterParameterGroupRef } from './cluster-parameter-group-ref'; import { Parameters } from './props'; -import { cloudformation } from './rds.generated'; +import { CfnDBClusterParameterGroup } from './rds.generated'; /** * Properties for a cluster parameter group @@ -33,7 +33,7 @@ export class ClusterParameterGroup extends ClusterParameterGroupRef { constructor(parent: cdk.Construct, id: string, props: ClusterParameterGroupProps) { super(parent, id); - const resource = new cloudformation.DBClusterParameterGroupResource(this, 'Resource', { + const resource = new CfnDBClusterParameterGroup(this, 'Resource', { description: props.description, family: props.family, parameters: new cdk.Token(() => this.parameters), diff --git a/packages/@aws-cdk/aws-rds/lib/cluster.ts b/packages/@aws-cdk/aws-rds/lib/cluster.ts index 7b34d104c4a20..7d2d357ee096d 100644 --- a/packages/@aws-cdk/aws-rds/lib/cluster.ts +++ b/packages/@aws-cdk/aws-rds/lib/cluster.ts @@ -3,7 +3,7 @@ import cdk = require('@aws-cdk/cdk'); import { ClusterParameterGroupRef } from './cluster-parameter-group-ref'; import { DatabaseClusterRef, Endpoint } from './cluster-ref'; import { BackupProps, DatabaseClusterEngine, InstanceProps, Login } from './props'; -import { cloudformation } from './rds.generated'; +import { CfnDBCluster, CfnDBInstance, CfnDBSubnetGroup } from './rds.generated'; /** * Properties for a new database cluster @@ -139,7 +139,7 @@ export class DatabaseCluster extends DatabaseClusterRef { throw new Error(`Cluster requires at least 2 subnets, got ${subnets.length}`); } - const subnetGroup = new cloudformation.DBSubnetGroupResource(this, 'Subnets', { + const subnetGroup = new CfnDBSubnetGroup(this, 'Subnets', { dbSubnetGroupDescription: `Subnets for ${name} database`, subnetIds: subnets.map(s => s.subnetId) }); @@ -150,7 +150,7 @@ export class DatabaseCluster extends DatabaseClusterRef { }); this.securityGroupId = securityGroup.securityGroupId; - const cluster = new cloudformation.DBClusterResource(this, 'Resource', { + const cluster = new CfnDBCluster(this, 'Resource', { // Basic engine: props.engine, dbClusterIdentifier: props.clusterIdentifier, @@ -188,7 +188,7 @@ export class DatabaseCluster extends DatabaseClusterRef { const publiclyAccessible = props.instanceProps.vpcPlacement && props.instanceProps.vpcPlacement.subnetsToUse === ec2.SubnetType.Public; - const instance = new cloudformation.DBInstanceResource(this, `Instance${instanceIndex}`, { + const instance = new CfnDBInstance(this, `Instance${instanceIndex}`, { // Link to cluster engine: props.engine, dbClusterIdentifier: cluster.ref, diff --git a/packages/@aws-cdk/aws-route53/lib/hosted-zone.ts b/packages/@aws-cdk/aws-route53/lib/hosted-zone.ts index c80062265f422..4769734048bc1 100644 --- a/packages/@aws-cdk/aws-route53/lib/hosted-zone.ts +++ b/packages/@aws-cdk/aws-route53/lib/hosted-zone.ts @@ -1,7 +1,7 @@ import ec2 = require('@aws-cdk/aws-ec2'); import cdk = require('@aws-cdk/cdk'); import { HostedZoneRef } from './hosted-zone-ref'; -import { cloudformation, HostedZoneNameServers } from './route53.generated'; +import { CfnHostedZone, HostedZoneNameServers } from './route53.generated'; import { validateZoneName } from './util'; /** @@ -52,7 +52,7 @@ export class PublicHostedZone extends HostedZoneRef { validateZoneName(props.zoneName); - const hostedZone = new cloudformation.HostedZoneResource(this, 'Resource', { + const hostedZone = new CfnHostedZone(this, 'Resource', { ...determineHostedZoneProps(props) }); @@ -92,14 +92,14 @@ export class PrivateHostedZone extends HostedZoneRef { /** * VPCs to which this hosted zone will be added */ - private readonly vpcs: cloudformation.HostedZoneResource.VPCProperty[] = []; + private readonly vpcs: CfnHostedZone.VPCProperty[] = []; constructor(parent: cdk.Construct, name: string, props: PrivateHostedZoneProps) { super(parent, name); validateZoneName(props.zoneName); - const hostedZone = new cloudformation.HostedZoneResource(this, 'Resource', { + const hostedZone = new CfnHostedZone(this, 'Resource', { vpcs: new cdk.Token(() => this.vpcs ? this.vpcs : undefined), ...determineHostedZoneProps(props) }); @@ -120,7 +120,7 @@ export class PrivateHostedZone extends HostedZoneRef { } } -function toVpcProperty(vpc: ec2.VpcNetworkRef): cloudformation.HostedZoneResource.VPCProperty { +function toVpcProperty(vpc: ec2.VpcNetworkRef): CfnHostedZone.VPCProperty { return { vpcId: vpc.vpcId, vpcRegion: new cdk.AwsRegion() }; } diff --git a/packages/@aws-cdk/aws-route53/lib/records/alias.ts b/packages/@aws-cdk/aws-route53/lib/records/alias.ts index e265700ddb869..57ea706f43338 100644 --- a/packages/@aws-cdk/aws-route53/lib/records/alias.ts +++ b/packages/@aws-cdk/aws-route53/lib/records/alias.ts @@ -1,6 +1,6 @@ import { Construct } from '@aws-cdk/cdk'; import { HostedZoneRef } from '../hosted-zone-ref'; -import { cloudformation } from '../route53.generated'; +import { CfnRecordSet } from '../route53.generated'; import { determineFullyQualifiedDomainName } from './_util'; /** @@ -48,7 +48,7 @@ export class AliasRecord extends Construct { constructor(parent: HostedZoneRef, id: string, props: AliasRecordProps) { super(parent, id); - new cloudformation.RecordSetResource(this, 'Resource', { + new CfnRecordSet(this, 'Resource', { hostedZoneId: parent.hostedZoneId, name: determineFullyQualifiedDomainName(props.recordName, parent), type: 'A', // ipv4 diff --git a/packages/@aws-cdk/aws-route53/lib/records/txt.ts b/packages/@aws-cdk/aws-route53/lib/records/txt.ts index 9ab789c7ec75a..7c7c058d4ba73 100644 --- a/packages/@aws-cdk/aws-route53/lib/records/txt.ts +++ b/packages/@aws-cdk/aws-route53/lib/records/txt.ts @@ -1,6 +1,6 @@ import { Construct } from '@aws-cdk/cdk'; import { HostedZoneRef } from '../hosted-zone-ref'; -import { cloudformation } from '../route53.generated'; +import { CfnRecordSet } from '../route53.generated'; import { determineFullyQualifiedDomainName } from './_util'; export interface TXTRecordProps { @@ -21,7 +21,7 @@ export class TXTRecord extends Construct { const recordValue = JSON.stringify(props.recordValue); const ttl = props.ttl === undefined ? 1800 : props.ttl; - new cloudformation.RecordSetResource(this, 'Resource', { + new CfnRecordSet(this, 'Resource', { hostedZoneId: parent.hostedZoneId, name: determineFullyQualifiedDomainName(props.recordName, parent), type: 'TXT', diff --git a/packages/@aws-cdk/aws-route53/lib/records/zone-delegation.ts b/packages/@aws-cdk/aws-route53/lib/records/zone-delegation.ts index 3bf7c255494f6..df7fbcacf7e5b 100644 --- a/packages/@aws-cdk/aws-route53/lib/records/zone-delegation.ts +++ b/packages/@aws-cdk/aws-route53/lib/records/zone-delegation.ts @@ -1,6 +1,6 @@ import { Construct } from '@aws-cdk/cdk'; import { HostedZoneRef } from '../hosted-zone-ref'; -import { cloudformation } from '../route53.generated'; +import { CfnRecordSet } from '../route53.generated'; import { determineFullyQualifiedDomainName } from './_util'; export interface ZoneDelegationRecordProps { @@ -38,7 +38,7 @@ export class ZoneDelegationRecord extends Construct { const ttl = props.ttl === undefined ? 172_800 : props.ttl; - new cloudformation.RecordSetResource(this, 'Resource', { + new CfnRecordSet(this, 'Resource', { hostedZoneId: parent.hostedZoneId, name: determineFullyQualifiedDomainName(props.delegatedZoneName, parent), type: 'NS', diff --git a/packages/@aws-cdk/aws-s3/lib/bucket-policy.ts b/packages/@aws-cdk/aws-s3/lib/bucket-policy.ts index 280304d837688..3e6e3a7273601 100644 --- a/packages/@aws-cdk/aws-s3/lib/bucket-policy.ts +++ b/packages/@aws-cdk/aws-s3/lib/bucket-policy.ts @@ -1,7 +1,7 @@ import { PolicyDocument } from '@aws-cdk/aws-iam'; import { Construct } from '@aws-cdk/cdk'; import { BucketRef } from './bucket'; -import { cloudformation } from './s3.generated'; +import { CfnBucketPolicy } from './s3.generated'; export interface BucketPolicyProps { /** @@ -29,7 +29,7 @@ export class BucketPolicy extends Construct { throw new Error('Bucket doesn\'t have a bucketName defined'); } - new cloudformation.BucketPolicyResource(this, 'Resource', { + new CfnBucketPolicy(this, 'Resource', { bucket: props.bucket.bucketName, policyDocument: this.document, }); diff --git a/packages/@aws-cdk/aws-s3/lib/bucket.ts b/packages/@aws-cdk/aws-s3/lib/bucket.ts index edb4a9b99bfba..b059f0463ab48 100644 --- a/packages/@aws-cdk/aws-s3/lib/bucket.ts +++ b/packages/@aws-cdk/aws-s3/lib/bucket.ts @@ -8,7 +8,7 @@ import { BucketNotifications } from './notifications-resource'; import perms = require('./perms'); import { CommonPipelineSourceActionProps, PipelineSourceAction } from './pipeline-action'; import { LifecycleRule } from './rule'; -import { cloudformation } from './s3.generated'; +import { CfnBucket } from './s3.generated'; import { parseBucketArn, parseBucketName } from './util'; /** @@ -427,7 +427,7 @@ export class Bucket extends BucketRef { const { bucketEncryption, encryptionKey } = this.parseEncryption(props); - const resource = new cloudformation.BucketResource(this, 'Resource', { + const resource = new CfnBucket(this, 'Resource', { bucketName: props && props.bucketName, bucketEncryption, versioningConfiguration: props.versioned ? { status: 'Enabled' } : undefined, @@ -523,7 +523,7 @@ export class Bucket extends BucketRef { * user's configuration. */ private parseEncryption(props: BucketProps): { - bucketEncryption?: cloudformation.BucketResource.BucketEncryptionProperty, + bucketEncryption?: CfnBucket.BucketEncryptionProperty, encryptionKey?: kms.EncryptionKeyRef } { @@ -583,14 +583,14 @@ export class Bucket extends BucketRef { * Parse the lifecycle configuration out of the uucket props * @param props Par */ - private parseLifecycleConfiguration(): cloudformation.BucketResource.LifecycleConfigurationProperty | undefined { + private parseLifecycleConfiguration(): CfnBucket.LifecycleConfigurationProperty | undefined { if (!this.lifecycleRules || this.lifecycleRules.length === 0) { return undefined; } return { rules: this.lifecycleRules.map(parseLifecycleRule) }; - function parseLifecycleRule(rule: LifecycleRule): cloudformation.BucketResource.RuleProperty { + function parseLifecycleRule(rule: LifecycleRule): CfnBucket.RuleProperty { const enabled = rule.enabled !== undefined ? rule.enabled : true; const x = { @@ -622,7 +622,7 @@ export class Bucket extends BucketRef { } } - private renderWebsiteConfiguration(props: BucketProps): cloudformation.BucketResource.WebsiteConfigurationProperty | undefined { + private renderWebsiteConfiguration(props: BucketProps): CfnBucket.WebsiteConfigurationProperty | undefined { if (!props.websiteErrorDocument && !props.websiteIndexDocument) { return undefined; } diff --git a/packages/@aws-cdk/aws-sns/lib/policy.ts b/packages/@aws-cdk/aws-sns/lib/policy.ts index a1018aa24d907..c1be7dfdfe7b9 100644 --- a/packages/@aws-cdk/aws-sns/lib/policy.ts +++ b/packages/@aws-cdk/aws-sns/lib/policy.ts @@ -1,6 +1,6 @@ import { PolicyDocument } from '@aws-cdk/aws-iam'; import { Construct, IDependable } from '@aws-cdk/cdk'; -import { cloudformation } from './sns.generated'; +import { CfnTopicPolicy } from './sns.generated'; import { TopicRef } from './topic-ref'; export interface TopicPolicyProps { @@ -27,7 +27,7 @@ export class TopicPolicy extends Construct implements IDependable { constructor(parent: Construct, name: string, props: TopicPolicyProps) { super(parent, name); - const resource = new cloudformation.TopicPolicyResource(this, 'Resource', { + const resource = new CfnTopicPolicy(this, 'Resource', { policyDocument: this.document, topics: props.topics.map(t => t.topicArn) }); diff --git a/packages/@aws-cdk/aws-sns/lib/subscription.ts b/packages/@aws-cdk/aws-sns/lib/subscription.ts index 9148be78ac16c..7202191f13af7 100644 --- a/packages/@aws-cdk/aws-sns/lib/subscription.ts +++ b/packages/@aws-cdk/aws-sns/lib/subscription.ts @@ -1,5 +1,5 @@ import { Construct } from '@aws-cdk/cdk'; -import { cloudformation } from './sns.generated'; +import { CfnSubscription } from './sns.generated'; import { TopicRef } from './topic-ref'; /** @@ -34,7 +34,7 @@ export class Subscription extends Construct { constructor(parent: Construct, name: string, props: SubscriptionProps) { super(parent, name); - new cloudformation.SubscriptionResource(this, 'Resource', { + new CfnSubscription(this, 'Resource', { endpoint: props.endpoint, protocol: props.protocol, topicArn: props.topic.topicArn diff --git a/packages/@aws-cdk/aws-sns/lib/topic.ts b/packages/@aws-cdk/aws-sns/lib/topic.ts index 650f3843bdbf7..476a2446c6c7d 100644 --- a/packages/@aws-cdk/aws-sns/lib/topic.ts +++ b/packages/@aws-cdk/aws-sns/lib/topic.ts @@ -1,5 +1,5 @@ import { Construct, } from '@aws-cdk/cdk'; -import { cloudformation } from './sns.generated'; +import { CfnTopic } from './sns.generated'; import { TopicRef } from './topic-ref'; /** @@ -37,7 +37,7 @@ export class Topic extends TopicRef { constructor(parent: Construct, name: string, props: TopicProps = {}) { super(parent, name); - const resource = new cloudformation.TopicResource(this, 'Resource', { + const resource = new CfnTopic(this, 'Resource', { displayName: props.displayName, topicName: props.topicName }); diff --git a/packages/@aws-cdk/aws-sqs/lib/policy.ts b/packages/@aws-cdk/aws-sqs/lib/policy.ts index 0ac34c0dc4e00..e0d7eec007c4d 100644 --- a/packages/@aws-cdk/aws-sqs/lib/policy.ts +++ b/packages/@aws-cdk/aws-sqs/lib/policy.ts @@ -1,7 +1,7 @@ import { PolicyDocument } from '@aws-cdk/aws-iam'; import { Construct, IDependable } from '@aws-cdk/cdk'; import { QueueRef } from './queue-ref'; -import { cloudformation } from './sqs.generated'; +import { CfnQueuePolicy } from './sqs.generated'; export interface QueuePolicyProps { /** @@ -27,7 +27,7 @@ export class QueuePolicy extends Construct implements IDependable { constructor(parent: Construct, name: string, props: QueuePolicyProps) { super(parent, name); - const resource = new cloudformation.QueuePolicyResource(this, 'Resource', { + const resource = new CfnQueuePolicy(this, 'Resource', { policyDocument: this.document, queues: props.queues.map(q => q.queueUrl) }); diff --git a/packages/@aws-cdk/aws-sqs/lib/queue.ts b/packages/@aws-cdk/aws-sqs/lib/queue.ts index ea6133ecbf754..f6b633a3ab1fe 100644 --- a/packages/@aws-cdk/aws-sqs/lib/queue.ts +++ b/packages/@aws-cdk/aws-sqs/lib/queue.ts @@ -1,7 +1,7 @@ import kms = require('@aws-cdk/aws-kms'); import cdk = require('@aws-cdk/cdk'); import { QueueRef } from './queue-ref'; -import { cloudformation } from './sqs.generated'; +import { CfnQueue } from './sqs.generated'; import { validateProps } from './validate-props'; /** @@ -216,7 +216,7 @@ export class Queue extends QueueRef { const { encryptionMasterKey, encryptionProps } = _determineEncryptionProps.call(this); - const queue = new cloudformation.QueueResource(this, 'Resource', { + const queue = new CfnQueue(this, 'Resource', { queueName: props.queueName, ...this.determineFifoProps(props), ...encryptionProps, diff --git a/packages/@aws-cdk/aws-ssm/test/test.ssm-document.ts b/packages/@aws-cdk/aws-ssm/test/test.ssm-document.ts index b6da8688e5976..ccd4522a11e76 100644 --- a/packages/@aws-cdk/aws-ssm/test/test.ssm-document.ts +++ b/packages/@aws-cdk/aws-ssm/test/test.ssm-document.ts @@ -9,7 +9,7 @@ export = { const stack = new cdk.Stack(); // WHEN - new ssm.cloudformation.AssociationResource(stack, 'Assoc', { + new ssm.CfnAssociation(stack, 'Assoc', { name: 'document', }); diff --git a/packages/@aws-cdk/aws-stepfunctions/lib/activity.ts b/packages/@aws-cdk/aws-stepfunctions/lib/activity.ts index 505e4b14405ef..a8bf045ad13c8 100644 --- a/packages/@aws-cdk/aws-stepfunctions/lib/activity.ts +++ b/packages/@aws-cdk/aws-stepfunctions/lib/activity.ts @@ -1,7 +1,7 @@ import cloudwatch = require('@aws-cdk/aws-cloudwatch'); import cdk = require('@aws-cdk/cdk'); import { IStepFunctionsTaskResource, StepFunctionsTaskResourceProps, Task } from './states/task'; -import { cloudformation } from './stepfunctions.generated'; +import { CfnActivity } from './stepfunctions.generated'; export interface ActivityProps { /** @@ -22,7 +22,7 @@ export class Activity extends cdk.Construct implements IStepFunctionsTaskResourc constructor(parent: cdk.Construct, id: string, props: ActivityProps = {}) { super(parent, id); - const resource = new cloudformation.ActivityResource(this, 'Resource', { + const resource = new CfnActivity(this, 'Resource', { name: props.activityName || this.generateName() }); diff --git a/packages/@aws-cdk/aws-stepfunctions/lib/state-machine.ts b/packages/@aws-cdk/aws-stepfunctions/lib/state-machine.ts index 9e7b552126e52..1368bc599f37a 100644 --- a/packages/@aws-cdk/aws-stepfunctions/lib/state-machine.ts +++ b/packages/@aws-cdk/aws-stepfunctions/lib/state-machine.ts @@ -3,7 +3,7 @@ import events = require('@aws-cdk/aws-events'); import iam = require('@aws-cdk/aws-iam'); import cdk = require('@aws-cdk/cdk'); import { StateGraph } from './state-graph'; -import { cloudformation } from './stepfunctions.generated'; +import { CfnStateMachine } from './stepfunctions.generated'; import { IChainable } from './types'; /** @@ -78,7 +78,7 @@ export class StateMachine extends cdk.Construct implements IStateMachine { const graph = new StateGraph(props.definition.startState, `State Machine ${id} definition`); graph.timeoutSeconds = props.timeoutSec; - const resource = new cloudformation.StateMachineResource(this, 'Resource', { + const resource = new CfnStateMachine(this, 'Resource', { stateMachineName: props.stateMachineName, roleArn: this.role.roleArn, definitionString: cdk.CloudFormationJSON.stringify(graph.toGraphJson()), diff --git a/packages/@aws-cdk/runtime-values/lib/rtv.ts b/packages/@aws-cdk/runtime-values/lib/rtv.ts index 5e9457f079a3f..d909df03cf86c 100644 --- a/packages/@aws-cdk/runtime-values/lib/rtv.ts +++ b/packages/@aws-cdk/runtime-values/lib/rtv.ts @@ -56,7 +56,7 @@ export class RuntimeValue extends cdk.Construct { this.parameterName = `/rtv/${new cdk.AwsStackName()}/${props.package}/${name}`; - new ssm.cloudformation.ParameterResource(this, 'Parameter', { + new ssm.CfnParameter(this, 'Parameter', { name: this.parameterName, type: 'String', value: props.value, diff --git a/packages/@aws-cdk/runtime-values/test/test.rtv.ts b/packages/@aws-cdk/runtime-values/test/test.rtv.ts index 669a5bdef7bb4..dc88dc255f031 100644 --- a/packages/@aws-cdk/runtime-values/test/test.rtv.ts +++ b/packages/@aws-cdk/runtime-values/test/test.rtv.ts @@ -23,13 +23,13 @@ class RuntimeValueTest extends cdk.Construct { constructor(parent: cdk.Construct, name: string) { super(parent, name); - const queue = new sqs.cloudformation.QueueResource(this, 'Queue', {}); + const queue = new sqs.CfnQueue(this, 'Queue', {}); const role = new iam.Role(this, 'Role', { assumedBy: new iam.ServicePrincipal('lambda.amazonaws.com'), }); - new lambda.cloudformation.FunctionResource(this, 'Function', { + new lambda.CfnFunction(this, 'Function', { runtime: 'nodejs6.10', handler: 'index.handler', code: { diff --git a/tools/cdk-build-tools/tsconfig.json b/tools/cdk-build-tools/tsconfig.json index 0c0d4afb8615a..033022226ac67 100644 --- a/tools/cdk-build-tools/tsconfig.json +++ b/tools/cdk-build-tools/tsconfig.json @@ -14,9 +14,5 @@ "noFallthroughCasesInSwitch": true, "inlineSourceMap": true, "inlineSources": true - }, - "exclude": [ - "test/enrichments/**", - "module-template/**" - ] + } } diff --git a/tools/cdk-integ-tools/tsconfig.json b/tools/cdk-integ-tools/tsconfig.json index 0c0d4afb8615a..033022226ac67 100644 --- a/tools/cdk-integ-tools/tsconfig.json +++ b/tools/cdk-integ-tools/tsconfig.json @@ -14,9 +14,5 @@ "noFallthroughCasesInSwitch": true, "inlineSourceMap": true, "inlineSources": true - }, - "exclude": [ - "test/enrichments/**", - "module-template/**" - ] + } } diff --git a/tools/cfn2ts/lib/codegen.ts b/tools/cfn2ts/lib/codegen.ts index e47762e7a4e90..61e68d09d26a3 100644 --- a/tools/cfn2ts/lib/codegen.ts +++ b/tools/cfn2ts/lib/codegen.ts @@ -70,13 +70,19 @@ export default class CodeGenerator { this.validateRefKindPresence(name, resourceType); const cfnName = SpecName.parse(name); - const resourceName = genspec.CodeName.forResource(cfnName); + const resourceName = genspec.CodeName.forCfnResource(cfnName); + const legacyResourceName = genspec.CodeName.forLegacyResource(cfnName); this.code.line(); - this.code.openBlock('export namespace cloudformation'); - const attributeTypes = this.emitResourceType(resourceName, resourceType); - this.emitPropertyTypes(name); + const attributeTypes = this.emitResourceType(resourceName, resourceType); + this.emitPropertyTypes(name, resourceName); + // emit the "cloudformation.XxxResource" classes for backwards compatibility + // those will also include a deprecation warning. + this.code.line('// legacy "cloudformation" namespace (will be deprecated soon)'); + this.code.openBlock('export namespace cloudformation'); + this.emitResourceType(legacyResourceName, resourceType, resourceName); + this.emitPropertyTypes(name, legacyResourceName); this.code.closeBlock(); for (const attributeType of attributeTypes) { @@ -96,19 +102,20 @@ export default class CodeGenerator { /** * Emits classes for all property types */ - private emitPropertyTypes(resourceName: string) { + private emitPropertyTypes(resourceName: string, resourceClass: genspec.CodeName) { const prefix = `${resourceName}.`; for (const name of Object.keys(this.spec.PropertyTypes).sort()) { if (!name.startsWith(prefix)) { continue; } const cfnName = PropertyAttributeName.parse(name); - const propTypeName = genspec.CodeName.forPropertyType(cfnName); - this.emitPropertyType(propTypeName, this.spec.PropertyTypes[name]); + const propTypeName = genspec.CodeName.forPropertyType(cfnName, resourceClass); + this.emitPropertyType(resourceClass, propTypeName, this.spec.PropertyTypes[name]); } } - private openClass(name: genspec.CodeName, docLink?: string, superClasses?: string) { + private openClass(name: genspec.CodeName, docLink?: string, superClasses?: string, deprecation?: string) { const extendsPostfix = superClasses ? ` extends ${superClasses}` : ''; - this.docLink(docLink); + const before = deprecation ? [ `@deprecated ${deprecation}` ] : [ ]; + this.docLink(docLink, ...before); this.code.openBlock(`export class ${name.className}${extendsPostfix}`); return name.className; } @@ -117,21 +124,21 @@ export default class CodeGenerator { this.code.closeBlock(); } - private emitPropsType(resourceName: genspec.CodeName, spec: schema.ResourceType): genspec.CodeName | undefined { + private emitPropsType(resourceContext: genspec.CodeName, spec: schema.ResourceType): genspec.CodeName | undefined { if (!spec.Properties || Object.keys(spec.Properties).length === 0) { return; } - const name = genspec.CodeName.forResourceProperties(resourceName); + const name = genspec.CodeName.forResourceProperties(resourceContext); this.docLink(spec.Documentation); this.code.openBlock(`export interface ${name.className}`); - const conversionTable = this.emitPropsTypeProperties(resourceName.specName!, spec.Properties); + const conversionTable = this.emitPropsTypeProperties(resourceContext, spec.Properties); this.code.closeBlock(); this.code.line(); - this.emitValidator(name, spec.Properties, conversionTable); + this.emitValidator(resourceContext, name, spec.Properties, conversionTable); this.code.line(); - this.emitCloudFormationMapper(name, spec.Properties, conversionTable); + this.emitCloudFormationMapper(resourceContext, name, spec.Properties, conversionTable); return name; } @@ -141,15 +148,13 @@ export default class CodeGenerator { * * Return a mapping of { originalName -> newName }. */ - private emitPropsTypeProperties(resourceName: SpecName, propertiesSpec: { [name: string]: schema.Property }): Dictionary { + private emitPropsTypeProperties(resource: genspec.CodeName, propertiesSpec: { [name: string]: schema.Property }): Dictionary { const propertyMap: Dictionary = {}; Object.keys(propertiesSpec).sort(propertyComparator).forEach(propName => { const propSpec = propertiesSpec[propName]; - const additionalDocs = resourceName.relativeName(propName).fqn; - - const resourceCodeName = genspec.CodeName.forResource(resourceName); - const newName = this.emitProperty(resourceCodeName, propName, propSpec, quoteCode(additionalDocs)); + const additionalDocs = resource.specName!.relativeName(propName).fqn; + const newName = this.emitProperty(resource, propName, propSpec, quoteCode(additionalDocs)); propertyMap[propName] = newName; }); return propertyMap; @@ -172,7 +177,7 @@ export default class CodeGenerator { } } - private emitResourceType(resourceName: genspec.CodeName, spec: schema.ResourceType) { + private emitResourceType(resourceName: genspec.CodeName, spec: schema.ResourceType, deprecated?: genspec.CodeName) { this.beginNamespace(resourceName); // @@ -183,7 +188,12 @@ export default class CodeGenerator { if (propsType) { this.code.line(); } - this.openClass(resourceName, spec.Documentation, RESOURCE_BASE_CLASS); + + const deprecation = deprecated && + `"cloudformation.${resourceName.fqn}" will be deprecated in a future release ` + + `in favor of "${deprecated.fqn}" (see https://github.com/awslabs/aws-cdk/issues/878)`; + + this.openClass(resourceName, spec.Documentation, RESOURCE_BASE_CLASS, deprecation); // // Static inspectors. @@ -241,6 +251,7 @@ export default class CodeGenerator { // // Constructor // + this.code.line(); this.code.line('/**'); this.code.line(` * Creates a new ${quoteCode(resourceName.specName!.fqn)}.`); @@ -286,8 +297,16 @@ export default class CodeGenerator { } } + if (deprecated) { + this.code.line(`this.addWarning('DEPRECATION: ${deprecation}');`); + } + this.code.closeBlock(); + // + // propertyOverrides + // + if (propsType) { this.code.line(); this.emitCloudFormationPropertiesOverride(propsType); @@ -334,7 +353,8 @@ export default class CodeGenerator { * * Generated as a top-level function outside any namespace so we can hide it from library consumers. */ - private emitCloudFormationMapper(typeName: genspec.CodeName, + private emitCloudFormationMapper(resource: genspec.CodeName, + typeName: genspec.CodeName, propSpecs: { [name: string]: schema.Property }, nameConversionTable: Dictionary) { const mapperName = genspec.cfnMapperName(typeName); @@ -365,7 +385,7 @@ export default class CodeGenerator { const propName = nameConversionTable[cfnName]; const propSpec = propSpecs[cfnName]; - const mapperExpression = genspec.typeDispatch(typeName.specName!, propSpec, { + const mapperExpression = genspec.typeDispatch(resource, propSpec, { visitScalar(type: genspec.CodeName) { return mapperNames([type]); }, @@ -405,7 +425,8 @@ export default class CodeGenerator { * * Generated as a top-level function outside any namespace so we can hide it from library consumers. */ - private emitValidator(typeName: genspec.CodeName, + private emitValidator(resource: genspec.CodeName, + typeName: genspec.CodeName, propSpecs: { [name: string]: schema.Property }, nameConversionTable: Dictionary) { const validatorName = genspec.validatorName(typeName); @@ -431,7 +452,7 @@ export default class CodeGenerator { } const self = this; - const validatorExpression = genspec.typeDispatch(typeName.specName!, propSpec, { + const validatorExpression = genspec.typeDispatch(resource, propSpec, { visitScalar(type: genspec.CodeName) { return validatorNames([type]); }, @@ -512,7 +533,7 @@ export default class CodeGenerator { } } - private emitPropertyType(typeName: genspec.CodeName, propTypeSpec: schema.PropertyType) { + private emitPropertyType(resourceContext: genspec.CodeName, typeName: genspec.CodeName, propTypeSpec: schema.PropertyType) { this.code.line(); this.beginNamespace(typeName); @@ -526,7 +547,7 @@ export default class CodeGenerator { Object.keys(propTypeSpec.Properties).forEach(propName => { const propSpec = propTypeSpec.Properties[propName]; const additionalDocs = quoteCode(`${typeName.fqn}.${propName}`); - const newName = this.emitProperty(typeName, propName, propSpec, additionalDocs); + const newName = this.emitProperty(resourceContext, propName, propSpec, additionalDocs); conversionTable[propName] = newName; }); } @@ -535,24 +556,24 @@ export default class CodeGenerator { this.endNamespace(typeName); this.code.line(); - this.emitValidator(typeName, propTypeSpec.Properties, conversionTable); + this.emitValidator(resourceContext, typeName, propTypeSpec.Properties, conversionTable); this.code.line(); - this.emitCloudFormationMapper(typeName, propTypeSpec.Properties, conversionTable); + this.emitCloudFormationMapper(resourceContext, typeName, propTypeSpec.Properties, conversionTable); } /** * Return the native type expression for the given propSpec */ - private findNativeType(resource: genspec.CodeName, propSpec: schema.Property): string { + private findNativeType(resourceContext: genspec.CodeName, propSpec: schema.Property): string { const alternatives: string[] = []; if (schema.isCollectionProperty(propSpec)) { // render the union of all item types - const itemTypes = genspec.specTypesToCodeTypes(resource.specName!, itemTypeNames(propSpec)); + const itemTypes = genspec.specTypesToCodeTypes(resourceContext, itemTypeNames(propSpec)); // Always accept a token in place of any list element itemTypes.push(genspec.TOKEN_NAME); - const union = this.renderTypeUnion(resource, itemTypes); + const union = this.renderTypeUnion(resourceContext, itemTypes); if (schema.isMapProperty(propSpec)) { alternatives.push(`{ [key: string]: (${union}) }`); @@ -571,8 +592,8 @@ export default class CodeGenerator { if (schema.isScalarPropery(propSpec)) { // Scalar type const typeNames = scalarTypeNames(propSpec); - const types = genspec.specTypesToCodeTypes(resource.specName!, typeNames); - alternatives.push(this.renderTypeUnion(resource, types)); + const types = genspec.specTypesToCodeTypes(resourceContext, typeNames); + alternatives.push(this.renderTypeUnion(resourceContext, types)); } // Always diff --git a/tools/cfn2ts/lib/genspec.ts b/tools/cfn2ts/lib/genspec.ts index c8e3d70a266df..e63444f3b7db3 100644 --- a/tools/cfn2ts/lib/genspec.ts +++ b/tools/cfn2ts/lib/genspec.ts @@ -7,7 +7,8 @@ import codemaker = require('codemaker'); import { itemTypeNames, PropertyAttributeName, scalarTypeNames, SpecName } from './spec-utils'; import util = require('./util'); -const RESOURCE_CLASS_POSTFIX = 'Resource'; +const RESOURCE_CLASS_PREFIX = 'Cfn'; +const LEGACY_RESOURCE_CLASS_POSTFIX = 'Resource'; export const CORE_NAMESPACE = 'cdk'; @@ -19,16 +20,20 @@ export const CORE_NAMESPACE = 'cdk'; * This refers to TypeScript constructs (typically a class) */ export class CodeName { - public static forResource(specName: SpecName): CodeName { + public static forCfnResource(specName: SpecName): CodeName { + const className = RESOURCE_CLASS_PREFIX + specName.resourceName; + return new CodeName(packageName(specName), '', className, specName); + } + + public static forLegacyResource(specName: SpecName): CodeName { let className = specName.resourceName; // add a "Resource" postfix to the class name (unless there is already a resource postfix). - if (!className.endsWith(RESOURCE_CLASS_POSTFIX)) { - className += RESOURCE_CLASS_POSTFIX; + if (!className.endsWith(LEGACY_RESOURCE_CLASS_POSTFIX)) { + className += LEGACY_RESOURCE_CLASS_POSTFIX; } else { - // tslint:disable:no-console - console.error('INFO: Resource class %s already had a %s postfix, so we didn\'t add one', className, RESOURCE_CLASS_POSTFIX); - // tslint:enable:no-console + // tslint:disable-next-line:no-console + console.error('INFO: Resource class %s already had a %s postfix, so we didn\'t add one', className, LEGACY_RESOURCE_CLASS_POSTFIX); } return new CodeName(packageName(specName), '', className, specName); @@ -38,18 +43,14 @@ export class CodeName { return new CodeName(resourceName.packageName, resourceName.namespace, `${resourceName.className}Props`, resourceName.specName); } - public static forPropertyType(specName: PropertyAttributeName): CodeName { + public static forPropertyType(specName: PropertyAttributeName, resourceClass: CodeName): CodeName { // Exception for an intrinsic type if (specName.propAttrName === 'Tag' && specName.resourceName === '') { return TAG_NAME; } // These are in a namespace named after the resource - let resourceClassName = specName.resourceName; - if (!resourceClassName.endsWith(RESOURCE_CLASS_POSTFIX)) { - resourceClassName += RESOURCE_CLASS_POSTFIX; - } - return new CodeName(packageName(specName), `${resourceClassName}`, `${specName.propAttrName}Property`, specName); + return new CodeName(packageName(specName), resourceClass.className, `${specName.propAttrName}Property`, specName); } public static forPrimitive(primitiveName: string): CodeName { @@ -287,7 +288,7 @@ export function isPrimitive(type: CodeName): boolean { || type.className === 'Date'; } -export function specTypeToCodeType(contextResource: SpecName, type: string): CodeName { +function specTypeToCodeType(resourceContext: CodeName, type: string): CodeName { if (schema.isPrimitiveType(type)) { return specPrimitiveToCodePrimitive(type); } else if (type === 'Tag') { @@ -296,18 +297,18 @@ export function specTypeToCodeType(contextResource: SpecName, type: string): Cod return TAG_NAME; } - const typeName = contextResource!.relativeName(type); - return CodeName.forPropertyType(typeName); + const typeName = resourceContext.specName!.relativeName(type); + return CodeName.forPropertyType(typeName, resourceContext); } /** * Translate a list of type references in a resource context to a list of code names */ -export function specTypesToCodeTypes(contextResource: SpecName, types: string[]): CodeName[] { +export function specTypesToCodeTypes(resourceContext: CodeName, types: string[]): CodeName[] { const ret = []; for (const type of types) { - ret.push(specTypeToCodeType(contextResource, type)); + ret.push(specTypeToCodeType(resourceContext, type)); } return ret; @@ -323,9 +324,9 @@ export interface PropertyVisitor { visitListOrScalar(scalarTypes: CodeName[], itemTypes: CodeName[]): any; } -export function typeDispatch(resource: SpecName, spec: schema.Property, visitor: PropertyVisitor): T { - const scalarTypes = specTypesToCodeTypes(resource, scalarTypeNames(spec)); - const itemTypes = specTypesToCodeTypes(resource, itemTypeNames(spec)); +export function typeDispatch(resourceContext: CodeName, spec: schema.Property, visitor: PropertyVisitor): T { + const scalarTypes = specTypesToCodeTypes(resourceContext, scalarTypeNames(spec)); + const itemTypes = specTypesToCodeTypes(resourceContext, itemTypeNames(spec)); if (scalarTypes.length && itemTypes.length) { // Can accept both a list and a scalar diff --git a/tools/cfn2ts/module-template/README.md b/tools/cfn2ts/module-template/README.md deleted file mode 100644 index c5490ea172d0a..0000000000000 --- a/tools/cfn2ts/module-template/README.md +++ /dev/null @@ -1,42 +0,0 @@ -## Low-level AWS CloudFormation Resources Library -The `@aws-cdk/resources` library is automatically generated from the -[CloudFormation Resource specification](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-resource-specification.html). -It provides access to all resource types CloudFormation supports, in a low-level API. You should prefer depending on -higher level construct libraries (such as `aws-cdk-ec2`, `aws-cdk-s3`, ...) as they will offer more expressive APIs and in many cases will -also provide additional validations. - -### Usage -The library bundles each AWS service resources in a dedicated namespace. Simply import the namespaces you need and work -with the classes it defines: - -```ts -import { Construct } from '@aws-cdk/cdk'; -import { kms, s3 } from '@aws-cdk/resources'; - -/** - * The Bucket class in the aws-cdk-s3 library provides much better - * functionality than what is presented in this toy example. - */ -export class EncryptedBucket extends Construct { - public readonly bucketArn: BucketArn; - - constructor(parent: Construct, name: string) { - super(parent, name); - const kmsKey = new kms.KeyResource(parent, 'BucketEncryption', { - enableKeyRotation: true, - keyPolicy - }); - const bucket = new s3.BucketResource(parent, 'BucketName', { - bucketEncryption: { - serverSideEncryptionConfiguration: { - serverSideEncryptionByDefault: { - kmsMasterKeyId: kmsKey.keyArn, - sseAlgorithm: 'aws:kms' - } - } - } - }); - this.bucketArn = bucket.bucketArn; - } -} -``` diff --git a/tools/cfn2ts/module-template/lib/registry.ts b/tools/cfn2ts/module-template/lib/registry.ts deleted file mode 100644 index 319fcebef8c06..0000000000000 --- a/tools/cfn2ts/module-template/lib/registry.ts +++ /dev/null @@ -1,36 +0,0 @@ -export interface PropertySpecification { - readonly isRequired: boolean; - readonly updateType: 'Conditional' | 'Immutable' | 'Mutable'; -} - -export interface ResourceClass { - readonly resourceProperties: { [name: string]: PropertySpecification | undefined }; - readonly resourceTypeName: string; -} - -const catalog: { [resourceType: string]: ResourceClass } = {}; - -/** - * Register a new binding from a CloudFormation resource type name to the Resource implementation. - * - * @param resourceType the CloudFormation resource type name. - * @param resourceClass the corresponding Resource implementation. - */ -export function registerResourceType(resourceClass: ResourceClass) { - const typeName = resourceClass.resourceTypeName; - if (catalog.hasOwnProperty(typeName)) { - throw new Error(`Attempted to re-define CloudFormation resource ${typeName}`); - } - catalog[typeName] = resourceClass; -} - -/** - * Find the resource implementation class for a given CloudFormation resource type name. - * - * @param resourceType the CloudFormation resource type name being looked for. - * - * @returns a resource implementation class, or undefined if this resource type is not declared. - */ -export function resourceImplementationFor(resourceType: string): ResourceClass | undefined { - return catalog[resourceType]; -} diff --git a/tools/cfn2ts/module-template/lib/runtime.ts b/tools/cfn2ts/module-template/lib/runtime.ts deleted file mode 100644 index 2acf872f31eeb..0000000000000 --- a/tools/cfn2ts/module-template/lib/runtime.ts +++ /dev/null @@ -1,364 +0,0 @@ -// ---------------------------------------------------------------------- -// PROPERTY MAPPERS -// -// These are used while converting generated classes/property bags to CloudFormation property objects -// -// We use identity mappers for the primitive types. These don't do anything but are there to make the code -// generation work out nicely (so the code generator doesn't need to emit different code for primitive -// vs. complex types). -export type Mapper = (x: any) => any; - -function identity(x: any) { - return x; -} - -export const stringToCloudFormation: Mapper = identity; -export const booleanToCloudFormation: Mapper = identity; -export const objectToCloudFormation: Mapper = identity; -export const numberToCloudFormation: Mapper = identity; - -/** - * The date needs to be formatted as an ISO date in UTC - * - * Some usage sites require a date, some require a timestamp. We'll - * always output a timestamp and hope the parser on the other end - * is smart enough to ignore the time part... (?) - */ -export function dateToCloudFormation(x?: Date): any { - if (!x) { - return undefined; - } - - // tslint:disable-next-line:max-line-length - return `${x.getUTCFullYear()}-${pad(x.getUTCMonth() + 1)}-${pad(x.getUTCDate())}T${pad(x.getUTCHours())}:${pad(x.getUTCMinutes())}:${pad(x.getUTCSeconds())}`; -} - -/** - * Pad a number to 2 decimal places - */ -function pad(x: number) { - if (x < 10) { - return "0" + x.toString(); - } - return x.toString(); -} - -/** - * Turn a tag object into the proper CloudFormation representation - */ -export function tagToCloudFormation(x: any): any { - return { - Key: x.key, - Value: x.value - }; -} - -export function listMapper(elementMapper: Mapper): Mapper { - return (x: any) => { - if (!canInspect(x)) { return x; } - return x.map(elementMapper); - }; -} - -export function hashMapper(elementMapper: Mapper): Mapper { - return (x: any) => { - if (!canInspect(x)) { return x; } - - const ret: any = {}; - - Object.keys(x).forEach((key) => { - ret[key] = elementMapper(x[key]); - }); - - return ret; - }; -} - -/** - * Return a union mapper - * - * Takes a list of validators and a list of mappers, which should correspond pairwise. - * - * The mapper of the first successful validator will be called. - */ -export function unionMapper(validators: Validator[], mappers: Mapper[]): Mapper { - if (validators.length !== mappers.length) { - throw Error('Not the same amount of validators and mappers passed to unionMapper()'); - } - - return (x: any) => { - if (!canInspect(x)) { return x; } - - for (let i = 0; i < validators.length; i++) { - if (validators[i](x).isSuccess) { - return mappers[i](x); - } - } - - // Should not be possible because the union must have passed validation before this function - // will be called, but catch it anyway. - throw new TypeError('No validators matched in the union()'); - }; -} - -// ---------------------------------------------------------------------- -// VALIDATORS -// -// These are used while checking that supplied property bags match the expected schema -// -// We have a couple of datatypes that model validation errors and collections of validation -// errors (together forming a tree of errors so that we can trace validation errors through -// an object graph), and validators. -// -// Validators are simply functions that take a value and return a validation results. Then -// we have some combinators to turn primitive validators into more complex validators. -// - -/** - * Representation of validation results - * - * Models a tree of validation errors so that we have as much information as possible - * about the failure that occurred. - */ -export class ValidationResult { - constructor(readonly errorMessage: string = '', readonly results: ValidationResults = new ValidationResults()) { - } - - public get isSuccess(): boolean { - return !this.errorMessage && this.results.isSuccess; - } - - /** - * Turn a failed validation into an exception - */ - public assertSuccess() { - if (!this.isSuccess) { - let message = this.errorTree(); - // The first letter will be lowercase, so uppercase it for a nicer error message - message = message.substr(0, 1).toUpperCase() + message.substr(1); - throw new TypeError(message); - } - } - - /** - * Return a string rendering of the tree of validation failures - */ - public errorTree(): string { - const childMessages = this.results.errorTreeList(); - return this.errorMessage + (childMessages.length ? `\n ${childMessages.replace(/\n/g, '\n ')}` : ''); - } - - /** - * Wrap this result with an error message, if it concerns an error - */ - public prefix(message: string): ValidationResult { - if (this.isSuccess) { return this; } - return new ValidationResult(`${message}: ${this.errorMessage}`, this.results); - } -} - -/** - * A collection of validation results - */ -export class ValidationResults { - constructor(public results: ValidationResult[] = []) { - } - - public collect(result: ValidationResult) { - // Only collect failures - if (!result.isSuccess) { - this.results.push(result); - } - } - - public get isSuccess(): boolean { - return this.results.every(x => x.isSuccess); - } - - public errorTreeList(): string { - return this.results.map(child => child.errorTree()).join('\n'); - } - - /** - * Wrap up all validation results into a single tree node - * - * If there are failures in the collection, add a message, otherwise - * return a success. - */ - public wrap(message: string): ValidationResult { - if (this.isSuccess) { return VALIDATION_SUCCESS; } - return new ValidationResult(message, this); - } -} - -// Singleton object to save on allocations -export const VALIDATION_SUCCESS = new ValidationResult(); - -export type Validator = (x: any) => ValidationResult; - -/** - * Return whether this object can be validated at all - * - * True unless it's undefined or a CloudFormation intrinsic - */ -export function canInspect(x: any) { - // Note: using weak equality on purpose, we also want to catch undefined - return (x != null && !isCloudFormationIntrinsic(x)); -} - -// CloudFormation validators for primitive types -export function validateString(x: any): ValidationResult { - if (canInspect(x) && typeof x !== 'string') { - return new ValidationResult(`${JSON.stringify(x)} should be a string`); - } - return VALIDATION_SUCCESS; -} - -export function validateNumber(x: any): ValidationResult { - if (canInspect(x) && typeof x !== 'number') { - return new ValidationResult(`${JSON.stringify(x)} should be a number`); - } - return VALIDATION_SUCCESS; -} - -export function validateBoolean(x: any): ValidationResult { - if (canInspect(x) && typeof x !== 'boolean') { - return new ValidationResult(`${JSON.stringify(x)} should be a boolean`); - } - return VALIDATION_SUCCESS; -} - -export function validateDate(x: any): ValidationResult { - if (canInspect(x) && !(x instanceof Date)) { - return new ValidationResult(`${JSON.stringify(x)} should be a Date`); - } - - if (x !== undefined && isNaN(x.getTime())) { - return new ValidationResult('got an unparseable Date'); - } - - return VALIDATION_SUCCESS; -} - -export function validateObject(x: any): ValidationResult { - if (canInspect(x) && typeof x !== 'object') { - return new ValidationResult(`${JSON.stringify(x)} should be an 'object'`); - } - return VALIDATION_SUCCESS; -} - -export function validateTag(x: any): ValidationResult { - if (!canInspect(x)) { return VALIDATION_SUCCESS; } - - if (x.key == null || x.value == null) { - return new ValidationResult(`${JSON.stringify(x)} should have a 'key' and a 'value' property`); - } - - return VALIDATION_SUCCESS; -} - -/** - * Return a list validator based on the given element validator - */ -export function listValidator(elementValidator: Validator): Validator { - return (x: any) => { - if (!canInspect(x)) { return VALIDATION_SUCCESS; } - - if (!x.forEach) { - return new ValidationResult(`${JSON.stringify(x)} should be a list`); - } - - for (let i = 0; i < x.length; i++) { - const element = x[i]; - const result = elementValidator(element); - if (!result.isSuccess) { return result.prefix(`element ${i}`); } - } - - return VALIDATION_SUCCESS; - }; -} - -/** - * Return a hash validator based on the given element validator - */ -export function hashValidator(elementValidator: Validator): Validator { - return (x: any) => { - if (!canInspect(x)) { return VALIDATION_SUCCESS; } - - for (const key of Object.keys(x)) { - const result = elementValidator(x[key]); - if (!result.isSuccess) { return result.prefix(`element '${key}'`); } - } - - return VALIDATION_SUCCESS; - }; -} - -/** - * Decorate a validator with a message clarifying the property the failure is for. - */ -export function propertyValidator(propName: string, validator: Validator): Validator { - return (x: any) => { - return validator(x).prefix(propName); - }; -} - -/** - * Return a validator that will fail if the passed property is not present - * - * Does not distinguish between the property actually not being present, vs being present but 'null' - * or 'undefined' (courtesy of JavaScript), which is generally the behavior that we want. - * - * Empty strings are considered "present"--don't know if this agrees with how CloudFormation looks - * at the world. - */ -export function requiredValidator(x: any) { - if (x == null) { - return new ValidationResult(`required but missing`); - } - return VALIDATION_SUCCESS; -} - -/** - * Validates if any of the given validators matches - * - * We add either/or words to the front of the error mesages so that they read - * more nicely. Example: - * - * Properties not correct for 'FunctionProps' - * codeUri: not one of the possible types - * either: properties not correct for 'S3LocationProperty' - * bucket: required but missing - * key: required but missing - * version: required but missing - * or: '3' should be a 'string' - * - */ -export function unionValidator(...validators: Validator[]): Validator { - return (x: any) => { - const results = new ValidationResults(); - let eitherOr = 'either'; - - for (const validator of validators) { - const result = validator(x); - if (result.isSuccess) { return result; } - results.collect(result.prefix(eitherOr)); - eitherOr = 'or'; - } - return results.wrap('not one of the possible types'); - }; -} - -/** - * Return whether the indicated value represents a CloudFormation intrinsic. - * - * CloudFormation instrinsics are modeled as objects with a single key, which - * look like: { "Fn::GetAtt": [...] } or similar. - */ -function isCloudFormationIntrinsic(x: any) { - if (!(typeof x === 'object')) { return false; } - const keys = Object.keys(x); - if (keys.length !== 1) { return false; } - - return keys[0] === 'Ref' || keys[0].substr(0, 4) === 'Fn::'; -} diff --git a/tools/cfn2ts/tsconfig.json b/tools/cfn2ts/tsconfig.json index 575cfca28b3c8..2613d6dc43014 100644 --- a/tools/cfn2ts/tsconfig.json +++ b/tools/cfn2ts/tsconfig.json @@ -17,7 +17,6 @@ "inlineSources": true }, "exclude": [ - "test/enrichments/**", - "module-template/**" + "test/enrichments/**" ] } diff --git a/tools/merkle-build/tsconfig.json b/tools/merkle-build/tsconfig.json index 0c0d4afb8615a..033022226ac67 100644 --- a/tools/merkle-build/tsconfig.json +++ b/tools/merkle-build/tsconfig.json @@ -14,9 +14,5 @@ "noFallthroughCasesInSwitch": true, "inlineSourceMap": true, "inlineSources": true - }, - "exclude": [ - "test/enrichments/**", - "module-template/**" - ] + } } diff --git a/tools/pkglint/tsconfig.json b/tools/pkglint/tsconfig.json index 0c0d4afb8615a..033022226ac67 100644 --- a/tools/pkglint/tsconfig.json +++ b/tools/pkglint/tsconfig.json @@ -14,9 +14,5 @@ "noFallthroughCasesInSwitch": true, "inlineSourceMap": true, "inlineSources": true - }, - "exclude": [ - "test/enrichments/**", - "module-template/**" - ] + } } diff --git a/tools/pkgtools/tsconfig.json b/tools/pkgtools/tsconfig.json index 0c0d4afb8615a..033022226ac67 100644 --- a/tools/pkgtools/tsconfig.json +++ b/tools/pkgtools/tsconfig.json @@ -14,9 +14,5 @@ "noFallthroughCasesInSwitch": true, "inlineSourceMap": true, "inlineSources": true - }, - "exclude": [ - "test/enrichments/**", - "module-template/**" - ] + } }