1 Respuesta
- Más nuevo
- Más votos
- Más comentarios
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
respondido hace 6 meses
Contenido relevante
- OFICIAL DE AWSActualizada hace 4 meses
- OFICIAL DE AWSActualizada hace un año
- OFICIAL DE AWSActualizada hace 2 años
- OFICIAL DE AWSActualizada hace un año