Skip to content

Commit b2e1964

Browse files
author
Elad Ben-Israel
authored
refactor(core): misc cleanups to App-related APIs (#2731)
Fixes #1891 Testing: all toolkit integration tests passed. BREAKING CHANGE: * **cli:** This release requires CDK CLI >= 0.34.0 * **core:** `App.run()` was renamed to `App.synth()` (soft deprecation, it will be removed in the next release). * **core:** The `Stack.autoDeploy` feature has been removed. You can use `cdk deploy STACK ...` to determine which stacks to deploy (and wildcards are supported, so `cdk deploy '*'` will deploy all stacks. We plan to change the CLI to require specifying stacks if there is more than a single stack in the app (#2750). * **core:** `ConstructNode.aspects` is now private. * **core:** The `Synthesizer` has been removed. Use `ConstructNode.synth(node)` instead. * **core:** `ISynthesizable.synthesize` now accepts an `ISynthesisSession` which contains the `CloudAssemblyBuilder` object. This will allow further extension in the future. * **cx-api:** `cxapi.MissingContext` now includes the context `key` * **core:** `Stack.reportMissingContext` now accepts a single argument of type `cxapi.MissingContext`, which includes the missing context key * **core:** `Stack.annotatePhysicalName` has been removed (not used). * **core:** `Stack.missingContext` is now private. * **cx-api:** Multiple changes to the cloud assembly APIs to reduce surface area and clean up. * **cdk-integ (private):** if an integration test includes multiple stacks, use `/// !cdk-integ STACK ...` to explicitly specify which stacks to include in the test.
1 parent 0db32de commit b2e1964

File tree

201 files changed

+896
-686
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

201 files changed

+896
-686
lines changed

packages/@aws-cdk/app-delivery/test/integ.cicd.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ new cicd.PipelineDeployStackAction(stack, 'DeployStack', {
3838
capabilities: cfn.CloudFormationCapabilities.None,
3939
});
4040

41-
app.run();
41+
app.synth();

packages/@aws-cdk/assert/lib/inspector.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ export class StackPathInspector extends Inspector {
5454
// The names of paths in metadata in tests are very ill-defined. Try with the full path first,
5555
// then try with the stack name preprended for backwards compat with most tests that happen to give
5656
// their stack an ID that's the same as the stack name.
57-
const md = this.stack.metadata[this.path] || this.stack.metadata[`/${this.stack.name}${this.path}`];
57+
const metadata = this.stack.manifest.metadata || {};
58+
const md = metadata[this.path] || metadata[`/${this.stack.name}${this.path}`];
5859
if (md === undefined) { return undefined; }
59-
const resourceMd = md.find(entry => entry.type === 'aws:cdk:logicalId');
60+
const resourceMd = md.find(entry => entry.type === api.LOGICAL_ID_METADATA_KEY);
6061
if (resourceMd === undefined) { return undefined; }
6162
const logicalId = resourceMd.data;
6263
return this.stack.template.Resources[logicalId];

packages/@aws-cdk/assert/lib/synth-utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Stack, SynthesisOptions, Synthesizer } from '@aws-cdk/cdk';
1+
import { ConstructNode, Stack, SynthesisOptions } from '@aws-cdk/cdk';
22
import cxapi = require('@aws-cdk/cx-api');
33

44
export class SynthUtils {
@@ -7,8 +7,8 @@ export class SynthUtils {
77
*/
88
public static synthesize(stack: Stack, options: SynthesisOptions = { }): cxapi.CloudFormationStackArtifact {
99
// always synthesize against the root (be it an App or whatever) so all artifacts will be included
10-
const synth = new Synthesizer();
11-
const assembly = synth.synthesize(stack.node.root, options);
10+
const root = stack.node.root;
11+
const assembly = ConstructNode.synth(root.node, options);
1212
return assembly.getStack(stack.name);
1313
}
1414

packages/@aws-cdk/assert/test/test.assertions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ function synthesizedStack(fn: (stack: cdk.Stack) => void): cx.CloudFormationStac
209209
const stack = new cdk.Stack(app, 'TestStack');
210210
fn(stack);
211211

212-
const assembly = app.run();
212+
const assembly = app.synth();
213213
return assembly.getStack(stack.name);
214214
}
215215

packages/@aws-cdk/assets-docker/test/integ.assets-docker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ const asset = new assets.DockerImageAsset(stack, 'DockerImage', {
1212
new cdk.CfnOutput(stack, 'ArtifactHash', { value: asset.artifactHash });
1313
new cdk.CfnOutput(stack, 'ImageUri', { value: asset.imageUri });
1414

15-
app.run();
15+
app.synth();

packages/@aws-cdk/assets-docker/test/test.image-asset.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ export = {
172172
directory: path.join(__dirname, 'demo-image')
173173
});
174174

175-
const session = app.run();
175+
const session = app.synth();
176176

177177
test.ok(fs.existsSync(path.join(session.directory, 'asset.1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439c/Dockerfile')));
178178
test.ok(fs.existsSync(path.join(session.directory, 'asset.1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439c/index.py')));

packages/@aws-cdk/assets/lib/staging.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Construct } from '@aws-cdk/cdk';
1+
import { Construct, ISynthesisSession } from '@aws-cdk/cdk';
22
import cxapi = require('@aws-cdk/cx-api');
33
import fs = require('fs');
44
import path = require('path');
@@ -66,12 +66,12 @@ export class Staging extends Construct {
6666
}
6767
}
6868

69-
protected synthesize(session: cxapi.CloudAssemblyBuilder) {
69+
protected synthesize(session: ISynthesisSession) {
7070
if (!this.relativePath) {
7171
return;
7272
}
7373

74-
const targetPath = path.join(session.outdir, this.relativePath);
74+
const targetPath = path.join(session.assembly.outdir, this.relativePath);
7575

7676
// asset already staged
7777
if (fs.existsSync(targetPath)) {

packages/@aws-cdk/assets/test/integ.assets.directory.lit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ class TestStack extends cdk.Stack {
2020

2121
const app = new cdk.App();
2222
new TestStack(app, 'aws-cdk-asset-test');
23-
app.run();
23+
app.synth();

packages/@aws-cdk/assets/test/integ.assets.file.lit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ class TestStack extends cdk.Stack {
2020

2121
const app = new cdk.App();
2222
new TestStack(app, 'aws-cdk-asset-file-test');
23-
app.run();
23+
app.synth();

packages/@aws-cdk/assets/test/integ.assets.permissions.lit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ class TestStack extends cdk.Stack {
2020

2121
const app = new cdk.App();
2222
new TestStack(app, 'aws-cdk-asset-refs');
23-
app.run();
23+
app.synth();

0 commit comments

Comments
 (0)