0.8.5
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.
NA - I am only running the import command on a route53 DNA A record
https://gist.github.com/westredd/c0f5145de05f3a2abe250919803016d3
https://gist.github.com/westredd/51661fbcb85ed0755d801a7a80ce6172
DNS record should have appeared in state file after running the import command
Terraform Crash
Please list the steps required to reproduce the issue, for example:
The DNS zone was created for testing. It is not a registered domain .
NA
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)
provider "aws" {
region = "us-west-2"
}
resource "aws_route53_zone" "main" {
name = "westredd.com"
}
resource "aws_route53_record" "default" {
zone_id = "${aws_route53_zone.main.zone_id}"
name = "mike"
type = "A"
ttl = "30"
records = ["127.0.0.1"]
}
That gave me the correct configuration to start with. I then tried exactly what you did:
% 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
From looking at the code, I wish it were that simple to run an import :(
I was able to get it working as follows:
% terraform import aws_route53_record.import1 Z3M232P8A7JAIH_mike_A 1 ↵ ✭
aws_route53_record.import1: Importing from ID "Z3M232P8A7JAIH_mike_A"...
aws_route53_record.import1: Import complete!
Imported aws_route53_record (ID: Z3M232P8A7JAIH_mike_A)
aws_route53_record.import1: Refreshing state... (ID: Z3M232P8A7JAIH_mike_A)
Import success! The resources imported are shown above. These are
now in your Terraform state. Import does not currently generate
configuration, so you must do this next. If you do not create configuration
for the above resources, then the next `terraform plan` will mark
them for destruction.
I could then terraform show based on this to get your record:
% terraform show ✭
aws_route53_record.import1:
id = Z3M232P8A7JAIH_mike_A
fqdn = mike.westredd.com
health_check_id =
name = mike
records.# = 1
records.3619153832 = 127.0.0.1
set_identifier =
ttl = 30
type = A
weight = -1
zone_id = Z3M232P8A7JAIH
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:
Z3M232P8A7JAIH <----------- THIS IS THE ZONE_ID
mike <----------- THIS IS THE RECORD NAME
A <----------- THIS IS THE RECORD TYPE
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?
% 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
Would this help?
Paul
that's awesome help , thanks alot buddy
Yes the error you proposed would be super helpful to realise the problem
I will try this tomorrow.
@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.
Most helpful comment
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