AWS CloudFormation infrastructure as code in practice
Implementing AWS CloudFormation for Infrastructure as Code replaces click-driven AWS changes with versioned templates, repeatable stack operations, and an audit trail. A template can describe networking, compute, storage, identity, and monitoring resources, then create or update them as a managed stack. The result is faster delivery and a clearer operational history, provided the team treats templates as production code rather than disposable scripts.
CloudFormation does not remove architectural decisions. It makes their effects explicit, repeatable, and reviewable. Parameterisation, conditions, policies, and change sets help control variation, while Git, CI/CD, and CloudTrail provide the surrounding controls. Used well, the service gives systems administrators a dependable path from an empty account to a standardised environment.
For Australian teams, region selection has practical consequences. Workloads often land in ap-southeast-2 for Sydney or ap-southeast-1 for Melbourne, but latency, disaster recovery, and failover still require testing from Perth, Adelaide, and Brisbane. Australian English such as “organisation” and “authorised” is straightforward, while handover notes may include informal phrases like “arvo”. Internal platform teams and managed service providers frequently share ownership across the ANZ market, with OAIC obligations and the ASD Essential Eight influencing governance.
From console changes to declarative stacks
CloudFormation operates on two core objects: templates and stacks. The template is a YAML or JSON document containing resources, parameters, conditions, mappings, and outputs. The stack represents the deployed resources and their lifecycle. This separation allows the same design to create a development stack and a production stack with different values.
The principal benefit is consistency. A new environment can be built from an approved template instead of copied manually between accounts. Resource relationships remain visible, configuration is reviewable in Git, and CloudTrail records the API activity associated with stack operations.
It also creates useful guardrails. Deletion policies can preserve databases or storage buckets, termination protection can prevent accidental stack removal, and stack policies can restrict updates to sensitive resource types. These controls complement IAM permissions rather than replacing them.
Designing a maintainable template
Start with a small resource set and a clear naming convention. Group related resources logically, use comments to explain operational decisions, and avoid embedding credentials, account identifiers, or fixed regional endpoints. Parameter files or deployment pipelines can supply environment-specific values without duplicating the template.
Parameters should have sensible restrictions. A Stage parameter might allow only dev, test, or prod, while an instance size can be constrained to approved values. Conditions can then include or exclude individual resources. This is more reliable than allowing arbitrary strings and discovering an invalid combination during deployment.
Outputs provide controlled interfaces between stacks, but cross-stack exports introduce dependencies that can be difficult to change. Prefer purpose-built references such as SSM parameters for shared configuration where practical. Nested stacks help organise large estates, although they also complicate failure diagnosis and deployment permissions.
Parameters, security, and safe defaults
A stack should accept only the variation required by its intended environments. Use AWS::SSM::Parameter::Value types for non-secret configuration, tags for ownership and cost allocation, and AWS Secrets Manager dynamic references where secrets are genuinely required. Review outputs carefully because sensitive values can still become visible in stack outputs, exports, or pipeline logs.
IAM deserves particular attention. Deployment roles need iam:PassRole only for roles explicitly used by the stack, and pipeline roles should be able to create change sets without being able to bypass approval controls. Named IAM capabilities should be declared deliberately because they acknowledge that CloudFormation will create or update permissions on the operator’s behalf.
CloudFormation Guard provides another layer. Guard rules can validate resource types, properties, naming patterns, and environment restrictions before deployment. The rules should complement unit tests and policy-as-code checks in the pipeline, giving operators fast feedback without waiting for a failed stack operation.
Deploying stacks through controlled workflows
For interactive work, AWS CloudShell provides the CLI without installing local tooling. The aws cloudformation deploy command supports parameters, capabilities, and change-set behaviour. Production deployments should generally move beyond a workstation and run through CodePipeline, where the template is packaged, reviewed, validated, and deployed to separate accounts.
A change set shows proposed operations before they run. Teams can inspect modifications, add approval actions, and decide whether the impact is acceptable. This is especially useful for networking, IAM, and databases, where a seemingly small template edit can trigger replacement or prolonged operations.
Failures should be handled through rollback triggers, CloudWatch alarms, and explicit remediation procedures. Automatic rollback restores changed resources where CloudFormation can do so, but it does not guarantee recovery for every external dependency. A related delivery concern is documented in CloudFront invalidation troubleshooting, which is useful when stack updates also trigger content delivery changes.
Detecting drift and diagnosing failures
CloudFormation drift detection compares selected resource properties with the template’s expected state. Scheduled checks can identify manual changes, but they do not observe every operational detail. AWS Config provides broader configuration monitoring and can integrate with remediation workflows for environments where manual modifications create material risk.
Troubleshooting starts with events. DescribeStackEvents usually identifies the failing resource and operation, while CloudTrail shows the underlying API calls. Engineers should check parameter values, dependency ordering, IAM permissions, quotas, and service-specific constraints rather than repeatedly cancelling and recreating the stack.
The AWS Config rule IAM_PASSWORD_POLICY can also report a stack failure involving IAM resources. Diagnosis still requires connecting that finding to the stack event, the effective IAM policy, and the deployment role. Scenario-based practice, such as ProblemBook scenarios, helps administrators rehearse this evidence-driven approach.
Operating CloudFormation across Australian teams
Templates should be owned with the same discipline as application code. Repository access, branch protection, required reviews, and automated validation provide a defensible change history. StackSets extend consistent baselines across multiple accounts and regions, while service-specific stacks handle workloads that need independent lifecycles.
A capability comparison helps clarify the operational boundaries.
| Capability | AWS CloudFormation | Terraform | AWS console |
|---|---|---|---|
| Primary model | Native declarative stacks | Declarative configuration with remote state | Direct resource management |
| Change review | Change sets and approval pipelines | Plan output and versioned code | Manual review or screenshots |
| Drift detection | Native checks, supplemented by AWS Config | Refreshed plans and external tooling | Visual inventory checks |
| AWS governance | Stack policies, Guard, and IAM | Provider policies and external controls | IAM and service permissions |
| Multi-account use | StackSets and cross-account roles | Backend workspaces and remote state | Repeated manual setup |
Hybrid estates benefit from clear boundaries. Networking, connectivity, and shared services can occupy separate stacks, reducing the blast radius of application changes. Australian operations teams should also record UTC timestamps alongside AEDT and AEST local times, making regional schedules, failover windows, and incident handovers easier to audit.