I'm trying to create reverse DNS entry (https://aws.amazon.com/premiumsupport/knowledge-center/route-53-reverse-dns/) but I'm failing..
name = "${join(".", ["${element(split(".", aws_instance.instance.private_ip), 3)}", "${var.dns-rev}"])}"
This fails with
Error reading config for aws_route53_record[resource]: parse error: syntax error
I know that the element() part works:
name = "${element(split(".", aws_instance.instance.private_ip), 3)}}"
This will correctly give me the last part of the IP address, but I'm guessing it's the join() that fails (and there especially where I try to give it a list by creating it in place).
Hi @FransUrbo!
As you expected, I think the [ ] syntax for creating a list literal is what's not working here. Terraform doesn't currently allow lists to be constructed like that.
Since you are joining together a known number of items here, you could potentially just use regular string interpolation syntax instead of that join:
name = "${element(split(".", aws_instance.instance.private_ip), 3)}.${var.dns-rev}"
Another option is to use the list() function to produce an inline list. It takes a variable number of string arguments and returns a string list of them all. This is currently the only way to produce a literal list, since we don't have a specific list literal syntax today.
Worked marvelously, thanx!
You don't happen to have an idea on how to do the same for ASG instances as well?
One way to solve this is documented in https://github.com/FransUrbo/Lambda-AWS-AutoScalingGroups-Route53.
However, it's not exactly what I want. It creates a round-robin entry, but I have the ELB for that. What I _would_ like is to have one entry per IP. But I'm starting to think that's impossible due to the restrictions of a Lambda function (must be stateless).
Hi @FransUrbo! It looks like your original question was resolved here, and as we're tidying up issues, I'm going to close this; you might be interested in the community forum for future questions!
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 @FransUrbo!
As you expected, I think the
[ ]syntax for creating a list literal is what's not working here. Terraform doesn't currently allow lists to be constructed like that.Since you are joining together a known number of items here, you could potentially just use regular string interpolation syntax instead of that
join:Another option is to use the
list()function to produce an inline list. It takes a variable number of string arguments and returns a string list of them all. This is currently the only way to produce a literal list, since we don't have a specific list literal syntax today.