Condition Functions

Lono supports Condition Functions. Since most of these function names are Ruby keywords they must be called with a bang (!).

  • equals
  • and!
  • if!
  • not!
  • or!

Examples follow:

Example: equals

condition("UseProdCondition",
  equals(ref("EnvironmentType"), "prod")
)

outputs:

Conditions:
  UseProdCondition:
    Fn::Equals:
    - Ref: EnvironmentType
    - prod

Example: and!

condition("MyAndCondition",
  and!(equals("sg-mysggroup", ref("ASecurityGroup")), {Condition: "SomeOtherCondition"})
)

outputs:

Conditions:
  MyAndCondition:
    Fn::And:
    - Fn::Equals:
      - sg-mysggroup
      - Ref: ASecurityGroup
    - Condition: SomeOtherCondition

Example: if!

condition("SecurityGroups",
  if!("CreateNewSecurityGroup", ref("NewSecurityGroup"), ref("ExistingSecurityGroup"))
)

outputs:

Conditions:
  SecurityGroups:
    Fn::If:
    - CreateNewSecurityGroup
    - Ref: NewSecurityGroup
    - Ref: ExistingSecurityGroup

Example: not!

condition("MyNotCondition",
  not!(equals(ref("EnvironmentType"), "prod"))
)

outputs:

Conditions:
  MyNotCondition:
    Fn::Not:
    - Fn::Equals:
      - Ref: EnvironmentType
      - prod

Example: or!

condition("MyOrCondition",
  or!(equals("sg-mysggroup", ref("ASecurityGroup")), {Condition: "SomeOtherCondition"})
)

outputs:

Conditions:
  MyOrCondition:
    Fn::Or:
    - Fn::Equals:
      - sg-mysggroup
      - Ref: ASecurityGroup
    - Condition: SomeOtherCondition

Back to Intrinsic Functions List.

Pro tip: Use the <- and -> arrow keys to move back and forward.

Edit this page

See a typo or an error? You can improve this page. This website is available on GitHub and contributions are encouraged and welcomed. We love pull requests from you!