1 réponse
- Le plus récent
- Le plus de votes
- La plupart des commentaires
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
répondu il y a 6 mois
Contenus pertinents
- demandé il y a 6 mois
- demandé il y a un an
- demandé il y a 2 mois
- AWS OFFICIELA mis à jour il y a un an
- AWS OFFICIELA mis à jour il y a un an