I am trying to create a simplest example where in I can
- create a DNS A record pointing to the public IP of an EC2 instance created in default VPC.
I have the following code for the same
hostedzone.tf
resource "aws_route53_zone" "devopslink-public-zone" {
name = var.domain_mydevops_link
comment = "${var.domain_mydevops_link} public zone"
provider = aws
}
instance.tf
data "aws_ami" "ubuntu" {
most_recent = true
filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-trusty-14.04-amd64-server-*"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
owners = ["099720109477"] # Canonical
}
resource "aws_instance" "web" {
ami = data.aws_ami.ubuntu.id
instance_type = "t2.micro"
tags = {
Name = "HelloWorld"
}
}
route53-record.tf
resource "aws_route53_record" "server1-record" {
zone_id = aws_route53_zone.devopslink-public-zone.zone_id
name = "server1.devops.link"
type = "A"
ttl = "300"
records = [aws_instance.web.public_ip]
}
- Terraform apply successfully give me this
Outputs:
devopslink-name-servers = [
"ns-1363.awsdns-42.org",
"ns-1707.awsdns-21.co.uk",
"ns-466.awsdns-58.com",
"ns-941.awsdns-53.net",
]
devopslink-public-zone-id = Z06137733F7SHPRF6K9Q3
And I can see the route53 record getting created in AWS console with the public IP of the instance on route53 console
server1.devops.link A Simple - 35.174.12.184
However when i do nslookup online or by using my PC its not resolving
✗ nslookup server1.devops.link
Server: 127.0.0.53
Address: 127.0.0.53#53
** server can't find server1.devops.link: NXDOMAIN
What am i doing wrong here? I do not own the domain devops.link. My assumption is that it should be taken care by the terraform code above.