admin管理员组文章数量:1122826
I have a terraform state file in local which we want to migrate it to GCP cloud as a remote backend. I have created the bucket named "dns-zone" and added the existing tfstate file named terraform.tfstate into the bucket folder named "dns-folder".
The backend code looks like this:
terraform {
backend "gcs" {
bucket = "dns-zone"
prefix = "dns-folder"
}
}
after that I ran the command "terraform init -migrate-state".
now its creating the new tfstate file as "default.tfstate"
in the bucket location instead of using the previuos state file (terraform.tfstate).
And when i try to run terraform plan it shows whole infra to create which is already exists.
Please help me to resolve this issue.
I have a terraform state file in local which we want to migrate it to GCP cloud as a remote backend. I have created the bucket named "dns-zone" and added the existing tfstate file named terraform.tfstate into the bucket folder named "dns-folder".
The backend code looks like this:
terraform {
backend "gcs" {
bucket = "dns-zone"
prefix = "dns-folder"
}
}
after that I ran the command "terraform init -migrate-state".
now its creating the new tfstate file as "default.tfstate"
in the bucket location instead of using the previuos state file (terraform.tfstate).
And when i try to run terraform plan it shows whole infra to create which is already exists.
Please help me to resolve this issue.
Share Improve this question asked Nov 22, 2024 at 11:56 MaheshMahesh 111 bronze badge 1 |1 Answer
Reset to default 0When working with the state, I always use and recommend using the terraform state ...
commands to ensure terraform does everything necessary to keep track of it. In your case, you would use terraform state push <path/to/your/terraform.tfstate>
to get your local state into your remote backend. https://developer.hashicorp.com/terraform/cli/commands/state/push
本文标签: Terraform state file migration from local to GCP cloudStack Overflow
版权声明:本文标题:Terraform state file migration from local to GCP cloud - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736303894a1932042.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
Named states for workspaces are stored in an object called <prefix>/<name>.tfstate
. When you dont specify a workspace then terraform uses the workspace calleddefault
. You can see this when you runterraform workspace list
– Chris Doyle Commented Nov 22, 2024 at 16:51