Interview Prep/Terraform/Modules and Code Structure

Where do you put provider-agnostic helper logic, such as naming and tagging conventions, shared by all stacks?

IntermediateScenarioModules and Code Structure
Answer

Situation read → Naming logic is copy-pasted in every stack.

What I'd do → Create a tiny "context" or "naming" module with no resources, just locals and outputs.

module "ctx" {
  source      = "git::https://github.com/acme/tf-modules.git//context?ref=v1.2.0"
  project     = "payments"
  environment = var.environment
}
resource "aws_s3_bucket" "x" {
  bucket = "${module.ctx.prefix}-reports"
  tags   = module.ctx.tags
}

Why → One definition of "how we name things" means a convention change is a single release.

Interview tip → Keep it dumb and stable; it's imported everywhere.

All Terraform questions Roadmap: Terraform

More on Modules and Code Structure