-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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 of Route 53 A record crashing TF #11549
Comments
Hi @westredd thanks for getting in touch here. Sorry this is an issue for you. I have just spent some time on this crash. Unfortunately, it's not a nice user experience I'm afraid. I ran the config as follows (please excuse using the domain in your crash report)
That gave me the correct configuration to start with. I then tried exactly what you did:
From looking at the code, I wish it were that simple to run an import :( I was able to get it working as follows:
I could then terraform show based on this to get your record:
So the documentation isn't very clear in this area - we need to make this much much better! The format of what I imported was as follows:
We need all of these 3 things to be able to import a record. Each need to be delimited by _ - as I said, this isn't a great user experience. Now, for the crash itself. This should never happen! We should have been able to parse that string that you sent us and threw the appropriate error to you suggesting what you need to do I am going to suggest that I throw an error in this area if the import isn't correct. How about something like this?
Would this help? Paul |
Fixes: #11549 When a user passes the wrong argument to a route53_record import, they got a crash. This was because we expected the ID to parse correctly. The crash looked like this: ``` % terraform import aws_route53_record.import1 mike.westredd.com aws_route53_record.import1: Importing from ID "mike.westredd.com"... aws_route53_record.import1: Import complete! Imported aws_route53_record (ID: mike.westredd.com) aws_route53_record.import1: Refreshing state... (ID: mike.westredd.com) Error importing: 1 error(s) occurred: * aws_route53_record.import1: unexpected EOF panic: runtime error: index out of range ``` Rather than throwing a panic to the user, we should present them with a more useful message that tells them what the error is: ``` % terraform import aws_route53_record.import mike.westredd.com aws_route53_record.import: Importing from ID "mike.westredd.com"... aws_route53_record.import: Import complete! Imported aws_route53_record (ID: mike.westredd.com) aws_route53_record.import: Refreshing state... (ID: mike.westredd.com) Error importing: 1 error(s) occurred: * aws_route53_record.import: Error Importing aws_route_53 record. Please make sure the record ID is in the form ZONEID_RECORDNAME_TYPE (i.e. Z4KAPRWWNC7JR_dev_A ``` At least they can work out what the problem is in this case
Fixes: #11549 When a user passes the wrong argument to a route53_record import, they got a crash. This was because we expected the ID to parse correctly. The crash looked like this: ``` % terraform import aws_route53_record.import1 mike.westredd.com aws_route53_record.import1: Importing from ID "mike.westredd.com"... aws_route53_record.import1: Import complete! Imported aws_route53_record (ID: mike.westredd.com) aws_route53_record.import1: Refreshing state... (ID: mike.westredd.com) Error importing: 1 error(s) occurred: * aws_route53_record.import1: unexpected EOF panic: runtime error: index out of range ``` Rather than throwing a panic to the user, we should present them with a more useful message that tells them what the error is: ``` % terraform import aws_route53_record.import mike.westredd.com aws_route53_record.import: Importing from ID "mike.westredd.com"... aws_route53_record.import: Import complete! Imported aws_route53_record (ID: mike.westredd.com) aws_route53_record.import: Refreshing state... (ID: mike.westredd.com) Error importing: 1 error(s) occurred: * aws_route53_record.import: Error Importing aws_route_53 record. Please make sure the record ID is in the form ZONEID_RECORDNAME_TYPE (i.e. Z4KAPRWWNC7JR_dev_A ``` At least they can work out what the problem is in this case
Fixes: #11549 When a user passes the wrong argument to a route53_record import, they got a crash. This was because we expected the ID to parse correctly. The crash looked like this: ``` % terraform import aws_route53_record.import1 mike.westredd.com aws_route53_record.import1: Importing from ID "mike.westredd.com"... aws_route53_record.import1: Import complete! Imported aws_route53_record (ID: mike.westredd.com) aws_route53_record.import1: Refreshing state... (ID: mike.westredd.com) Error importing: 1 error(s) occurred: * aws_route53_record.import1: unexpected EOF panic: runtime error: index out of range ``` Rather than throwing a panic to the user, we should present them with a more useful message that tells them what the error is: ``` % terraform import aws_route53_record.import mike.westredd.com aws_route53_record.import: Importing from ID "mike.westredd.com"... aws_route53_record.import: Import complete! Imported aws_route53_record (ID: mike.westredd.com) aws_route53_record.import: Refreshing state... (ID: mike.westredd.com) Error importing: 1 error(s) occurred: * aws_route53_record.import: Error Importing aws_route_53 record. Please make sure the record ID is in the form ZONEID_RECORDNAME_TYPE (i.e. Z4KAPRWWNC7JR_dev_A ``` At least they can work out what the problem is in this case
that's awesome help , thanks alot buddy |
…1603) Fixes: hashicorp#11549 When a user passes the wrong argument to a route53_record import, they got a crash. This was because we expected the ID to parse correctly. The crash looked like this: ``` % terraform import aws_route53_record.import1 mike.westredd.com aws_route53_record.import1: Importing from ID "mike.westredd.com"... aws_route53_record.import1: Import complete! Imported aws_route53_record (ID: mike.westredd.com) aws_route53_record.import1: Refreshing state... (ID: mike.westredd.com) Error importing: 1 error(s) occurred: * aws_route53_record.import1: unexpected EOF panic: runtime error: index out of range ``` Rather than throwing a panic to the user, we should present them with a more useful message that tells them what the error is: ``` % terraform import aws_route53_record.import mike.westredd.com aws_route53_record.import: Importing from ID "mike.westredd.com"... aws_route53_record.import: Import complete! Imported aws_route53_record (ID: mike.westredd.com) aws_route53_record.import: Refreshing state... (ID: mike.westredd.com) Error importing: 1 error(s) occurred: * aws_route53_record.import: Error Importing aws_route_53 record. Please make sure the record ID is in the form ZONEID_RECORDNAME_TYPE (i.e. Z4KAPRWWNC7JR_dev_A ``` At least they can work out what the problem is in this case
@stack72 Any chance we could get the explanation of the record ID format in the documentation for aws_route53_record ? I don't understand the import example that is currently given in the doc because there is a 4th field at the end which is not covered in your explanation above: Z4KAPRWWNC7JR_dev.example.com_NS_dev I see that this is an NS record but what does dev signify? |
dev - it is "set id" |
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. |
Terraform Version
0.8.5
Affected Resource(s)
Please list the resources as a list, for example:
If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.
Terraform Configuration Files
NA - I am only running the import command on a route53 DNA A record
Debug Output
https://gist.github.com/westredd/c0f5145de05f3a2abe250919803016d3
Panic Output
https://gist.github.com/westredd/51661fbcb85ed0755d801a7a80ce6172
Expected Behavior
DNS record should have appeared in state file after running the import command
Actual Behavior
Terraform Crash
Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
Important Factoids
The DNS zone was created for testing. It is not a registered domain .
References
NA
The text was updated successfully, but these errors were encountered: