question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cdk.json seems to ignore various options

See original GitHub issue
  • I’m submitting a …

    • 🪲 bug report
  • What is the current behavior? When I add various settings options to the cdk.json file, they don’t seem to be applied when running cdk synth. Specifically pathMetadata and assetMetadata

To reproduce: make some very basic cdk app (I am currently using python). cdk.json

{
    "app": "python3 app.py",
    "pathMetadata": false,
    "assetMetadata": false,
    "versionReporting": false
}

When I run cdk -v synth I get the following:

cdk.json: {
  "app": "python3 app.py",
  "pathMetadata": false,
  "assetMetadata": false,
  "versionReporting": false,
  "staging": false
}
merged settings: {
  versionReporting: false,
  pathMetadata: true,
  output: 'cdk.out',
  app: 'python3 app.py',
  assetMetadata: true,
  staging: true,
  context: {},
  tags: []
}

Clearly you can see the pathMetadata and assetMetadata in the cdk.json but it doesn’t merge into the settings

  • What is the expected behavior (or behavior of feature suggested)? That the cdk.json settings be merged into the settings

  • What is the motivation / use case for changing the behavior or adding this feature? This is how it should work already

  • Please tell us about your environment:

    • CDK CLI Version: 1.3.0
    • OS: macOS Mojave
    • Language: Python

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:7
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
eladbcommented, Aug 12, 2019

Yes, we currently don’t have support for all switches in cdk.json and we should!

2reactions
zradlo1984commented, Dec 10, 2021

The reason is that in cdk.js all options that has defaults specified (excluding undefined value) will be set after command line arguments are parsed. And in settings.js (class Configuration) there is this code:

        this.settings = this.defaultConfig
            .merge(userConfig)
            .merge(this.projectConfig)
            .merge(this.commandLineArguments)
            .makeReadOnly();

so defaultConfig is overriden by userConfig (~/cdk.json) then by projectConfig(cdk.json) and then with commandLineArguments (which includes all defaults specified in cdk.js function parseCommandLineArguments so command line defaults overrides all options specified earlier).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting common AWS CDK issues
This topic describes how to troubleshoot the following issues with the AWS CDK.
Read more >
cdk deploy / destroy seem to ignore profile - AWS re:Post
Now, I am trying to deploy it to my another profile. If I hardcode account in the code, and specify --profile another ,...
Read more >
AWS CDK - How to properly share a generic app/stack across ...
I think this will work but context variables don't seem suited for this use-case, from the CDK documentation they cache all sorts of...
Read more >
AWS CDK Pipelines: Real-World Tips and Tricks (Part 2)
Note that the multiple CDK CLI versions can be specified in your pipeline application. The one specified in your package.json is used for...
Read more >
How to migrate CDK v1 to CDK v2 in 10 minuets
Theoretically, you just need to remove all the feature flags put on cdk.json in v1, and can check whether you need the new...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found