Skip to main content
In this lesson we cover the most common ways to deploy AWS CloudFormation templates (YAML or JSON). Whether you prefer a visual, manual workflow or a fully automated CI/CD pipeline, CloudFormation supports patterns for development, testing, and production deployments. Below we summarize the options, show concise CLI examples, and outline recommended practices for automation and permissions.

Deployment approaches at a glance

  • Manual (visual): AWS Management Console and Infrastructure Composer — good for exploration, quick edits, and one-off stack creation.
  • CLI (scriptable): aws cloudformation deploy / create-stack / update-stack — ideal for reproducible deployments and automation scripts.
  • CI/CD (fully automated): AWS CodePipeline or external CI systems — recommended for continuous delivery from version control.

Manual methods (Console and Infrastructure Composer)

  • AWS Management Console: Upload a CloudFormation template in the CloudFormation console and create a stack. The console guides you through selecting parameters, tags, and required capabilities, then provisions resources.
  • Infrastructure Composer: Import a template to visually edit resources or build a template from scratch, then deploy it using CloudFormation.
Typical console/Composer flow:
  1. Author or modify the template (YAML/JSON).
  2. Upload the template or point CloudFormation to an S3 URL.
  3. Create the stack and provide parameters, tags, and any required capabilities.
  4. CloudFormation provisions the resources defined in the template.

Automated methods (CLI)

Using the AWS CLI is fast, repeatable, and integrates into scripts and pipelines. Two common CLI patterns:
  • High-level (recommended for many workflows): aws cloudformation deploy — handles create-or-update automatically and is simpler for typical use cases.
  • Low-level explicit operations: aws cloudformation create-stack and aws cloudformation update-stack — use when you need explicit control.
Example: deploy a local template file using aws cloudformation deploy
aws cloudformation deploy \
  --template-file template.yaml \
  --stack-name my-stack \
  --capabilities CAPABILITY_NAMED_IAM
Example: create a stack with parameters using aws cloudformation create-stack
aws cloudformation create-stack \
  --stack-name my-stack \
  --template-body file://template.yaml \
  --capabilities CAPABILITY_NAMED_IAM \
  --parameters ParameterKey=Environment,ParameterValue=production
Notes on CLI usage:
  • aws cloudformation deploy performs create-or-update (idempotent behavior) and can simplify deployments when you track templates in version control.
  • aws cloudformation create-stack explicitly creates a new stack; use aws cloudformation update-stack for existing stacks.
  • When templates create or modify IAM resources (roles, policies), include capability flags such as CAPABILITY_IAM or CAPABILITY_NAMED_IAM. If your template uses CloudFormation macros that expand at processing time, include CAPABILITY_AUTO_EXPAND.
Always supply the correct CAPABILITY_* flags for templates that create or modify IAM resources. Also ensure the IAM principal running the CLI has permissions to create/update the resources referenced in your template.
For continuous delivery, integrate CloudFormation with CodePipeline (or another CI/CD system). Typical pipeline pattern:
  1. Store templates and application code in a source repo (CodeCommit, GitHub, etc.).
  2. CodePipeline (or your CI system) detects changes and triggers the pipeline.
  3. Optional build/test stages (CodeBuild, unit tests, integration tests).
  4. A CloudFormation deploy action creates or updates stacks (can deploy nested stacks or change sets).
A slide titled "Deploying CloudFormation Templates" showing an automated method that integrates AWS CloudFormation with AWS CodePipeline. It depicts the two services connecting and automatically deploying CloudFormation templates.

Comparison table

MethodBest forKey commands / examples
Manual ConsoleVisual editing, one-off stacks, demosUpload template in AWS CloudFormation Console
Infrastructure ComposerVisual authoring and iterative editingExport to template → deploy via Console/CLI
CLI (scriptable)Repeatable automation, local CI scriptsaws cloudformation deploy / create-stack / update-stack
CI/CD (CodePipeline)Fully automated delivery from version controlIntegrate CloudFormation action into pipeline stages

Best practices

  • Keep templates in version control (Git); treat templates as code.
  • Parameterize environment-specific values and avoid hard-coding credentials.
  • Use change sets or aws cloudformation deploy to preview changes for production stacks.
  • Manage IAM privileges carefully: least-privilege for the principal that runs deployments.
  • Use nested stacks or modular templates for large deployments to improve maintainability.
Summary
  • Manual: Use the CloudFormation console or Infrastructure Composer for visual editing and ad-hoc stack creation.
  • CLI: Use aws cloudformation deploy, create-stack, or update-stack for scripted, repeatable deployments.
  • CI/CD: Use CodePipeline (or other CI systems) to automatically deploy CloudFormation templates from version control for continuous delivery.
These routes cover deployments from exploratory manual edits to fully automated CI/CD workflows—pick the pattern that fits your development lifecycle and governance needs.

Watch Video