1 回答
- 最新
- 投票最多
- 评论最多
1
For conditional resource creation using CfnCondition
, you will need to add a condition
property to the cfnOptions of the resource.
Check out this sample:
const enableRefresh = new CfnParameter(this, 'EnableRefresh', { type: 'String', allowedValues: ['true', 'false'], default:'true' }) const isRefreshEnabledCond = new CfnCondition(this, "Refresh enabled",{ expression: Fn.conditionEquals(enableRefresh.valueAsString , 'true') }) const rule = new events.Rule(this, 'Rule', { schedule: events.Schedule.rate(Duration.minutes(100)), }); const cfnRule = rule.node.tryFindChild('Resource') as events.CfnRule; cfnRule.cfnOptions.condition = isRefreshEnabledCond
And run cdk synth
to verify the template. Make sure you see the Condition
attached in the resource definition.
Resources: Rule4C995B7F: Type: AWS::Events::Rule Properties: ScheduleExpression: rate(100 minutes) State: ENABLED Metadata: aws:cdk:path: demo-stack9/Rule/Resource Condition: Refreshenabled
已回答 6 个月前
相关内容
- AWS 官方已更新 1 年前
- AWS 官方已更新 1 年前
- AWS 官方已更新 1 年前