You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(cli): pathMetadata and assetMetadata defaults cannot be configured in cdk.json (#24533)
Previously, pathMetadata, assetMetadata, debug and staging could not be set in `cdk.json` as command-line parameters defaults would always overwrite this. In particular, this `cdk.json` would be ignored:
```
{
"app": "npx ts-node --prefer-ts-exts bin/example",
...
"pathMetadata": false,
"assetMetadata": false
}
```
The issue is this piece of code:
```
this.settings = this.defaultConfig
.merge(userConfig)
.merge(this.projectConfig)
.merge(this.commandLineArguments)
.makeReadOnly();
```
`commandLineArguments` returns true for the above mentioned options. This commit is a copy of #21891 which fell through the cracks, so I'm picking up as this can potentially cause outages to resources that have drift under the hood, and adding metadata looks like an `Update` operation to CloudFormation.
There are already unit tests around the cli which show that the same behavior works, located here:
https://github.com/aws/aws-cdk/blob/main/packages/%40aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts
shoutout to @berenddeboer who did the work, I'm just reviving it.
Closes#3573
----
*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Copy file name to clipboardExpand all lines: packages/aws-cdk/lib/cli.ts
+2-2
Original file line number
Diff line number
Diff line change
@@ -77,8 +77,8 @@ async function parseCommandLineArguments(args: string[]) {
77
77
.option('ca-bundle-path',{type: 'string',desc: 'Path to CA certificate to use when validating HTTPS requests. Will read from AWS_CA_BUNDLE environment variable if not specified',requiresArg: true})
.option('version-reporting',{type: 'boolean',desc: 'Include the "AWS::CDK::Metadata" resource in synthesized templates (enabled by default)',default: undefined})
80
-
.option('path-metadata',{type: 'boolean',desc: 'Include "aws:cdk:path" CloudFormation metadata for each resource (enabled by default)',default: true})
81
-
.option('asset-metadata',{type: 'boolean',desc: 'Include "aws:asset:*" CloudFormation metadata for resources that uses assets (enabled by default)',default: true})
80
+
.option('path-metadata',{type: 'boolean',desc: 'Include "aws:cdk:path" CloudFormation metadata for each resource (enabled by default)',default: undefined})
81
+
.option('asset-metadata',{type: 'boolean',desc: 'Include "aws:asset:*" CloudFormation metadata for resources that uses assets (enabled by default)',default: undefined})
82
82
.option('role-arn',{type: 'string',alias: 'r',desc: 'ARN of Role to use when invoking CloudFormation',default: undefined,requiresArg: true})
83
83
.option('staging',{type: 'boolean',desc: 'Copy assets to the output directory (use --no-staging to disable the copy of assets which allows local debugging via the SAM CLI to reference the original source files)',default: true})
84
84
.option('output',{type: 'string',alias: 'o',desc: 'Emits the synthesized cloud assembly into a directory (default: cdk.out)',requiresArg: true})
0 commit comments