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.synth output - returning as JSON/String in code #408

Closed
lukepopp opened this issue Oct 9, 2020 · 7 comments
Closed

App.synth output - returning as JSON/String in code #408

lukepopp opened this issue Oct 9, 2020 · 7 comments
Labels
enhancement New feature or request testing

Comments

@lukepopp
Copy link

lukepopp commented Oct 9, 2020

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

Hi

I'm trying to trap the output of App.synth() in Java. Unfortunately the synth method returns void so I can't get this easily in code. I can use the Builder to specify an output directory and read the output from that but was looking for a better way . The AWS CDK has options to get the JSON Tree in code. Thanks.

References

@lukepopp lukepopp added the enhancement New feature or request label Oct 9, 2020
@jsteinich
Copy link
Collaborator

I'm curious how you plan on using the synthesized output. Are you looking for something like #237 ?

@lukepopp
Copy link
Author

I'm looking to be able to do things like Unit testing and potentially doc generation automation.

@martimconstantino
Copy link

I'm also looking for a good way of unit testing the CDK in Java.
So far, the best I managed to do is:
`
App app = new App();
Stack stack = new Stack(app, 'test-stack');
// Add other CDK constructs

CloudAssembly assembly = app.synth();
String treePath = assembly.getDirectory() + "/" + assembly.tree().getFile();
JsonNode tree = objectMapper.readTree(new File(treePath));
`

Now, I have a tree.json file to check. But it doesn't seem to be the right way, though

@jsteinich
Copy link
Collaborator

It does look like AWS CDK has a couple pieces that don't exist in cdktf. Seems reasonable to explore similar patterns.
See https://docs.aws.amazon.com/cdk/latest/guide/testing.html

@skorfmann
Copy link
Contributor

There are some basic testing capabilities - see here for an example: https://github.com/hashicorp/terraform-cdk/blob/fc3363e575f14d43aacd5512b608105e4216536c/packages/cdktf/test/provider.test.ts

@lukepopp what are you looking for beyond that? Some helpers around matching particular parts of resources / attributes?

@DanielMSchmidt
Copy link
Contributor

We added unit testing capabilities, the other parts overlap with #237 and #682, closing this in favor of the tickets referencing it

@github-actions
Copy link
Contributor

I'm going to lock this issue because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request testing
Projects
None yet
Development

No branches or pull requests

5 participants