Migrating production and staging state files to AWS S3 backend


We have a very good working setup that allows us to plan and apply to a production and a staging environment.

The local directory structure we are using is that the project root contains all the .tf files and we have sub-directories for production and staging that contain the .tfvars, .tfplan, .tfstate, and .tfstatebackup.

All except the .tfplan is committed to a repo.

We have a backend setup (S3 bucket and a DynamoDB table for the locks).

We want to migrate the current states to the backend.

And here we are stuck.

The terraform init --reconfigure command does not seem to allow us to nominate the location of the existing .tfstate file (production/terraform.tfstate or staging/terraform.tfstate).

Are there any good blogs around on dealing with multiple environments in the way I have described? Essentially the same resources, just different sizes/names based upon the .tfvars


Richard Quadling.