Condition Functions

Lono supports Condition Functions. Since most of these function names are Ruby keywords they must be called explictly with fn::.

  • equals
  • fn::and
  • fn::if
  • fn::not
  • fn::or

Examples follow:

Example: equals

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

outputs:

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

Example: fn::and

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

outputs:

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

Example: fn:if

condition("SecurityGroups",
  fn::if("CreateNewSecurityGroup", ref("NewSecurityGroup"), ref("ExistingSecurityGroup"))
)

outputs:

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

Example: fn:not

condition("MyNotCondition",
  fn::not(equals(ref("EnvironmentType"), "prod"))
)

outputs:

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

Example: fn::or

condition("MyOrCondition",
  fn::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!