CfnParameter giving me unresolved tokens error

0

I have this code as part of my cdk typescript

const stage = new CfnParameter(this, 'stageName');

const api = new apigateway.RestApi(this, 'typescriptapi', { description: 'example api gateway with typescript', deployOptions: { stageName: stage.valueAsString, }, .... ... **and running this command ** cdk deploy TypescriptcdkStack --parameters stageName='UAT'

it gives me error, what am I missing, I am using CDK 2.18.0 (build 75c90fa)

throw new Error(`ID components may not include unresolved tokens: ${unresolvedTokens.join(',')}`);

Error: Resolution error: ID components may not include unresolved tokens: DeploymentStage.${Token[TOKEN.200]}.

1回答
1

Hi there,

Values of CfnParameter cannot be resolved at synthesis, but only at deployment, so you won't be retrieving the values during the process of compiling. If you want to get the value at synthesis, you can use CDK Runtime context. Specifically, you can set the values of context via:

  • Through the --context option to the cdk command. (These values are always strings.)

  • In the project's cdk.context.json file.

  • In the context key of the project's cdk.json file.

  • In the context key of your ~/.cdk.json file.

  • In your AWS CDK app using the construct.node.setContext() method.

Then, you can get a context value using the construct.node.tryGetContext method.

サポートエンジニア
回答済み 2年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ