Terraform remote state

Currently, I'm setting up the infrastructure for the project I'm working on at my current job, and I knew the existence of the terraform remote config command to configure remote state storage backends. But it took me by surprise when I tried to execute the command and Terraform didn't recognize it.

I'm using version 0.9.2 and it seems that starting from version 0.9.0, the Terraform team removed that option in favor of a file-based configuration.

That means that if you were previously running this command:

terraform remote config \
-backend=s3 \
-backend-config="bucket=my-tfstate-bucket" \
-backend-config="key=terraform.tfstate" \
-backend-config="region=us-west-1" \
-backend-config="encrypt=true"

... now you'll need to declare this backend in a .tf file with the following syntax:

terraform {
    backend "s3" {
        bucket = "my-tfstate-bucket"
        key = "terraform.tfstate"
        region = "us-west-1"
        encrypt = true
    }
}

With this new approach your team members won't need to configure the remote state on each machine, because the configuration now will reside in a .tf file.

Terraform also included support for state locking using DynamoDB, but I will explain that in another post.