Condition

The optional Conditions section contains statements that define the circumstances under which entities are created or configured.

The condition method maps to the CloudFormation Template Anatomy Conditions section.

Example Snippets

There are 2 forms for conditions. Here are example snippets:

# medium form
condition "CreateProdResources", equals(ref("EnvType"), "prod")

# medium form with a Fn::Equals example
condition("CreateDevResources",
  "Fn::Equals": [
    ref("EnvType"),
    "dev"
  ]
)

# long form
condition("CreateStagResources",
  "Fn::Equals": [
    {"Ref": "EnvType"},
    "stag"
  ]
)

Output

Conditions:
  CreateProdResources:
    Fn::Equals:
    - Ref: EnvType
    - prod
  CreateDevResources:
    Fn::Equals:
    - Ref: EnvType
    - dev
  CreateStagResources:
    Fn::Equals:
    - Ref: EnvType
    - stag

Back to DSL Basics Docs.