| « PreviousNext » | |
![]() ![]() ![]() | Did this page help you? Yes | No | Tell us about it... |
Using the AWS::CloudFormation::WaitCondition and AWS::CloudFormation::WaitConditionHandle resources, you can place a wait condition in a template to make AWS CloudFormation pause the creation of the stack and wait for a signal before it continues to create the stack.
{
"Type" : "AWS::CloudFormation::WaitCondition",
"Properties" : {
"Count" : String,
"Handle" : String,
"Timeout" : String
}
} The number of success signals that AWS CloudFormation must receive before it continues the stack creation process. When the wait condition receives the requisite number of success signals, AWS CloudFormation resumes the creation of the stack. If the wait condition does not receive the specified number of success signals before the Timeout period expires, AWS CloudFormation assumes that the wait condition has failed and rolls the stack back.
Required: No.
Type: String.
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.
Required: Yes.
Type: String.
The length of time (in seconds) to wait for the number of signals that the Count property specifies. The maximum time that can be specified for this property is 12 hours (43200 seconds).
Required: Yes.
Type: String.
When the logical ID of this resource is provided to the Ref intrinsic
function, it returns the resource name.
For more information about using the Ref function, see Ref.
Fn::GetAtt returns a value for a specified attribute of this type.
This section lists the available attributes and corresponding return values.
Returns: A JSON object that contains the
UniqueId and Data values from
the wait condition signal(s) for the specified wait condition. For more
information about wait condition signals, see Wait Condition Signal JSON Format.
Example return value for a wait condition with 2 signals:
{ "Signal1" : "Step 1 complete." , "Signal2" : "Step 2 complete." } For more information about using Fn:GetAtt, see Fn::GetAtt.
Example Simple WaitCondition example with a WaitConditionHandle and GetAtt
"Resources" : {
"myWaitHandle" : {
"Type" : "AWS::CloudFormation::WaitConditionHandle",
"Properties" : { }
},
"myWaitCondition" : {
"Type" : "AWS::CloudFormation::WaitCondition",
"Properties" : {
"Handle" : { "Ref" : "myWaitHandle" },
"Timeout" : "300"
}
}
},
"Outputs" : {
"ApplicationData" : {
"Value" : { "Fn::GetAtt" : [ "myWaitCondition", "Data" ]},
"Description" : "The data passed back as part of signalling the WaitCondition"
}
} Example WaitCondition that waits for a Windows Server instance to start
"WindowsServerWaitHandle" : {
"Type" : "AWS::CloudFormation::WaitConditionHandle"
},
"WindowsServerWaitCondition" : {
"Type" : "AWS::CloudFormation::WaitCondition",
"DependsOn" : "WindowsServer",
"Properties" : {
"Handle" : { "Ref" : "WindowsServerWaitHandle" },
"Timeout" : "1800"
}
} Example WaitCondition that waits for the desired number of instances in a web server group
"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" }
}
}