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년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인