CloudFormation Tutorials
Template Workflow
- Define the infrastructure in YAML or JSON.
- Validate the template.
- Create or update the stack.
- 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.