Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Condition

Focus mode
Condition - AWS CloudFormation
Filter View

The intrinsic function Condition returns the evaluated result of the specified condition.

When you are declaring a condition in a template and you need to use another condition in the evaluation, you can use Condition to refer to that other condition. This is used when declaring a condition in the Conditions section of the template.

Declaration

JSON

{ "Condition" : "conditionName" }

YAML

Syntax for the full function name:

Condition: conditionName

Syntax for the short function name:

!Condition conditionName

Parameters

conditionName

The name of the condition you want to reference.

Return Value

The boolean result of the condition referenced.

Example

The following snippet is from the Conditions section of a template. The MyAndCondition condition includes the SomeOtherCondition condition:

JSON

"MyAndCondition": { "Fn::And": [ {"Fn::Equals": ["sg-mysggroup", {"Ref": "ASecurityGroup"}]}, {"Condition": "SomeOtherCondition"} ] }

YAML

MyAndCondition: !And - !Equals ["sg-mysggroup", !Ref "ASecurityGroup"] - !Condition SomeOtherCondition

Supported functions

You can't use any functions in the Condition function. You must specify a string that's a condition name.

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.