Terraform: `-backup` option for `terraform state mv` seems not to work correctly

Created on 22 Feb 2017  ยท  3Comments  ยท  Source: hashicorp/terraform

I'm not sure it's a spec or bug, but I think this behavior is different from document's specification.
https://www.terraform.io/docs/commands/state/mv.html#_backup_path

Terraform Version

Terraform v0.8.7

Affected Resource(s)

  • My example is aws_vpc but I think it's core issue.

Terraform Configuration Files

provider "aws" {
  region = "us-east-1"
  max_retries = 3
}

resource "aws_vpc" "example" {
  cidr_block = "10.1.0.0/16"
  tags { Name = "example" }
}
# I want to move the above resource to the module
# module "vpc" {
#  source = "./vpc"
#}

Debug Output

sishimura% TF_LOG=debug terraform state mv -backup=mybackup.tfstate aws_vpc.example module.vpc.aws_vpc.example                                                                                                                               [kamatama-test](master)
2017/02/22 12:44:55 [INFO] Terraform version: 0.8.7  c1df88ac4633b61b83802bbb10c343c20d3035b5
2017/02/22 12:44:55 [INFO] CLI args: []string{"/Users/shinichi/IdeaProjects/tfenv/versions/0.8.7/terraform", "state", "mv", "-backup=mybackup.tfstate", "aws_vpc.example", "module.vpc.aws_vpc.example"}
2017/02/22 12:44:55 [DEBUG] Detected home directory from env var: /Users/shinichi
2017/02/22 12:44:55 [DEBUG] Detected home directory from env var: /Users/shinichi
2017/02/22 12:44:55 [DEBUG] Attempting to open CLI config file: /Users/shinichi/.terraformrc
2017/02/22 12:44:55 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2017/02/22 12:44:55 [DEBUG] Detected home directory from env var: /Users/shinichi
2017/02/22 12:44:55 [DEBUG] plugin: waiting for all plugin processes to complete...
Moved aws_vpc.example to module.vpc.aws_vpc.example

Panic Output

No panic

Expected Behavior

terraform.tfstate should be updated and mybackup.tfstate should be generated as a backup file.

Actual Behavior

mybackup.tfstate was generated as a new state file and mybackup.tfstate.1487735095.backup was generated as a backup file

Steps to Reproduce

  1. terraform apply
  2. terraform state mv -backup=mybackup.tfstate aws_vpc.example module.vpc.aws_vpc.example

Important Factoids

Nothing

References

Nothing

bug core

All 3 comments

This isn't intended. Working on a fix now.

Fix is in a PR. Thank you for reporting this!

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cpoole picture cpoole  ยท  3Comments

rjinski picture rjinski  ยท  3Comments

rkulagowski picture rkulagowski  ยท  3Comments

ketzacoatl picture ketzacoatl  ยท  3Comments

larstobi picture larstobi  ยท  3Comments