- Newest
- Most votes
- Most comments
The error occurs because the AWS SDK client is receiving an unresolved CloudFormation token (${Token[TOKEN.657]}) instead of the actual ARN. To resolve this, ensure the instance ARN is fully resolved before passing it to the SDK client, possibly by using CloudFormation outputs or environment variables to store and reference the resolved ARN.
This happens because when you synthesize your app, not all values such as ARNs are available to be resolved. Resources need to be created before their ARNs are available. CDK uses tokens to represent these and these typically get resolved to Cloudformation Ref intrinsic functions. More information on tokens can be found in the CDK documentation page on tokens [1]. As the previous answer mentions, the recommended way to pass values from one stack to another within the same application is to either use a cross-stack reference or to use Parameter Store. More information and code samples can be found in this article [2]. Cross-stack references are done by exporting a variable containing the necessary value in one stack class and passing it in via the properties to another. CDK automatically handles transforming these to the relevant CloudFormation outputs.
[1] https://docs.aws.amazon.com/cdk/v2/guide/tokens.html
[2] https://repost.aws/knowledge-center/cdk-cross-stack-reference
Relevant content
- AWS OFFICIALUpdated 9 months ago

Actually I'm creating both the stacks in one app. I'm getting this error while I build the APP. Is it possible to get the actual ARN (in the first stack) at the build time?
To resolve the issue, you need to create cross-stack references. The error occurs because the ARN from the first stack isn't resolved at build time. To fix this, use
CfnOutputin the first stack and reference it in the second stack usingFn.importValue. This ensures the ARN is resolved before being passed to the AWS SDK client.Check these resources:
Thank you, Sorry for flagging the answer, I was not aware of the possible consequences. I thought its to marking the answer as incomplete/not-relevant.