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 年前檢視次數 316 次
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 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南