Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Servers, nginx and Docker

A CloudFormation resource fails with Exceeded attempts to wait

Your error

Exceeded attempts to wait1 more line it can show

Fix it fast

Most common cause, 1 of 3

An ACM certificate is still waiting for domain validation

For a Route 53 zone in this account, add DomainValidationOptions with HostedZoneId and make its DomainName equal the certificate's DomainName; ACM then writes the CNAME itself.

Fix
Certificate:
  Type: AWS::CertificateManager::Certificate
  Properties:
    DomainName: example.com
    ValidationMethod: DNS
    DomainValidationOptions:
      - DomainName: example.com
        HostedZoneId: Z0123456789EXAMPLE
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

Exceeded attempts to wait (HandlerErrorCode NotStabilized) means a CloudFormation resource handler polled until its wait budget ran out before the resource stabilized. Find the resource in describe-stack-events, then remove the blocker: missing ACM DNS validation, a long RDS or Auto Scaling operation needing a service role, or your own CLI waiter giving up. Applies to AWS CLI 2.4x.

  • Applies to AWS CloudFormation (current service), AWS CLI 2.41, cloudformation-cli-java-plugin (resource handlers)
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

List the events that carry a status reason. The resource type next to the first failure tells you which cause applies; if no resource failed and the stack is still in progress, the wait came from your own terminal.

Run this first
aws cloudformation describe-stack-events --stack-name my-stack --query 'StackEvents[?ResourceStatusReason!=`null`].[Timestamp,LogicalResourceId,ResourceType,ResourceStatus,ResourceStatusReason]' --output table

Then find the line you see in this list and open its fix:

  1. 1An ACM certificate is still waiting for domain validationThe resource stuck in CREATE_IN_PROGRESS, or failed first, is AWS::CertificateManager::Certificate
  2. 2A slow resource ran past the timeout that applies to your credentialsThe failed resource is an Auto Scaling group, an RDS DB cluster or instance, a nested stack, an Elasticsearch domain or a Redshift cluster, and it keeps working in its own console
  3. 3The AWS CLI waiter stopped, while the stack carried onYour terminal printed Waiter StackCreateComplete failed: Max attempts exceeded, yet the stack status is still CREATE_IN_PROGRESS and no resource has failed

What does the error look like?

  • Exceeded attempts to wait
  • Waiter StackCreateComplete failed: Max attempts exceeded

Cause 1 of 3

An ACM certificate is still waiting for domain validation

You seeThe resource stuck in CREATE_IN_PROGRESS, or failed first, is AWS::CertificateManager::Certificate

Check

When a certificate's domain is not in a Route 53 zone of the same account, or email validation is chosen, CloudFormation cannot validate it on its own. The stack sits in CREATE_IN_PROGRESS until someone adds the CNAME or answers the email, and AWS lists certificate creation among the operations that can fail to stabilize.

Check
aws cloudformation describe-stack-events --stack-name my-stack --query 'StackEvents[?ResourceType==`AWS::CertificateManager::Certificate`].[ResourceStatus,ResourceStatusReason]' --output table

Fix

For a Route 53 zone in this account, add DomainValidationOptions with HostedZoneId and make its DomainName equal the certificate's DomainName; ACM then writes the CNAME itself. For DNS hosted elsewhere, create the CNAME that ACM shows at your DNS provider while the stack is waiting.

Fix
Certificate:
  Type: AWS::CertificateManager::Certificate
  Properties:
    DomainName: example.com
    ValidationMethod: DNS
    DomainValidationOptions:
      - DomainName: example.com
        HostedZoneId: Z0123456789EXAMPLE

Verify

The certificate resource reaches CREATE_COMPLETE and the stack moves on to the resources that depend on it.

Verify
aws cloudformation wait stack-create-complete --stack-name my-stack

Confirmed by docs.aws.amazon.com

Did this fix it?

Cause 2 of 3

A slow resource ran past the timeout that applies to your credentials

You seeThe failed resource is an Auto Scaling group, an RDS DB cluster or instance, a nested stack, an Elasticsearch domain or a Redshift cluster, and it keeps working in its own console

Check

AWS lists these types as able to outlast the default stabilization period. The limit depends on the resource and on the credentials used for the stack operation, so an operation run without a service role can stop waiting before the database or group is ready.

Check
aws cloudformation describe-stack-events --stack-name my-stack --max-items 30

Fix

Run the stack operation with a service role that CloudFormation assumes; AWS documents this as the way to extend the timeout. If a service role is already in use, AWS Support is the next step.

Fix
aws cloudformation deploy \
  --template-file template.yaml \
  --stack-name my-stack \
  --role-arn arn:aws:iam::123456789012:role/cfn-deploy-role

Verify

The slow resource reaches its COMPLETE status in the event list without a NotStabilized reason.

Verify
aws cloudformation describe-stack-events --stack-name my-stack --max-items 10

Confirmed by docs.aws.amazon.com

Did this fix it?

Cause 3 of 3

The AWS CLI waiter stopped, while the stack carried on

You seeYour terminal printed Waiter StackCreateComplete failed: Max attempts exceeded, yet the stack status is still CREATE_IN_PROGRESS and no resource has failed

Check

aws cloudformation wait stack-create-complete checks the stack every 30 seconds and exits with code 255 after 120 failed checks. That is a limit of the polling command on your machine, not a failure inside CloudFormation.

Check
aws cloudformation describe-stack-events --stack-name my-stack --max-items 5

Fix

Start the wait again, or poll the stack events in your pipeline until a final status appears. Treat exit code 255 as still running unless the events show a failure.

Fix
aws cloudformation wait stack-create-complete --stack-name my-stack
echo "exit code: $?"

Verify

The wait returns exit code 0 once the stack reaches CREATE_COMPLETE.

Verify
aws cloudformation wait stack-create-complete --stack-name my-stack && echo done

Confirmed by awscli.amazonaws.com

Did this fix it?

How do I stop it coming back?

  • Give every ACM certificate in a template a HostedZoneId when its zone lives in the same account, so validation never needs a person.
  • Deploy stacks that hold databases or Auto Scaling groups with a dedicated CloudFormation service role instead of a developer's session.
  • In CI, follow a stuck deploy with describe-stack-events instead of a fixed CLI waiter, and fail the job only on a FAILED or ROLLBACK status.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine on the same stack: Dispatch Pro, Raheeb, Loade Driver.

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.