I need to read some data from the state file, to be specific, I need to import a DNS record's IP address into my terraform configuration. I have a resource aws_route53_record.dns_record
that I imported from the state file.
This is the output definition:
output "dns_record_ip" {
value = aws_route53_record.dns_record.*.records[0]
}
And this is the actual output:
dns_record_ip = toset([
"10.10.10.100",
])
When I try to extract only the IP as a string like this:
terraform output -json dns_record_ip | jq -r '.[0]'
I indeed get a string:
10.10.10.100
Is there a way to achieve this by modifying the output definition so I don't have to use jq and command line since I need to use the output value in my terraform configuration? EDIT: Needed an output value so it can be used by another module.
How can I modify this:
output "dns_record_ip" {
value = aws_route53_record.dns_record.*.records[0]
}
so the value of dns_record_ip
is actually 10.10.10.100
?
ps: edited to avoid confusion