AWS::CloudFormation::WaitCondition - Amazon CloudFormation
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

AWS::CloudFormation::WaitCondition

Important

For Amazon EC2 and Auto Scaling resources, we recommend that you use a CreationPolicy attribute instead of wait conditions. Add a CreationPolicy attribute to those resources, and use the cfn-signal helper script to signal when an instance creation process has completed successfully.

You can use a wait condition for situations like the following:

  • To coordinate stack resource creation with configuration actions that are external to the stack creation.

  • To track the status of a configuration process.

For these situations, we recommend that you associate a CreationPolicy attribute with the wait condition so that you don't have to use a wait condition handle. For more information and an example, see Creating wait conditions in a template. If you use a CreationPolicy with a wait condition, don't specify any of the wait condition's properties.

Note

If you use the VPC endpoints feature, resources in the VPC that respond to wait conditions must have access to CloudFormation, specific Amazon Simple Storage Service (Amazon S3) buckets. Resources must send wait condition responses to a presigned Amazon S3 URL. If they can't send responses to Amazon S3, CloudFormation won't receive a response and the stack operation fails. For more information, see Setting up VPC endpoints for Amazon CloudFormation.

Syntax

To declare this entity in your Amazon CloudFormation template, use the following syntax:

JSON

{ "Type" : "AWS::CloudFormation::WaitCondition", "Properties" : { "Count" : Integer, "Handle" : String, "Timeout" : String } }

YAML

Type: AWS::CloudFormation::WaitCondition Properties: Count: Integer Handle: String Timeout: String

Properties

Count

The number of success signals that CloudFormation must receive before it continues the stack creation process. When the wait condition receives the requisite number of success signals, CloudFormation resumes the creation of the stack. If the wait condition doesn't receive the specified number of success signals before the Timeout period expires, CloudFormation assumes that the wait condition has failed and rolls the stack back.

Updates aren't supported.

Required: No

Type: Integer

Update requires: No interruption

Handle

A reference to the wait condition handle used to signal this wait condition. Use the Ref intrinsic function to specify an AWS::CloudFormation::WaitConditionHandle resource.

Anytime you add a WaitCondition resource during a stack update, you must associate the wait condition with a new WaitConditionHandle resource. Don't reuse an old wait condition handle that has already been defined in the template. If you reuse a wait condition handle, the wait condition might evaluate old signals from a previous create or update stack command.

Updates aren't supported.

Required: No

Type: String

Update requires: No interruption

Timeout

The length of time (in seconds) to wait for the number of signals that the Count property specifies. Timeout is a minimum-bound property, meaning the timeout occurs no sooner than the time you specify, but can occur shortly thereafter. The maximum time that can be specified for this property is 12 hours (43200 seconds).

Updates aren't supported.

Required: No

Type: String

Update requires: No interruption

Return values

Ref

When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the resource name.

For more information about using the Ref function, see Ref.

Fn::GetAtt

The Fn::GetAtt intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.

For more information about using the Fn::GetAtt intrinsic function, see Fn::GetAtt.

Examples

WaitCondition that waits for the desired number of instances in a web server group

JSON

{ "WebServerGroup": { "Type": "AWS::AutoScaling::AutoScalingGroup", "Properties": { "AvailabilityZones": { "Fn::GetAZs": "", "LaunchConfigurationName": { "Ref": "LaunchConfig" } }, "MinSize": "1", "MaxSize": "5", "DesiredCapacity": { "Ref": "WebServerCapacity" }, "LoadBalancerNames": [ { "Ref": "ElasticLoadBalancer" } ] } }, "WaitHandle": { "Type": "AWS::CloudFormation::WaitConditionHandle" }, "WaitCondition": { "Type": "AWS::CloudFormation::WaitCondition", "DependsOn": "WebServerGroup", "Properties": { "Handle": { "Ref": "WaitHandle" }, "Timeout": "300", "Count": { "Ref": "WebServerCapacity" } } } }

YAML

WebServerGroup: Type: AWS::AutoScaling::AutoScalingGroup Properties: AvailabilityZones: Fn::GetAZs: '' LaunchConfigurationName: !Ref 'LaunchConfig' MinSize: '1' MaxSize: '5' DesiredCapacity: !Ref 'WebServerCapacity' LoadBalancerNames: - !Ref 'ElasticLoadBalancer' WaitHandle: Type: AWS::CloudFormation::WaitConditionHandle WaitCondition: Type: AWS::CloudFormation::WaitCondition DependsOn: WebServerGroup Properties: Handle: !Ref 'WaitHandle' Timeout: '300' Count: !Ref 'WebServerCapacity'

See also