1
votes

I'm using the aws cli to create a cloudformation stackset

echo "creating stackset..."

some_stackset_id=$(aws cloudformation create-stack-set \
  --stack-set-name $StacksetName \
  --template-url $TemplateURL \
  --capabilities '["CAPABILITY_NAMED_IAM"]' \
  --administration-role-arn "arn:aws:iam::000000000009:role/AWSCloudFormationStackSetAdministrationRole" \
  --execution-role-name "AWSCloudFormationStackSetExecutionRole" \
  --parameters '[
  {"ParameterKey":"env","ParameterValue":"DEV","UsePreviousValue": false, "ResolvedValue": "DEV"}

  ]' \
  | jq '.StackSetId')

echo "Waiting for stack instance to be created ..."

aws cloudformation wait stack-create-complete \
  --region $region \
  --stack-name $some_stackset_id

echo "Creating stack instances..."

some_id=$(aws cloudformation create-stack-instances \
  --stack-set-name myStackset\
  --accounts '["0000030000"]' \
  --regions '["us-east-1"]' 
  --operation-preferences='
  {
  "RegionOrder": ["us-east-1"],
  "FailureToleranceCount": 0,
  "MaxConcurrentCount": 3
}' | jq '.OperationId')

echo "Done creating stack instances"

When I wait for the stackset to finish creating before I can create stack instances within that stackset, the cli is supposed to

Wait until stack status is CREATE_COMPLETE. It will poll every 30 seconds until a successful state has been reached. This will exit with a return code of 255 after 120 failed checks. https://docs.aws.amazon.com/cli/latest/reference/cloudformation/wait/stack-create-complete.html

However, that's not the behavior i'm observing. As soon as the cli gets to that aws cloudformation wait stack-create-complete... it doesn't wait there for 30 secs as it's supposed to according to the cli doc, instead, it just moves on to the next command (create-stack-instances) which fails with OperationInProgressException any idea why?

1

1 Answers

0
votes

A Cloudformation stackSet is different from a stack. The waiter you are using aws cloudformation wait stack-create-complete is for stacks, not stackSets. Unfortunately there is no waiter for stackSets at this time, though using a bash loops is not difficult to create your own waiter.