Skull
Skull

Reputation: 1252

Change the name of 'terraform.tfstate.d' in terraform

I am trying to create env specific deployment using workspace in terraform. It is working as expected like creating env specific states. It looks like

terraform.tfstate.d
   |
   ---- DEV
          |
          -----terraform.tfstate
   |
   ---- STAG
          |
          -----terraform.tfstate

How to change the name of terraform.tfstate.d to env

Upvotes: 2

Views: 1207

Answers (1)

AmanGarg-MSFT
AmanGarg-MSFT

Reputation: 1153

@skull it is possible to provide a different name by using "local" backend:

terraform {
  backend "local" {
    path = "relative/path/to/terraform.tfstate"
  }
}

https://www.terraform.io/docs/backends/types/local.html

For reference:

https://shinglyu.com/web/2019/04/06/switching-between-multiple-local-backend-in-terraform.html

https://www.terraform.io/docs/backends/index.html

https://medium.com/@jessgreb01/how-to-terraform-locking-state-in-s3-2dc9a5665cb6

Upvotes: 4

Related Questions