How did you handle multiple AWS accounts in Terraform?
AdvancedBehavioralInfrastructure as Code & Terraform state
Answer
Good answer looks like → "Each environment had its own AWS account. CI assumed a deploy role in the target account using OIDC into a central account, then assume_role in the provider block. Shared resources like Route 53 zones lived in a networking account, managed via a provider alias."
provider "aws" {
alias = "network"
region = "ap-south-1"
assume_role {
role_arn = "arn:aws:iam::111122223333:role/terraform-deploy"
}
}
Follow-ups to expect → How did you bootstrap the roles themselves? How did you create new accounts?
Red flags → One set of admin credentials used for every account.
More on Infrastructure as Code & Terraform state
What did your Terraform state setup look like?IntermediateHow did you structure your Terraform code?BeginnerWhy did you use folders per environment rather than Terraform workspaces (or vice versa)?IntermediateHow did different Terraform stacks share information?IntermediateDid you ever have a state lock or corrupted state? What did you do?AdvancedHow did you handle Terraform drift?Intermediate