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

"Import completed!" message is wrong #20017

Closed
YakDriver opened this issue Jan 16, 2019 · 1 comment · Fixed by #20018
Closed

"Import completed!" message is wrong #20017

YakDriver opened this issue Jan 16, 2019 · 1 comment · Fixed by #20018
Labels

Comments

@YakDriver
Copy link
Member

YakDriver commented Jan 16, 2019

Terraform Version

$ terraform -v
Terraform v0.11.11

Terraform Configuration Files

resource "aws_route" "test" {
  route_table_id = "${aws_route_table.test.id}"
  destination_cidr_block = "10.1.0.0/16"
  gateway_id = "${aws_internet_gateway.test.id}"
}

Expected Behavior

During import, Terraform should report "Import prepared" (or something similar) after the resource importer State() function is complete.

To be extra clear, after both the State() and Read() functions complete successfully, a message announcing "Import complete!" could be given.

Actual Behavior

During import, Terraform wrongly reports "Import complete!" when it is not usually complete.

Terraform reports "Import complete!" after the resource importer State() function is complete. However, State() is often used to just set enough information so that Read() works, which is called immediately after. Usually during State(), information provided in the import command is put in the right places in the state, without ever checking anything on AWS (or presumably, other provider). That does not constitute the normal meaning of "import complete." As a result, it's easy to get the confusing and wrong "Import complete!" message below followed by a "non-existent resource" message.

aws_route.test: Importing from ID "rtb-0b8835dc7eb1e3168_12.22.48.96/0"...
aws_route.test: Import complete!
  Imported aws_route (ID: r-rtb-0b8835dc7eb1e3168715786107)
aws_route.test: Refreshing state... (ID: r-rtb-0b8835dc7eb1e3168715786107)

Error: aws_route.test (import id: rtb-0b8835dc7eb1e3168_12.22.48.96/0): 1 error(s) occurred:

* import aws_route.test result: r-rtb-0b8835dc7eb1e3168715786107: import aws_route.test (id: r-rtb-0b8835dc7eb1e3168715786107): Terraform detected a resource with this ID doesn't
exist. Please verify the ID is correct. You cannot import non-existent
resources using Terraform import.

Steps to Reproduce

  1. terraform init
  2. terraform apply
  3. terraform state rm aws_route.test
  4. Delete the route using the AWS console
  5. terraform import -input=false aws_route.test rtb-0b8835dc7eb1e3168_12.22.48.96/0

Additional Context

References

@ghost
Copy link

ghost commented Aug 13, 2019

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 Aug 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants