Assign custom DNS name to ec2 instance.

0

Hello,

Is it possible to assign a domain name to ec2 instance. My goal is to have ec2 instances with my custom domain assigned for example: app-1.example.com For now my idea is to programmatically assign or remove domain name based on instance state.

Maybe there is a AWS service that could help me?

asked a year ago293 views
1 Answer
4
Accepted Answer

Yes, it is possible to assign a custom domain name to your EC2 instances. One way to do this is by using Amazon Route 53, which is a DNS web service that you can use to route traffic to various AWS services, including EC2 instances.

Here are the general steps to assign a custom domain name to your EC2 instance using Route 53:

  1. First, register your domain name with a domain registrar such as Amazon Route 53, or transfer your existing domain to Route 53.
  2. Next, create a hosted zone in Route 53 that corresponds to your domain name.
  3. Create an "A" record in the hosted zone that maps your domain name to the Elastic IP address of your EC2 instance.
  4. Optionally, you can also create a "CNAME" record in the hosted zone that maps a subdomain of your domain name to the public DNS name of your EC2 instance.
  5. Associate the hosted zone with your domain name at the domain registrar.

To programmatically assign or remove the domain name based on the instance state, you can use AWS Lambda and AWS CloudWatch Events. You can create a Lambda function that listens to the EC2 instance state change events using CloudWatch Events, and then programmatically update or delete the Route 53 record sets accordingly.

profile picture
EXPERT
answered a year ago
profile pictureAWS
EXPERT
reviewed a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions