Terragrunt moving terraform.tfvars

This message is extracted from a ticket originally emailed to support@gruntwork.io. Names and URLs have been removed where appropriate.

I was wondering if there was a ‘best practice’ on how to move terraform.tfvars files once the state has been created remotely. Do I need to manually create the directories in s3 and then move the file myself or is there a more automatic way of doing it?

For example, let say I had the following:

us-west-2
    - api
        - terraform.tfvars

and I created the state files remotely, but now I want to change it to the following:

us-west-2
    - services
        - api
            - terraform.tfvars

Do I have to manually move the file in s3?

Your question combined moving terraform.tfvars​ files and the Terraform state files, so I’ll answer both.

Yes, I would recommend moving everything manually. First, you can copy the state files in S3 from the old location to the new location. This is manual, but a straightforward operation. As you suggest in your question, make sure the new S3 location exactly corresponds to your new planned terraform.tfvars​ location.

Next, you can just move the terraform.tfvars​ file to the new folder. As a sanity check, run terragrunt plan​ and make sure that Terraform does not propose to create, modify, or destroy any resources.

Finally, clean up any old Terraform state artifacts by deleting the old folder and old file in the old S3 location.