From c9dfcc13fdbd20f253f99a0ee3d20ad6f294b447 Mon Sep 17 00:00:00 2001 From: Elad Ben-Israel Date: Tue, 8 Jan 2019 10:17:15 +0200 Subject: [PATCH] feat: stop generating legacy cloudformation resources BREAKING CHANGE: the deprecated `cloudformation.XxxResource` classes have been removed. Use the `CfnXxx` classes instead. --- .../lib/custom-action-registration.ts | 4 ++-- .../aws-iam/test/test.legacy-resources.ts | 24 ------------------- tools/cfn2ts/lib/codegen.ts | 9 ------- tools/cfn2ts/lib/genspec.ts | 15 ------------ 4 files changed, 2 insertions(+), 50 deletions(-) delete mode 100644 packages/@aws-cdk/aws-iam/test/test.legacy-resources.ts diff --git a/packages/@aws-cdk/aws-codepipeline/lib/custom-action-registration.ts b/packages/@aws-cdk/aws-codepipeline/lib/custom-action-registration.ts index 764f0319a9a29..d1920ac6e7195 100644 --- a/packages/@aws-cdk/aws-codepipeline/lib/custom-action-registration.ts +++ b/packages/@aws-cdk/aws-codepipeline/lib/custom-action-registration.ts @@ -1,6 +1,6 @@ import cpapi = require('@aws-cdk/aws-codepipeline-api'); import cdk = require('@aws-cdk/cdk'); -import { cloudformation } from './codepipeline.generated'; +import { CfnCustomActionType } from './codepipeline.generated'; /** * The creation attributes used for defining a configuration property @@ -119,7 +119,7 @@ export class CustomActionRegistration extends cdk.Construct { constructor(parent: cdk.Construct, id: string, props: CustomActionRegistrationProps) { super(parent, id); - new cloudformation.CustomActionTypeResource(this, 'Resource', { + new CfnCustomActionType(this, 'Resource', { category: props.category, inputArtifactDetails: { minimumCount: props.artifactBounds.minInputs, diff --git a/packages/@aws-cdk/aws-iam/test/test.legacy-resources.ts b/packages/@aws-cdk/aws-iam/test/test.legacy-resources.ts deleted file mode 100644 index c47da3d7a7215..0000000000000 --- a/packages/@aws-cdk/aws-iam/test/test.legacy-resources.ts +++ /dev/null @@ -1,24 +0,0 @@ -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/tools/cfn2ts/lib/codegen.ts b/tools/cfn2ts/lib/codegen.ts index 03e0a33f52ff6..2e40e6ac24b26 100644 --- a/tools/cfn2ts/lib/codegen.ts +++ b/tools/cfn2ts/lib/codegen.ts @@ -71,19 +71,10 @@ export default class CodeGenerator { const cfnName = SpecName.parse(name); const resourceName = genspec.CodeName.forCfnResource(cfnName); - const legacyResourceName = genspec.CodeName.forLegacyResource(cfnName); this.code.line(); 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(); } } diff --git a/tools/cfn2ts/lib/genspec.ts b/tools/cfn2ts/lib/genspec.ts index 5ea5fed035ba3..1d65543141817 100644 --- a/tools/cfn2ts/lib/genspec.ts +++ b/tools/cfn2ts/lib/genspec.ts @@ -8,7 +8,6 @@ import { itemTypeNames, PropertyAttributeName, scalarTypeNames, SpecName } from import util = require('./util'); const RESOURCE_CLASS_PREFIX = 'Cfn'; -const LEGACY_RESOURCE_CLASS_POSTFIX = 'Resource'; export const CORE_NAMESPACE = 'cdk'; @@ -25,20 +24,6 @@ export class CodeName { 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(LEGACY_RESOURCE_CLASS_POSTFIX)) { - className += LEGACY_RESOURCE_CLASS_POSTFIX; - } else { - // 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); - } - public static forResourceProperties(resourceName: CodeName): CodeName { return new CodeName(resourceName.packageName, resourceName.namespace, `${resourceName.className}Props`, resourceName.specName); }