Skip to content

CloudFormation Tutorials

Template Workflow

  1. Define the infrastructure in YAML or JSON.
  2. Validate the template.
  3. Create or update the stack.
  4. Review stack events and outputs.

Example commands:

aws cloudformation validate-template --template-body file://template.yml
aws cloudformation create-stack --stack-name demo --template-body file://template.yml
aws cloudformation update-stack --stack-name demo --template-body file://template.yml

A Simple Template Shape

AWSTemplateFormatVersion: '2010-09-09'
Description: Basic web stack
Parameters:
  InstanceType:
    Type: String
    Default: t3.micro
Resources:
  WebServer:
    Type: AWS::EC2::Instance
    Properties:
      InstanceType: !Ref InstanceType
      ImageId: ami-12345678
Outputs:
  InstanceId:
    Value: !Ref WebServer

Practical Guidance

  • Start with one stack per lifecycle boundary.
  • Use parameters for environment-specific settings.
  • Prefer outputs over hard-coded cross-stack assumptions.

References