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 v0.8.7
aws_vpc but I think it's core issue.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"
#}
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
No panic
terraform.tfstate should be updated and mybackup.tfstate should be generated as a backup file.
mybackup.tfstate was generated as a new state file and mybackup.tfstate.1487735095.backup was generated as a backup file
terraform applyterraform state mv -backup=mybackup.tfstate aws_vpc.example module.vpc.aws_vpc.exampleNothing
Nothing
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.