Understand stack deployment time - AWS CloudFormation
Services or capabilities described in AWS documentation might vary by Region. To see the differences applicable to the AWS European Sovereign Cloud Region, see the AWS European Sovereign Cloud User Guide.

Understand stack deployment time

When you create, update, or delete a stack, CloudFormation provisions each resource in your template and reports that the stack operation is complete when your resources are ready to serve traffic. This topic describes how CloudFormation provisions a stack, what affects how long a stack operation takes, and how you can shorten deployment time.

How CloudFormation provisions a stack

CloudFormation reads the dependencies between resources in your template. A resource that references another resource, through Ref, Fn::GetAtt, or DependsOn, is provisioned after the resource it references. Resources that have no dependencies on each other are provisioned in parallel.

For each resource, CloudFormation applies the resource configuration and then confirms that the resource is ready to serve traffic. CloudFormation moves forward as soon as each resource is ready, so dependent resources start as early as possible. As a result, stacks with longer dependency chains see the largest improvement. When every resource in the stack is ready, CloudFormation reports that the stack operation is complete.

This behavior applies automatically to stack operations. You don't need to change your templates or set any parameters.

What affects deployment time

Dependency chains

The longest chain of resources that depend on each other sets the minimum time for a stack operation. Resources that are not part of that chain are provisioned in parallel and usually don't add to the total time.

Resources that take longer to become ready

Workloads that include resources such as Amazon RDS database instances, Elastic Load Balancing load balancers, NAT gateways, or Amazon CloudFront distributions spend most of their deployment time waiting for those resources to become ready to serve traffic.

Resource types that keep their current provisioning behavior

Workloads that include Amazon DynamoDB tables, AWS KMS keys, or Amazon EC2 Auto Scaling groups keep their current provisioning behavior for those resources. Other resources in the same stack still move forward as soon as they are ready. CloudFormation continues to expand the resource types that move forward as soon as they are ready.

Outputs that reference resource attributes

If a stack output references a resource attribute, for example with Fn::GetAtt, CloudFormation waits until the attribute value is available before it completes the stack operation. This wait can add time to the operation.

Ways to shorten deployment time

  • Use express mode for development iteration. Express mode completes stack operations as soon as CloudFormation applies the resource configuration, and resources continue becoming ready in the background. For more information, see Express mode.

  • Group resources by how often they change. Place resources that take longer to become ready, such as databases, in separate stacks from resources that you update often. Updates to the frequently changed stack then don't include the longer-running resources.

  • Remove dependencies that you don't need. Declare DependsOn only when a resource must wait for another resource. Fewer dependencies let CloudFormation provision more resources in parallel.

  • Reference resource attributes in outputs only when you need them. Outputs that reference resource attributes can extend a stack operation until those values are available.