Skip to content

Commit

Permalink
feat: stop generating legacy cloudformation resources (#1493)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: the deprecated `cloudformation.XxxResource` classes have
been removed. Use the `CfnXxx` classes instead.
  • Loading branch information
Elad Ben-Israel committed Jan 8, 2019
1 parent 4d6d5ca commit 81b4174
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 50 deletions.
@@ -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
Expand Down Expand Up @@ -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,
Expand Down
24 changes: 0 additions & 24 deletions packages/@aws-cdk/aws-iam/test/test.legacy-resources.ts

This file was deleted.

9 changes: 0 additions & 9 deletions tools/cfn2ts/lib/codegen.ts
Expand Up @@ -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();
}
}

Expand Down
15 changes: 0 additions & 15 deletions tools/cfn2ts/lib/genspec.ts
Expand Up @@ -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';

Expand All @@ -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);
}
Expand Down

0 comments on commit 81b4174

Please sign in to comment.