🖊️
Notes
  • Notes
  • aws
    • CloudWatch
    • EKS
    • IAM
    • Key Management Service (KMS)
    • security
      • Attacks against AWS infrastructure
    • vpc
      • AWS Transit Gateway
  • azure
    • Azure AD
    • Azure CDN
    • DNS in Azure
    • Hub-spoke network topology
    • Identity and access management
    • Azure Landing zones
    • Storage
  • certifications
    • aws-sa-pro
    • Certified Kubernetes Administrator
  • containers
    • Examples
    • Linux Container Primitives
  • databases
    • Relational databases
  • gcp
    • IAM
  • git
    • Git
  • golang
    • Building Go projects
    • Concurrency
    • Project structure
  • infosec
    • SSH
    • SSL
  • Kubernetes
    • Admission Controllers
    • Autoscaling
    • Debugging
    • Multi-tenancy
    • Network Policies
    • Pod Priority
    • Pod Security Policies
    • Secrets
    • StatefulSet
    • additional-services
      • Debugging ArgoCD RBAC
      • open-policy-agent
  • misc
    • FFmpeg
    • PDFs
  • programming
    • Learning resources
    • concepts
      • Serialization
  • rabbitmq
    • Clustering and HA
    • Shovel plugin
  • shells
    • Bash
  • terraform
    • Moving resources between remote states
  • vim
    • Fzf (plugin)
    • Registers
    • Spell Check
  • linux
    • arch
      • Arch Linux installation
Powered by GitBook
On this page
  1. terraform

Moving resources between remote states

Sometimes it's useful to be able to move resources between remote states without a need to recreate infrastructure. One use case is moving resources between directories.

terraform state mv command does not directly support remote states, but -state and -state-out parameters can be used against local states. This means remote states need to fetched first.

This can be done with for example aws s3 cp or terraform state pull > local.tfstate.

After both states are local, state mv command can be used in the following manner:

terraform state mv -state=src.tfstate -state-out=dst.tfstate module.foo module.foo

After this modified local state files need to pushed to remote storage, for example with:

terraform state push /path/to/local/state

References:

  • https://github.com/hashicorp/terraform/pull/15652#issuecomment-410754814

PreviousterraformNextvim

Last updated 2 years ago