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