Closed ghost closed 7 years ago
You can't create a CNAME record without an A record. If you want to create a CNAME for the instance add a CNAME tag to the instance. The function will use the value you assign to CNAME to create a CNAME record in Route 53.
You misunderstand my goal. I have instances in peered VPC's. Amazon's DNS cannot resolve CNAMES when they are pointing to instances that are in a peered VPC. Therefore, I don't want the script to work the way it was originally intended.
Let's say a bring up a new server which has a CNAME tag of server1.domain.com. Originally the created an A record like this: ip-10-10-0-10 A 10.10.0.10, then creates a CNAME that would point to that A record. What I want is just an A record like this: server1.domain.com A 10.10.0.10. No CNAME record needed.
I tried getting help on how to modify the code here: https://github.com/awslabs/aws-lambda-ddns-function/issues/8. But was only told that it would be possible.
The way I have it does work, but only for the Private IP address. In those occasions where my instance is in a public subnet, it does not work.
I believe you can use the ZONE tag to create an A and CNAME record in a different hosted zone. This function, as written, does not allow you to configure the server's hostname. It will always use the hostname assigned to it by the VPC, ip-xxx.xxx.xxx.xxx or ec2-xxx.xxx.xxx.xxx. The way to workaround this is to create a CNAME for the server.
There is a loop in the function that loops through the tags assigned to the instance. It start with for tag in tags
. You can use that looping construct to find a particular tag and it's corresponding value and pass that to the method that creates the resource record.
That is exactly what I am trying to do! I modified the code that would normally create the CNAME and asked it to create an A record instead. AND IT DOES CREATE an A record like this: server1.panosoft.com A 10.10.0.10.
HOWEVER,
It throws a php error local variable 'public_ip' referenced before assignment
AND
If the instance is in a PUBLIC subnet, it does not work.
On Mon, Jan 23, 2017 at 7:55 PM, Jeremy Cowan notifications@github.com wrote:
There is a loop in the function that loops through the tags assigned to the instance. It start with for tag in tags. You can use that looping construct to find a particular tag and it's corresponding value and pass that to the method that creates the resource record.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/awslabs/aws-lambda-ddns-function/issues/9#issuecomment-274699022, or mute the thread https://github.com/notifications/unsubscribe-auth/ARA0TIjz6CT6lu-4F1WoWcBRLWrZwEUvks5rVXZCgaJpZM4Lrrto .
-- Laurie Kepford Cloud DevOps Engineer Panoramic Software 760-712-2266
You need to update the code that creates the resource record, e.g. create_resource_record(private_hosted_zone_id, private_host_name, private_hosted_zone_name, 'A', private_ip)
. Replace private_ip
with the variable you use for the hostname. If you're planning to do this, you can remove the logic to create CNAMEs. You can probably delete the reverse lookup zone logic too. I created that for EMR because earlier versions of EMR required reverse lookups.
Very nice script.
Is it possible to pass in the "value" of "ZONE" tag as the hostname?
Thanks for the feedback. I didn't design the function to use the ZONE tag to assign the hostname. You could modify the function to use a tag to assign the hostname, however, you should probably use the hostname assigned to the instance by the OS and use that to update Route 53.
@jicowan , this is a wonderful script! But, when I try to create a CNAME record like abc.host.internal.example (in private hosted zone Route 53), the script doesn't create a CNAME record. Instead the script runs just perfect when the hostname is of 3 levels like host.internal.example
Any suggestions where to make changes and what changes are to made Thanks!
hi @sasidharkanumuri, i didn't really account for that when i wrote this script. the script assumes that you want to use a different hostname for the alias. did you try using abc.host for the CNAME tag?
The error I am receiving is:
local variable 'public_ip' referenced before assignment
I modified the 4 lines in the CNAME section so that it would create A records instead of CNAME records. Below is my current code.