-
Does anybody have any tricks for using strings from CDK constructs in templates? Example I have some resources that I'd like to include in some of these Gateways, like the ID of a VpcLink or a BaseUrl for a VPC Endpoint (created in another construct). What I've got so far I've created a helper class to:
So you can do things like:
...then in the spec
But it's not as easy to do with non-resource strings or even string via parameters. E.g.
I've adapted my current CDK-workarounds from items I've found from other CDK users. I'm hoping that there are a few more created ideas out there to get me over this next hurdle! Edit |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
Typical. Spent days trying to work round the issue only to come up with the solution a few hours after posting this. Oh well. Here we go: Use Example (continued from above)
...pass the params in using the Cfn (rather than CDK) mechanism:
..and that allows you to use them in your templates:
|
Beta Was this translation helpful? Give feedback.
-
Looks like this issue has just been closed by the inactive bot! For anyone who had read this far and was hoping for something better that my suggested workaround of using a nested stack, please upvote this CloudFormation issue to address the underlying cause. |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
Typical. Spent days trying to work round the issue only to come up with the solution a few hours after posting this. Oh well. Here we go:
Use
NestedStack
stacks withCfnParameter
(rather than let CDK try to handle the variables internally). That gives you a CloudFormation reference for them.Example (continued from above)