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?

已提问 1 年前317 查看次数
1 回答
5
已接受的回答

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
专家
已回答 1 年前
profile picture
专家
已审核 2 天前
profile pictureAWS
专家
已审核 1 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则