Adam Harkus
Adam Harkus

Reputation: 2210

How do I create a public IP address for my AWS ALB?

My EC2 instance has an endpoint Public DNS name which works fine.

However, there's no public IP address attached to it.

How do I set this up so that I can point our DNS records to it?

Upvotes: 1

Views: 5785

Answers (2)

John Hanley
John Hanley

Reputation: 81336

Your question asks about IP addresses for ALB and IP addresses for EC2 instances. Similar topics but very different use cases.

If you want to setup a domain name to point to an EC2 instance, add / use an Elastic IP address to your EC2 instance. Do not use the Public DNS endpoint.

If you instead want to attach your EC2 instances to your ELB, then you will specify the EC2 instance ID when configuring the load balancer. The load balancer will use the private IP address to communicate to the EC2 instances.

The following is my comments on setting up IP addressing for EC2 instances. This is NOT required for EC2 instances behind load balancers.

You cannot manually associate or disassociate a public IP address from your instance. Instead, in certain cases, we release the public IP address from your instance, or assign it a new one:

  1. We release the public IP address for your instance when it's stopped or terminated. Your stopped instance receives a new public IP address when it's restarted.
  2. We release the public IP address for your instance when you associate an Elastic IP address with your instance, or when you associate an Elastic IP address with the primary network interface (eth0) of your instance in a VPC. When you disassociate the Elastic IP address from your instance, it receives a new public IP address.
  3. If the public IP address of your instance in a VPC has been released, it will not receive a new one if there is more than one network interface attached to your instance.

If you require a persistent public IP address that can be associated to and from instances as you require, use an Elastic IP address instead.

Public IPv4 Addresses and External DNS Hostnames

Elastic IP Addresses

Upvotes: 0

Two options:

  1. Use the Public DNS name as a CNAME record.
  2. Setup an Elastic IP Address and use it in an A record.

The advantage of a CNAME is that there are no limits. Elastic IPs have limits - I think 5 per account, though that may have changed and there may be ways to get more. The advantage of an Elastic IP is that you can move it around between instances while keeping your DNS record pointing to the same IP address.

This assumes you already have NS records pointing somewhere where you can configure DNS. If you don't have DNS set up and you want to do everything in AWS then you can use Route 53.

Upvotes: 2

Related Questions