Terraform Cloud Ignores Backend

I am using the following configuration.:

terraform {
  required_version = "0.12.21"

  backend "gcs" {
    bucket      = "testing-5"
    prefix      = "infrastructure/github/testing"
    credentials = "./.tmp/credentials.json"

I was expecting to fail using Terraform Cloud since there is no file called ./tmp/credentials.json.

But it seems that Terraform Cloud ignores my backend configuration. The run went ahead just fine, but it used Terraform Cloud for saving the state instead of my backend configuration.

Is this intentional by design?

I am confused on how to make this to work with GCP backend for saving the state.

Hi @alchemist_ubi,

When you are using Terraform Cloud, the backend is always forced to be the remote backend with the hostname set to app.terraform.io, and the state is always stored in the Terraform Cloud state storage. That’s by design: the other backend types are there for folks who are using Terraform CLI outside of Terraform Cloud.

Normally when using Terraform Cloud we’d expect to see a backend "remote" block so that a local terraform plan or terraform apply (outside of Terraform Cloud) would also know to look in Terraform Cloud for the state, but for historical reasons Terraform Cloud doesn’t require such a block, and instead creates a backend configuration automatically itself. (In the current implementation, that is done via an override file generated prior to running Terraform.)

1 Like

Roger, thank you very much for the help.