Instiq
Chapter 4 · Deployment·v2.1.0·Updated 6/28/2026·~8 min

What's changed: In-scope service coverage (axis B): added CodeArtifact/CloudShell (s1) and Amplify (s3) definitions, roles, and selection criteria.

4.2IaC: CloudFormation and SAM

Key points

Understand declarative infrastructure with CloudFormation (stacks, templates), the serverless shorthand AWS SAM, and the benefits of repeatable deployments.

Rather than building infrastructure by hand, Infrastructure as Code (IaC) codifies it as templates. On AWS, CloudFormation is the core, and SAM helps for serverless.

4.2.1CloudFormation and SAM

Diagram contrasting CloudFormation (declarative YAML/JSON templates deploying a stack of resources; repeatable, version-controlled) with AWS SAM (shorthand for Lambda/API Gateway/DynamoDB that transforms into CloudFormation).
CloudFormation and SAM
  • CloudFormation: deploys a group of resources (stack) via declarative YAML/JSON templates.
  • AWS SAM: serverless shorthand for Lambda/API Gateway/DynamoDB; transforms into CloudFormation under the hood.
  • IaC enables repeatability, version control, and review, reducing environment drift.

A CloudFormation template has several sections: Parameters take inputs (e.g., environment name), Resources declare resources, Outputs expose stack outputs (e.g., endpoints), and Mappings/Conditions absorb environment differences. Before applying changes, a change set shows "what will be created/updated/deleted," preventing accidents. When manual changes make the live state diverge from the template, that’s drift, found via drift detection. SAM expresses serverless with short syntax like AWS::Serverless::Function and expands into ordinary CloudFormation at deploy time. With the SAM CLI you can run locally via sam local and ship via sam deploy, which uploads artifacts to S3 then updates the stack. A related tool, CDK, generates templates from general-purpose programming languages.

Continue reading — free sign-up

You're reading the free preview. Sign up free to read this section in full, plus every chapter (including 4+) and all questions.