0

UPDATE: rewritten question

I have an ec2 instance launched via terraform which is unreachable; I manually launched the exact same type of instance, based on the exact same image and was able to connect to it no issues.

Comparing the 2 instances, the only differences I can see is in network settings:

  • Public IPv4 DNS is listed for the reachable (manually launched) instance, but blank for the terraformed instance.
  • Answer private resource DNS name is listed as IPv4 (A) for the reachable instance and blank for the terraformed instance.

Q: How do I provide this missing piece of infra?

  • the dns provider seems to be for setting up custom domains? I don't need that / don't have a custom domain name I want to use for this server.
  • the different record types are confusing to me because I'm not a networking expert.

Can anyone point me in the right direction to specify this in terraform?

yen
  • 121
  • 1
  • 1
  • 10
  • ach... i keep confusing the stack* communities. I guess this should've been on serverfault. sorry! I can delete and move it if needed? But I think you're not allowed to ask the same thing on more than 1 site so not sure what to do now. – yen Oct 24 '22 at 02:33
  • 1
    What do you mean by "unreachable" exactly? Does its IP address not answer to anything, or does it not get a domain name that it's supposed to, or what? – u1686_grawity Oct 24 '22 at 04:25
  • Have you used any DNS tools to analyze a differences between the (un)reachable nodes? Does the IP of the unreachable node seems to exist or not at all? Have you tried to contact Support so they can run tests from their side? – harrymc Oct 24 '22 at 09:04
  • 1
    "Unreachable" as in I cannot ping it and I cannot connect to it via EC2 Instance Connect from the AWS console. – yen Oct 25 '22 at 23:51
  • DNS is only for name resolution. I.e. .com ---> public IP. If you have an IP, which may be what you are missing, then you should be able to ping or traceroute that. – rfportilla Oct 28 '22 at 05:12

1 Answers1

0

The following two posts may answer your question.

From the post EC2 instance has no public DNS :

  • Go to console.aws.amazon.com
  • Go To Services -> VPC
  • Open Your VPCs
  • select your VPC connected to your EC2 and
  • select Actions > Edit DNS Hostnames
  • Change DNS hostnames: to YES

The post EC2 instance in public subnet has no public IP adds this :

Your instances won't automatically get public IPs attached to their ENIs after you enable 'Auto-assign IPv4' in your subnet. One possible solution without spinning up a new EC2 is to attach an Elastic IP (as @Oleksii Donoha suggested in the comment) to this instance. You can follow the aws docs to allocate an Elastic IP address and then associate it with your running instance.

Side note: It's not possible to attach an ephemeral ip to an already-created ENI or EC2 instance. See discussions here.

harrymc
  • 455,459
  • 31
  • 526
  • 924
  • Thanks v much for this. Thing is, I am launching it via terraform. So I'm trying to figure out how to automate this DNS stuff. I don't want my solution to involve manually change the instance, it will cause drift terraform. – yen Oct 25 '22 at 23:50
  • See [this post](https://stackoverflow.com/questions/69840337/terraform-get-ip-address-of-api-gatway). If it doesn't help. see [Troubleshoot Terraform](https://learn.hashicorp.com/tutorials/terraform/troubleshooting-workflow), where is also described how to create a log which you can post here (if interesting). – harrymc Oct 26 '22 at 09:14