Skip to content

Commit

Permalink
feat(cli): Remove stack rename support (#2819)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The CLI no longer accepts `--rename`, and the stack
                 names are now immutable on the stack artifact.

Fixes #2670
  • Loading branch information
RomainMuller authored Jun 11, 2019
1 parent 7c022cf commit 0f30e39
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 131 deletions.
4 changes: 2 additions & 2 deletions packages/@aws-cdk/cx-api/lib/cloudformation-artifact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export class CloudFormationStackArtifact extends CloudArtifact {
public readonly parameters: { [id: string]: string };

/**
* The name of this stack. This is read/write and can be used to rename the stack.
* The name of this stack.
*/
public name: string;
public readonly name: string;

constructor(assembly: CloudAssembly, name: string, artifact: ArtifactManifest) {
super(assembly, name, artifact);
Expand Down
3 changes: 0 additions & 3 deletions packages/aws-cdk/bin/cdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { RequireApproval } from '../lib/diff';
import { availableInitLanguages, cliInit, printAvailableTemplates } from '../lib/init';
import { data, debug, error, print, setVerbose, success } from '../lib/logging';
import { PluginHost } from '../lib/plugin';
import { parseRenames } from '../lib/renames';
import { serializeStructure } from '../lib/serialize';
import { Configuration, Settings } from '../lib/settings';
import version = require('../lib/version');
Expand All @@ -31,7 +30,6 @@ async function parseCommandLineArguments() {
.option('app', { type: 'string', alias: 'a', desc: 'REQUIRED: command-line for executing your app or a cloud assembly directory (e.g. "node bin/my-app.js")', requiresArg: true })
.option('context', { type: 'array', alias: 'c', desc: 'Add contextual string parameter (KEY=VALUE)', nargs: 1, requiresArg: true })
.option('plugin', { type: 'array', alias: 'p', desc: 'Name or path of a node package that extend the CDK features. Can be specified multiple times', nargs: 1 })
.option('rename', { type: 'string', desc: 'Rename stack name if different from the one defined in the cloud executable ([ORIGINAL:]RENAMED)', requiresArg: true })
.option('trace', { type: 'boolean', desc: 'Print trace for stack warnings' })
.option('strict', { type: 'boolean', desc: 'Do not construct stacks with warnings' })
.option('ignore-errors', { type: 'boolean', default: false, desc: 'Ignores synthesis errors, which will likely produce an invalid output' })
Expand Down Expand Up @@ -112,7 +110,6 @@ async function initCommandLine() {
configuration,
aws,
synthesizer: execProgram,
renames: parseRenames(argv.rename)
});

/** Function to load plug-ins, using configurations additively. */
Expand Down
24 changes: 1 addition & 23 deletions packages/aws-cdk/lib/api/cxapp/stacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import colors = require('colors/safe');
import minimatch = require('minimatch');
import contextproviders = require('../../context-providers');
import { debug, error, print, warning } from '../../logging';
import { Renames } from '../../renames';
import { Configuration } from '../../settings';
import { SDK } from '../util/sdk';

Expand Down Expand Up @@ -45,11 +44,6 @@ export interface AppStacksProps {
*/
aws: SDK;

/**
* Renames to apply
*/
renames?: Renames;

/**
* Callback invoked to synthesize the actual stacks
*/
Expand All @@ -69,11 +63,7 @@ export class AppStacks {
*/
public assembly?: cxapi.CloudAssembly;

private readonly renames: Renames;

constructor(private readonly props: AppStacksProps) {
this.renames = props.renames || new Renames({});
}
constructor(private readonly props: AppStacksProps) {}

/**
* List all stacks in the CX and return the selected ones
Expand All @@ -92,7 +82,6 @@ export class AppStacks {
if (selectors.length === 0) {
// remove non-auto deployed Stacks
debug('Stack name not specified, so defaulting to all available stacks: ' + listStackNames(stacks));
this.applyRenames(stacks);
return stacks;
}

Expand Down Expand Up @@ -132,7 +121,6 @@ export class AppStacks {

// Only check selected stacks for errors
this.processMessages(selectedList);
this.applyRenames(selectedList);

return selectedList;
}
Expand All @@ -144,8 +132,6 @@ export class AppStacks {
* topologically sorted order. If there are dependencies that are not in the
* set, they will be ignored; it is the user's responsibility that the
* non-selected stacks have already been deployed previously.
*
* Renames are *NOT* applied in list mode.
*/
public async listStacks(): Promise<cxapi.CloudFormationStackArtifact[]> {
const response = await this.synthesizeStacks();
Expand All @@ -158,7 +144,6 @@ export class AppStacks {
public async synthesizeStack(stackName: string): Promise<cxapi.CloudFormationStackArtifact> {
const resp = await this.synthesizeStacks();
const stack = resp.getStack(stackName);
this.applyRenames([stack]);
return stack;
}

Expand Down Expand Up @@ -277,13 +262,6 @@ export class AppStacks {
logFn(` ${entry.trace.join('\n ')}`);
}
}

private applyRenames(stacks: cxapi.CloudFormationStackArtifact[]) {
this.renames.validateSelectedStacks(stacks);
for (const stack of stacks) {
stack.name = this.renames.finalName(stack.name);
}
}
}

/**
Expand Down
83 changes: 0 additions & 83 deletions packages/aws-cdk/lib/renames.ts

This file was deleted.

20 changes: 0 additions & 20 deletions packages/aws-cdk/test/api/test.stacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import cxapi = require('@aws-cdk/cx-api');
import { Test } from 'nodeunit';
import { SDK } from '../../lib';
import { AppStacks, ExtendedStackSelection } from '../../lib/api/cxapp/stacks';
import { Renames } from '../../lib/renames';
import { Configuration } from '../../lib/settings';
import { testAssembly } from '../util';

Expand Down Expand Up @@ -59,23 +58,4 @@ export = {

test.done();
},

async 'renames get applied when stacks are selected'(test: Test) {
// GIVEN
const stacks = new AppStacks({
configuration: new Configuration(),
aws: new SDK(),
synthesizer: async () => FIXED_RESULT,
renames: new Renames({ withouterrors: 'withoutbananas' }),
});

// WHEN
const synthed = await stacks.selectStacks(['withouterrors'], ExtendedStackSelection.None);

// THEN
test.equal(synthed[0].name, 'withoutbananas');
test.equal(synthed[0].originalName, 'withouterrors');

test.done();
},
};

0 comments on commit 0f30e39

Please sign in to comment.