Skip to content

Commit 0f30e39

Browse files
authoredJun 11, 2019
feat(cli): Remove stack rename support (#2819)
BREAKING CHANGE: The CLI no longer accepts `--rename`, and the stack names are now immutable on the stack artifact. Fixes #2670
1 parent 7c022cf commit 0f30e39

File tree

5 files changed

+3
-131
lines changed

5 files changed

+3
-131
lines changed
 

‎packages/@aws-cdk/cx-api/lib/cloudformation-artifact.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ export class CloudFormationStackArtifact extends CloudArtifact {
3131
public readonly parameters: { [id: string]: string };
3232

3333
/**
34-
* The name of this stack. This is read/write and can be used to rename the stack.
34+
* The name of this stack.
3535
*/
36-
public name: string;
36+
public readonly name: string;
3737

3838
constructor(assembly: CloudAssembly, name: string, artifact: ArtifactManifest) {
3939
super(assembly, name, artifact);

‎packages/aws-cdk/bin/cdk.ts

-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { RequireApproval } from '../lib/diff';
1414
import { availableInitLanguages, cliInit, printAvailableTemplates } from '../lib/init';
1515
import { data, debug, error, print, setVerbose, success } from '../lib/logging';
1616
import { PluginHost } from '../lib/plugin';
17-
import { parseRenames } from '../lib/renames';
1817
import { serializeStructure } from '../lib/serialize';
1918
import { Configuration, Settings } from '../lib/settings';
2019
import version = require('../lib/version');
@@ -31,7 +30,6 @@ async function parseCommandLineArguments() {
3130
.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 })
3231
.option('context', { type: 'array', alias: 'c', desc: 'Add contextual string parameter (KEY=VALUE)', nargs: 1, requiresArg: true })
3332
.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 })
34-
.option('rename', { type: 'string', desc: 'Rename stack name if different from the one defined in the cloud executable ([ORIGINAL:]RENAMED)', requiresArg: true })
3533
.option('trace', { type: 'boolean', desc: 'Print trace for stack warnings' })
3634
.option('strict', { type: 'boolean', desc: 'Do not construct stacks with warnings' })
3735
.option('ignore-errors', { type: 'boolean', default: false, desc: 'Ignores synthesis errors, which will likely produce an invalid output' })
@@ -112,7 +110,6 @@ async function initCommandLine() {
112110
configuration,
113111
aws,
114112
synthesizer: execProgram,
115-
renames: parseRenames(argv.rename)
116113
});
117114

118115
/** Function to load plug-ins, using configurations additively. */

‎packages/aws-cdk/lib/api/cxapp/stacks.ts

+1-23
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import colors = require('colors/safe');
44
import minimatch = require('minimatch');
55
import contextproviders = require('../../context-providers');
66
import { debug, error, print, warning } from '../../logging';
7-
import { Renames } from '../../renames';
87
import { Configuration } from '../../settings';
98
import { SDK } from '../util/sdk';
109

@@ -45,11 +44,6 @@ export interface AppStacksProps {
4544
*/
4645
aws: SDK;
4746

48-
/**
49-
* Renames to apply
50-
*/
51-
renames?: Renames;
52-
5347
/**
5448
* Callback invoked to synthesize the actual stacks
5549
*/
@@ -69,11 +63,7 @@ export class AppStacks {
6963
*/
7064
public assembly?: cxapi.CloudAssembly;
7165

72-
private readonly renames: Renames;
73-
74-
constructor(private readonly props: AppStacksProps) {
75-
this.renames = props.renames || new Renames({});
76-
}
66+
constructor(private readonly props: AppStacksProps) {}
7767

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

@@ -132,7 +121,6 @@ export class AppStacks {
132121

133122
// Only check selected stacks for errors
134123
this.processMessages(selectedList);
135-
this.applyRenames(selectedList);
136124

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

@@ -277,13 +262,6 @@ export class AppStacks {
277262
logFn(` ${entry.trace.join('\n ')}`);
278263
}
279264
}
280-
281-
private applyRenames(stacks: cxapi.CloudFormationStackArtifact[]) {
282-
this.renames.validateSelectedStacks(stacks);
283-
for (const stack of stacks) {
284-
stack.name = this.renames.finalName(stack.name);
285-
}
286-
}
287265
}
288266

289267
/**

‎packages/aws-cdk/lib/renames.ts

-83
This file was deleted.

‎packages/aws-cdk/test/api/test.stacks.ts

-20
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import cxapi = require('@aws-cdk/cx-api');
22
import { Test } from 'nodeunit';
33
import { SDK } from '../../lib';
44
import { AppStacks, ExtendedStackSelection } from '../../lib/api/cxapp/stacks';
5-
import { Renames } from '../../lib/renames';
65
import { Configuration } from '../../lib/settings';
76
import { testAssembly } from '../util';
87

@@ -59,23 +58,4 @@ export = {
5958

6059
test.done();
6160
},
62-
63-
async 'renames get applied when stacks are selected'(test: Test) {
64-
// GIVEN
65-
const stacks = new AppStacks({
66-
configuration: new Configuration(),
67-
aws: new SDK(),
68-
synthesizer: async () => FIXED_RESULT,
69-
renames: new Renames({ withouterrors: 'withoutbananas' }),
70-
});
71-
72-
// WHEN
73-
const synthed = await stacks.selectStacks(['withouterrors'], ExtendedStackSelection.None);
74-
75-
// THEN
76-
test.equal(synthed[0].name, 'withoutbananas');
77-
test.equal(synthed[0].originalName, 'withouterrors');
78-
79-
test.done();
80-
},
8161
};

0 commit comments

Comments
 (0)