I have a use-case where my bash script needs to wait until AWS CloudFormation completes Creating or Updating the stacks.
I found the following commands can be used to do so:
aws cloudformation wait stack-create-complete --stack-name STACK_NAME
aws cloudformation wait stack-update-complete --stack-name STACK_NAME
Following is a snippet of the script -
echo "Creating stack ..."
aws cloudformation create-stack --stack-name $STACK_NAME \
--parameters ParameterKey=Environment,ParameterValue=Development \
--template-body file://someCfScript.yaml \
--capabilities CAPABILITY_AUTO_EXPAND --profile someProfileName
aws cloudformation wait stack-create-complete --stack-name $STACK_NAME
But I am not able to do so and I get the following error:
{
"StackId": "arn:aws:cloudformation:ap-southeast-1:someAwsAcId:stack/someStackName/xxxx-xxx-xx-xxx-xxxxx"
}
Waiter StackCreateComplete failed: Waiter encountered a terminal failure state
And instead of waiting, the script goes to the next line, causing things to break.