Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

State mv command is overly aggressive on name matching. #7797

Closed
clstokes opened this issue Jul 25, 2016 · 2 comments · Fixed by #8304
Closed

State mv command is overly aggressive on name matching. #7797

clstokes opened this issue Jul 25, 2016 · 2 comments · Fixed by #8304
Assignees

Comments

@clstokes
Copy link
Contributor

Terraform is overly aggressive on name matching when doing state mv commands resulting in resources being lost in my state. If I have aws_vpc.main[0] and aws_vpc.main[1] in my state, and state mv aws_vpc.main without the brackets my first vpc is moved and the rest are removed from my state.

Terraform Version

$ ~/Downloads/terraform-0.7-rc3/terraform version
Terraform v0.7.0-rc3 (3f4857a07a24f3c9e2db6b4458fbf5be19a8b256)

Affected Resource(s)

All resources I believe.

Terraform Configuration Files

resource "aws_vpc" "main" {
  cidr_block = "10.0.0.0/16"
  tags {
    Name = "import-${count.index}"
  }
  count = 2
}

https://gist.github.com/clstokes/d1b7cc64a310dd7d2e29d7176e613bf3#file-main-tf

Debug Output

https://gist.github.com/clstokes/d1b7cc64a310dd7d2e29d7176e613bf3#file-log-log

Expected Behavior

Terraform show have exited with an error that the resource was not found or that more than one resource was found.

Actual Behavior

Terraform moved the first resource it found and removed the others.

Steps to Reproduce

  1. terraform apply
  2. terraform state list <- See 2 VPCs
  3. terraform state mv aws_vpc.main aws_vpc.renamed <- See only 1 VPC remains
@mitchellh
Copy link
Contributor

Fix for this is in the referenced PR now!

@ghost
Copy link

ghost commented Apr 23, 2020

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.

@ghost ghost locked and limited conversation to collaborators Apr 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants