Skip to content
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

app-delivery expects yaml output, but cdk synth only outputs json #3595

Closed
brucejcooper opened this issue Aug 9, 2019 · 5 comments · Fixed by #3986
Closed

app-delivery expects yaml output, but cdk synth only outputs json #3595

brucejcooper opened this issue Aug 9, 2019 · 5 comments · Fixed by #3986
Assignees
Labels
bug This issue is a bug. management/ci-cd Related to CI/CD

Comments

@brucejcooper
Copy link

I'd like to report a simple bug in the app-delivery module. I'm trying to use the app-deploy module to build and self-deploy a CDK app, just like in the documentation. The problem is that the app-deploy model expects the built CFN to be in yaml format (see https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/app-delivery/lib/pipeline-deploy-stack-action.ts#L123), but running node_modules/.bin/cdk synth -o dist will only produce json output, no matter what options you supply.

The only way I've been able work around the problem is to do a dodgey content redirect in the buildspec.yml file

  # When redirecting, the directory must exist before the command is run.
  # TODO remove when cdk bug is resolved.
  - mkdir -p dist

  # There is a bug in CDK whereby the cdk command generates json when using the 
  # -o option, but the app-deploy target expects yaml.  To work around this, we
  # do silly buggers with redirection of the stdout, which is yaml.
  - node_modules/.bin/cdk synth -o dist > dist/CodepipelineMetaStack.template.yaml

Whilst this makes it work, it isn't very elegant and its prone to output changes in the cdk executable. Its trivial to fix, so I thought I'd raise this issue.

This is related to #2965 in that fixing that one would allow me to create a yaml file as part of a call to cdk synth. You could either fix that bug, or change the linked file to expect json instead...

@brucejcooper brucejcooper added the needs-triage This issue or PR still needs to be triaged. label Aug 9, 2019
@eladb
Copy link
Contributor

eladb commented Aug 12, 2019

Since JSON is YAML I am wondering what kind of error you have observed.

@eladb eladb added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Aug 12, 2019
@caseyhoward
Copy link

The problem isn't with the contents of the file, it's with the name of the file. The error I see is "File [blah.template.yaml] does not exist in artifact [Artifact_Blah_Something]". It's looking for a file with the yaml extension but synth outputs a json extension. I'm really curious how this ever worked since it's hardcoded to look for yaml in the source code. Did "cdk synth" used to emit yaml?

@brucejcooper
Copy link
Author

Since JSON is YAML I am wondering what kind of error you have observed.

As casey suggests, its a file naming problem.

if you look at https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/app-delivery/lib/pipeline-deploy-stack-action.ts#L123, you'll see that the replace changeset action is expecting a file that ends in .yaml. When the pipeline is built using the suggested command of node_modules/.bin/cdk synth -o dist the file that is created is dist/{nameofstack}.template.json. This causes the action to fail. Simply changing the expected filename to .json will fix this.

@eladb eladb added management/ci-cd Related to CI/CD bug This issue is a bug. and removed response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. needs-triage This issue or PR still needs to be triaged. labels Aug 13, 2019
@eladb
Copy link
Contributor

eladb commented Aug 13, 2019

Got it. Confirming this is a bug in the app-delivery library.

@eklinkhammer
Copy link

As a short term fix, I added this to my buildspec:
- find dist/ -name '*.template.json' -exec rename 's/\.json$/.yaml/' \{} \;

eladb pushed a commit that referenced this issue Sep 8, 2019
Use the new `stack.templateFile` instead of hard-coding the template
file name (which was wrongfully using the YAML extension).

Fixes #3595
eladb pushed a commit that referenced this issue Sep 8, 2019
Use the new `stack.templateFile` instead of hard-coding the template
file name (which was wrongfully using the YAML extension).

Fixes #3595
@mergify mergify bot closed this as completed in #3986 Sep 9, 2019
mergify bot pushed a commit that referenced this issue Sep 9, 2019
Use the new `stack.templateFile` instead of hard-coding the template
file name (which was wrongfully using the YAML extension).

Fixes #3595
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. management/ci-cd Related to CI/CD
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants