Skip to content

(aws-cdk): cdk bootstrap prints YAML template even when using --json option #21456

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rantoniuk opened this issue Aug 4, 2022 · 4 comments
Closed
Labels
bug This issue is a bug. effort/small Small work item – less than a day of effort good first issue Related to contributions. See CONTRIBUTING.md p2 package/tools Related to AWS CDK Tools or CLI

Comments

@rantoniuk
Copy link

rantoniuk commented Aug 4, 2022

Describe the bug

OK, I'm either stupid and I'm missing something obvious or the command --show-template doesn't behave like it should.
The below commands are always printing the same template for me:

$ cdk bootstrap --show-template > x
$ cdk bootstrap --show-template --bootstrap-kms-key-id=AWS_KEY_MANAGED > x2
$ cdk bootstrap --show-template --bootstrap-customer-key > x3
$ cdk bootstrap --show-template --bootstrap-customer-key asd > x4
$ cdk bootstrap --show-template --json > x5

$ diff x* 
$
(no output, same files)

Why? There is no --dry-run- option, so I expect to be able to see the template modified with the CLI options to validate before actual deployment. Instead, even -j does not have any effect whatsoever for me. Am I missing something?

Also, in the template I see that it's possible to use AWS_MANAGED_KEY for FileAssetsBucketKmsKeyId.
Shouldn't this be possible to enable this via CLI (and be documented in cdk bootstrap -h) ?

I even tried to do the following:

  1. cdk bootstrap --show-template > template
  2. (edited the template file and set FileAssetsBucketKmsKeyId to AWS_MANAGED_KEY
  3. cdk bootstrap --cloudformation-execution-policies arn:aws:iam::aws:policy/AdministratorAccess aws://XXX/eu-west-1 --template template --no-execute

Result:

  • CDKToolkit: creating CloudFormation changeset... Environment bootstrapped (no changes).
  • CloudFormation shows an empty and FAILED changeset.

CDK CLI Version

2.35.0 (build 5c23578)

Framework Version

No response

Node.js Version

v14.19.3

OS

MacOS

Language

Typescript

Language Version

No response

Other information

No response

@rantoniuk rantoniuk added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Aug 4, 2022
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Aug 4, 2022
@rantoniuk
Copy link
Author

I was able to effectively re-bootstrap (update) the bucket by using cdk bootstrap --bootstrap-kms-key-id arn:aws:kms:eu-west-1:..... command, but without review.
The changeset that was created with --no-execute was either empty or it contained "modify" on some resources but I was unable to see how the resources are going to be modified (which is the purpose of the ChangeSet review right?)

@peterwoodworth
Copy link
Contributor

These options aren't going to show changes because they make use of CloudFormation parameters. Supplying a different parameter will not show a difference in the template.

The --json option isn't working here because that option is a global option showing for all our commands, but it isn't actually enabled for the bootstrap command. Could be changed here where it gets printed

process.stdout.write(`${toYAML(template)}\n`);

@peterwoodworth peterwoodworth added good first issue Related to contributions. See CONTRIBUTING.md p2 effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels Aug 22, 2022
@peterwoodworth peterwoodworth changed the title (aws-cdk): cdk bootstrap doesn't care for template CLI arguments (aws-cdk): cdk bootstrap prints YAML template even when using --json option Aug 22, 2022
mergify bot pushed a commit that referenced this issue Aug 31, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
…ion (#21852)

Fix for the issue #21456.

Added support of `--json` option for `cdk bootstrap --show-template` command.

`cdk bootstrap --show-template` - will print YAML template
`cdk bootstrap --show-template --json` - will print JSON template

**How I tested it locally?**

- Prepared a package with fix with `yarn package` and installed with `npm install -g dist/js/aws-cdk-0.0.0.tgz`

- Reproduced steps from the bug #21456

- Ensured that the issue is fixed

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@arewa
Copy link
Contributor

arewa commented Sep 1, 2022

Hi @peterwoodworth and @rantoniuk , I prepared a fix and it was already merged, perhaps we could resolve this issue.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 1, 2022

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. effort/small Small work item – less than a day of effort good first issue Related to contributions. See CONTRIBUTING.md p2 package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

No branches or pull requests

4 participants