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(:use_prod_condition,
  equals(ref(:environment_type), "prod")
)

outputs:

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

Example: fn::and

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

outputs:

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

Example: fn:if

condition(:security_groups,
  fn::if(:create_new_security_group, ref(:new_security_group), ref(:existing_security_group))
)

outputs:

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

Example: fn:not

condition(:my_not_condition,
  fn::not(equals(ref(:environment_type), "prod"))
)

outputs:

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

Example: fn::or

condition(:my_or_condition,
  fn::or(equals("sg-mysggroup", ref(:a_security_group)), {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!