diff --git a/packages/@aws-cdk/cdk/lib/app.ts b/packages/@aws-cdk/cdk/lib/app.ts index f7f2994f8c393..b93183a51b680 100644 --- a/packages/@aws-cdk/cdk/lib/app.ts +++ b/packages/@aws-cdk/cdk/lib/app.ts @@ -45,10 +45,14 @@ export class App extends Root { const result: cxapi.SynthesizeResponse = { version: cxapi.PROTO_RESPONSE_VERSION, - stacks: this.synthesizeStacks(Object.keys(this.stacks)), - runtime: this.collectRuntimeInformation() + stacks: this.synthesizeStacks(Object.keys(this.stacks)) }; + const disableVersionReporting = this.node.getContext(cxapi.DISABLE_VERSION_REPORTING); + if (!disableVersionReporting) { + result.runtime = this.collectRuntimeInformation(); + } + const outfile = path.join(outdir, cxapi.OUTFILE_NAME); fs.writeFileSync(outfile, JSON.stringify(result, undefined, 2)); } diff --git a/packages/@aws-cdk/cdk/test/test.app.ts b/packages/@aws-cdk/cdk/test/test.app.ts index b0e5edff50db5..40c5244ef8462 100644 --- a/packages/@aws-cdk/cdk/test/test.app.ts +++ b/packages/@aws-cdk/cdk/test/test.app.ts @@ -268,6 +268,19 @@ export = { test.done(); }, + 'runtime library versions disabled'(test: Test) { + const context: any = {}; + context[cxapi.DISABLE_VERSION_REPORTING] = true; + + const response = withApp(context, app => { + const stack = new Stack(app, 'stack1'); + new Resource(stack, 'MyResource', { type: 'Resource::Type' }); + }); + + test.equals(response.runtime, undefined); + test.done(); + }, + 'runtime library versions'(test: Test) { const response = withApp({}, app => { const stack = new Stack(app, 'stack1'); diff --git a/packages/@aws-cdk/cx-api/lib/cxapi.ts b/packages/@aws-cdk/cx-api/lib/cxapi.ts index 867fd4a1af323..b7e186194433a 100644 --- a/packages/@aws-cdk/cx-api/lib/cxapi.ts +++ b/packages/@aws-cdk/cx-api/lib/cxapi.ts @@ -133,3 +133,8 @@ export const PATH_METADATA_KEY = 'aws:cdk:path'; * Enables the embedding of the "aws:cdk:path" in CloudFormation template metadata. */ export const PATH_METADATA_ENABLE_CONTEXT = 'aws:cdk:enable-path-metadata'; + +/** + * Disable the collection and reporting of version information. + */ +export const DISABLE_VERSION_REPORTING = 'aws:cdk:disable-version-reporting'; diff --git a/packages/aws-cdk/lib/api/cxapp/exec.ts b/packages/aws-cdk/lib/api/cxapp/exec.ts index a28fb64c08580..2e56d5062e1da 100644 --- a/packages/aws-cdk/lib/api/cxapp/exec.ts +++ b/packages/aws-cdk/lib/api/cxapp/exec.ts @@ -33,6 +33,15 @@ export async function execProgram(aws: SDK, config: Configuration): Promise