Skip to content

Delete key from Terraform Cloud state

Sometimes it can be necessary to change a key in the Terraform Cloud state without changing the Terraform files.

  1. Change the backend.tf definition to:
terraform {
backend "remote" {
organization = "org"
hostname = "app.terraform.io"
workspaces {
name = "workspace"
}
}
}
  1. Ensure your ~/.terraformrc is available
credentials "app.terraform.io" {
token = "token from https://app.terraform.io/app/settings/tokens"
}
  1. Test if the connection works
terraform state list
  1. Remove the actual key
terraform state rm 'module.something.something_config_map.auth[0]'
  1. When done, remove the ~/.terraformrc file and undo the backend.tf changes to avoid accidents

#published

Links to this note

These notes are unpolished collections of thoughts, unfinished ideas, and things I want to remember later. In the spirit of learning in public, I'm sharing them here. Have fun exploring, if you want!
© 2020 by Adrian Philipp