How do i get CfnOutput without deploy

Viewed 568

I have created CDK repo.

which exports outputs to cdk-export.json file. Which is git ignored.

Now my teammate needs to have this file after he clones the repo. ( but he don't want to deploy the whole infrastructure )

Is there any command that gets CfnOutput without deploy?.

2 Answers

If the values you pass to the outputs are tokens, then they will be resolved to actual values during deployment, and not before.

Now, if another user needs these values, they should just import them - they don't need the values to do that. Use Fn.importValue for that. They would only need the export name, which is defined in the CDK code.

If you want to reuse outputs in processes separate from the actual deployment, I would recommend using the Systems Manager Parameter Store. Here you can store values, like for example API endpoints, that get generated during your deployment as part of your CDK code. You can then read these values afterwards using either CDK or SDK.

Article about writing and reading parameters in CDK

This one covers reading using the AWS SDK in case you want to directly use the values in applications disconnected from the deployment process.

Both of these approaches would allow you to use a single CDK/CloudFormation stack, as opposed to using CfnOutput which would require you to set up multiple stacks because the values will be tokenized as gshpychka explained in his answer.

Related