AWS, Azure & GCP · Cloud across providers
Why use infrastructure as code?
Short answer
IaC defines infrastructure in versioned files so environments are reproducible, reviewable and auditable. Terraform, CloudFormation, Bicep and Pulumi differ in language and state handling but share the same goal.
With infrastructure as code, the desired state lives in a repository instead of a console. Changes go through review and a pipeline, and the tool computes a plan before applying it. That makes environments repeatable and gives you a history of who changed what.
Why it matters
- Reproducible environments from development through production
- Code review and automated policy checks before changes land
- Drift detection when someone edits resources manually
- Modules for reusable patterns such as networks and accounts
- A path to disaster recovery by rebuilding infrastructure from source
resource "aws_s3_bucket" "logs" {
bucket = "vh-logs-prod"
}
resource "aws_s3_bucket_versioning" "logs" {
bucket = aws_s3_bucket.logs.id
versioning_configuration {
status = "Enabled"
}
}State is the mapping between declared resources and real infrastructure. Store it remotely with locking, restrict access, and treat it as sensitive because it can contain secrets and resource details. Do not let two pipelines apply the same state concurrently.
Follow-ups you should expect
Interviewers use these to check whether the first answer was understanding or memorisation.
- 1Why does Terraform need remote state and locking?
- 2How do you handle drift from manual console changes?
- 3How do you structure modules for multiple environments?
- 4What secrets can leak through IaC state?
Say it in the interview
Infrastructure as code puts the desired state in version control so environments are reproducible, reviewable and auditable. I use plan and apply in a pipeline, store state remotely with locking, and detect drift when someone changes things manually. IaC does not replace design review or policy checks, because a valid plan can still create an insecure resource.
Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.
Related questions
Reading is step one
Now say it out loud.
Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live AWS, Azure & GCP mock interview and get scored feedback on depth, clarity and confidence.