aws-cloudformation
Manage AWS CloudFormation stacks
TLDR
Create a stack from a template file
Delete a stack
List all stacks
List all running stacks
Check the status of a stack
Initiate drift detection for a stack
Check the drift status output of a stack using StackDriftDetectionId from the previous command output
SYNOPSIS
aws cloudformation <subcommand> [--stack-name value] [global-options] [subcommand-options]
PARAMETERS
--stack-name
Name of the stack to operate on.
--template-body
Template body as a string or file content.
--template-url
S3 URL location of the template file.
--parameters
Key-value pairs for stack parameters (JSON or file).
--capabilities
Capabilities like CAPABILITY_IAM or CAPABILITY_NAMED_IAM.
--tags
Key-value pairs to tag the stack and resources.
--role-arn
ARN of IAM role for stack execution.
--region
AWS region (e.g., us-east-1).
--output
Output format: json|text|table.
--debug
Turn on debug logging.
create-stack
Creates a new stack from a template.
delete-stack
Deletes a specified stack.
update-stack
Updates an existing stack.
describe-stacks
Describes one or more stacks.
validate-template
Validates a template syntax.
DESCRIPTION
The aws cloudformation command is part of the AWS Command Line Interface (CLI) for interacting with AWS CloudFormation, a service that enables modeling and provisioning of AWS resources using declarative templates in JSON or YAML. It allows users to create, update, delete, and monitor stacks—logical units of resources—automating infrastructure as code (IaC).
Key operations include validating templates before deployment, creating change sets for safe updates, managing stack sets across accounts and regions, tagging resources, and handling rollbacks. Supports features like custom resources, macros, modules, and drift detection to ensure infrastructure matches templates. Integrates with CI/CD tools, GitOps, and other AWS services such as IAM, Lambda, and S3.
Ideal for DevOps workflows, it provides detailed outputs on stack events, resources, and exports. Requires AWS credentials with appropriate IAM permissions. Enhances reproducibility, version control, and scalability of cloud deployments.
CAVEATS
Requires AWS CLI v2+ installed and configured with valid credentials. Stack operations can incur costs and may take minutes; use --capabilities for IAM resources. Limited to 500 resources per stack by default. No direct support for graphical UIs—use AWS Console for that.
INSTALLATION
Install via pip install awscli or package managers; run aws configure for setup.
EXAMPLE
aws cloudformation create-stack --stack-name myapp --template-body file://template.yaml --capabilities CAPABILITY_IAM
Creates stack myapp from local YAML template.
SUBCOMMANDS
Full list: aws cloudformation help. Includes list-stack-sets, detect-stack-drift, estimate-template-cost.
HISTORY
AWS CloudFormation launched in July 2011. Integrated into AWS CLI v1 (2013); enhanced in v2 (2020) with better performance and pagination. Added StackSets (2017), modules (2021), and drift detection for enterprise IaC.
SEE ALSO
aws(1)


