💾 Archived View for cfdocs.wetterberg.nu › using-cfn-waitcondition.gemini captured on 2021-12-03 at 14:04:38. Gemini links have been rewritten to link to archived content

View Raw

More Information

-=-=-=-=-=-=-

Creating wait conditions in a template

Search

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.

For more information, see CreationPolicy or Deploying applications on Amazon EC2 with AWS CloudFormation.

CreationPolicy

Deploying applications on Amazon EC2 with AWS CloudFormation

Using the AWS::CloudFormation::WaitConditionHandle resource and CreationPolicy attribute, you can do the following:

AWS::CloudFormation::WaitConditionHandle

CreationPolicy

For example, you can start the creation of another resource after an application configuration is partially complete, or you can send signals during an installation and configuration process to track its progress.

Using a wait condition handle

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

VPC endpoint

Setting up VPC endpoints for AWS CloudFormation

Example bucket policies for VPC endpoints for Amazon S3

You can use the wait condition and wait condition handle to make AWS CloudFormation pause the creation of a stack and wait for a signal before it continues to create the stack. For example, you might want to download and configure applications on an Amazon EC2 instance before considering the creation of that Amazon EC2 instance complete.

The following list provides a summary of how a wait condition with a wait condition handle works:

DependsOn attribute

Wait condition signal JSON format

When you signal a wait condition, you must use the following JSON format:

1. {
2.   "Status" : "StatusValue",
3.   "UniqueId" : "Some UniqueId",
4.   "Data" : "Some Data",
5.   "Reason" : "Some Reason"
6. }

Where:

Fn::GetAtt function

DescribeStacks action

"WaitConditionData" : {
  "Value" : { "Fn::GetAtt" : [ "mywaitcondition", "Data" ]},
  "Description" : "The data passed back as part of signalling the WaitCondition"
},

The Fn::GetAtt function returns the UniqueId and Data as a name/value pair within a JSON structure. The following is an example of the Data attribute returned by the WaitConditionData output value defined above:

{"Signal1":"Application has completed configuration."}