Certablo
← Knowledge Base

AWS CloudFormation & Infrastructure as Code

Declarative AWS infrastructure through templates and stacks, with parameters, change sets, update behavior, drift detection and StackSets for repeated multi-account deployment.

CLF-C02SAA-C03SOA-C03

Visual overview

OPERATING LOOPDefine, deploy, observe, govern, and improve the environment continuously
01DefineInfrastructure + policy
02OperateFleet + workload actions
03ObserveMetrics · logs · events
04GovernAccounts · config · evidence
Management services answer different operational questions: what changed, how the workload behaves, whether configuration is compliant, and how repeatably infrastructure is managed.
AWS SERVICE MAPGoverned infrastructure lifecycle

CloudFormation declares and deploys infrastructure, Config observes resulting state, and Organizations supplies multi-account scope for standardized deployment.

CloudFormationDeclarative infrastructure deployment
AWS ConfigConfiguration-state evidence
OrganizationsMulti-account StackSet scope
EXAM-RELEVANT MECHANICS

Technical reference

CloudFormation governance hinges on the relationship between declared template state, deployed stack state and actual resource state.

Core unitTemplate → stack → resources

The template declares resources and properties; a stack is the managed deployment and lifecycle boundary for that declaration.

Template inputsParameters · mappings · conditions

Parameters accept deployment input, mappings provide keyed lookup values, and conditions control supported conditional creation/properties.

Change setProposed stack changes before execution

A change set can reveal adds, modifications and removals/replacements before CloudFormation changes the running stack.

Update behaviorIn-place · interruption · replacement

The exact behavior is property-specific in each resource type reference; replacement risk should be reviewed before execution.

DriftExpected state vs actual state

Drift detection reports supported resources whose current properties no longer match the values expected from the stack definition.

StackSetsStack instances across accounts/Regions

A StackSet manages repeated deployments and supports self-managed or Organizations-integrated service-managed permissions.

CloudFormation makes desired infrastructure declarative and repeatable

AWS CloudFormation models AWS infrastructure in templates and provisions the described resources as stacks. Instead of manually creating related resources and trying to reproduce their settings later, a template becomes a versionable declaration of the desired environment. CloudFormation resolves dependencies between resources where it can infer them, and explicit dependencies can be expressed when creation or update order matters beyond reference relationships.

Templates can include parameters for deployment-time input, conditions for conditional resource creation or properties, mappings for lookup tables, outputs for useful values, and the resources that CloudFormation manages. Parameters make a template reusable, but they should not become an excuse to hide every architectural decision behind an unstructured set of inputs. A good template captures a coherent unit of infrastructure with predictable interfaces.

Change sets preview updates; drift detection finds out-of-band changes

A change set previews the changes CloudFormation intends to make when a stack is created or updated. This is especially important because modifying a resource property can result in no interruption, some interruption or resource replacement depending on that resource type and property. Reviewing the proposed changes gives an operator a chance to catch an unexpected replacement before executing the change set, but the preview is not a guarantee that execution will succeed under all runtime conditions.

Drift occurs when resources are changed outside CloudFormation so their actual configuration no longer matches the stack's expected configuration. Drift detection compares supported resource properties against the template-derived expected state and reports differences such as modifications or deletions. Detecting drift is therefore a governance check; resolving it requires choosing whether the actual change should be reverted or incorporated into the declared infrastructure.

  • Review replacements carefully: a template change can recreate a resource rather than edit it in place.
  • Change sets forecast intended stack operations; drift detection compares actual resource state with the stack's expected state.
  • Out-of-band console changes weaken the value of IaC unless they are reconciled back into the managed definition.

StackSets extend a template across accounts and Regions

CloudFormation StackSets let an administrator use one template as the basis for stacks in multiple target accounts and Regions. This is a key governance primitive for repeatable infrastructure such as baseline roles, logging resources or configuration components that should exist throughout an organization. A StackSet owns stack instances in each target account/Region combination and can update those instances as the shared definition evolves.

StackSets support self-managed and service-managed permission models. With service-managed permissions and AWS Organizations integration, StackSets can target OUs and can automatically deploy to new accounts added to those targets when automatic deployment is configured. That makes StackSets complementary to Organizations policy: an SCP constrains maximum permissions, while a StackSet can actually provision standardized resources into the governed accounts.

Key takeaways

  1. 01

    CloudFormation templates declare desired AWS resources; stacks are managed deployments of those templates.

  2. 02

    Parameters, conditions, mappings and outputs make templates reusable and composable around the resources they define.

  3. 03

    Change sets preview intended changes before execution and help expose resource replacement risk.

  4. 04

    Drift detection identifies supported resources whose actual configuration differs from the stack's expected configuration.

  5. 05

    StackSets apply a common CloudFormation definition across accounts and Regions.

Official AWS sources

Use these primary AWS resources for the source material behind this article and for deeper reference.