What you will learn in this TP
- Describe a resource in HCL
- Apply with plan then apply
- Detect drift
Terraform + LocalStack #
What you will learn in this section
- Describe a resource in HCL
- Apply with plan then apply
- Detect drift
Context. Infrastructure created by hand cannot be reproduced or audited. Infrastructure as Code describes resources in versioned files: you practise it with Terraform and see what configuration drift is.
Prerequisites: Previous lab (LocalStack), Terraform installed · Estimated time: 40 min
A versioned bucket described in HCL.1. Configure the provider
Why? The provider tells Terraform which API to target; pointing it at LocalStack, the same code would work on real AWS by removing the overrides.
Point the AWS provider to LocalStack.2. Describe the resource
Why? Describing versioning and tags in code guarantees they are identical everywhere and auditable in Git.
Create a bucket with versioning and anenv=labtag.3. Plan and apply
Why? plan shows what will change before doing it: it is the safeguard that prevents accidental destruction.
Run the full cycle and inspect the state.4. Drift and destruction
Why? Changing by hand then re-running plan makes drift clear: real state diverges from code, and Terraform offers to fix it.
Change the resource by hand, detect the drift, then destroy the infrastructure.
Difficulty level : ●●○○○ (2/5)
My progress
Sign in to track your progress and take notes. Sign in
💬 Questions about this lesson
No questions yet: be the first to ask for help or share your configuration.
Recommended Articles
Cloud best practices: security, resilience, costs and operations
Cloud computing best practices: pillars of a well-architected design, IAM and least privilege, mu...
Cloud deployment models: public, private, hybrid, community and multi-cloud
Understand cloud computing deployment models according to NIST: public, private, community and hy...
Infrastructure as Code on Azure: Bicep, Terraform, Cost Management and Well-Architected
Describe and deploy Azure as code with Bicep (modules, parameters, what-if, pipeline deployments)...
Infrastructure as Code on AWS: CloudFormation, CDK, Terraform and Well-Architected
Describe and deploy your AWS infrastructure as code with CloudFormation, the CDK or Terraform, au...
Operating Google Cloud: observability, security, infrastructure as code and costs
Operate Google Cloud: Cloud Monitoring, Cloud Logging and Cloud Trace (Google Cloud Observability...
Terraform in CI/CD: pipelines, plan review, OIDC and GitOps
Automate Terraform: plan pipeline on merge requests and apply after approval, posting the plan as...
Terraform: principles, architecture and workflow
Understand Terraform: declarative infrastructure as code, architecture (core, providers, state), ...
Terraform across multiple clouds: AWS, Azure, Google Cloud, OVHcloud and Kubernetes
Use Terraform with the main providers: aws, azurerm, google, ovh and openstack, kubernetes and he...
Infrastructure as Code and GitOps: Terraform, Ansible and Argo CD
Manage infrastructure as code: declarative or imperative, Terraform (providers, state, plan, modu...