I have a project that provisions the infrastructure in AWS using terraform. We have different environments dev, stg, prod and the way we deploy to each of these environments is through environment specific .tfvars . This is our structure
infra-project
|_____Module1
| Main.tf
Variables.tf
output.tf
Environments
|
| _____ dev
|_____ terraform.tfvars
|
| _____ stg
|_____ terraform.tfvars
|
| _____ prod
|_____ terraform.tfvars
Sample content of the terraform.tfvars
file in dev
region = "us-west-2"
ami_id = "ami-0234er2455665"
subnet_id = "subnet-345rf789d"
instanceType = "t2.micro"
pvtIP= "10.12.0.0/16"
The environments are going to grow and it is not desirable to create environment specific terraform.tfvars
everytime. Is there a way to automate generating the tfvars for each environment so that it can be deployed to n environments without altering the project structure everytime?