You are working on a small project for your personal usage.
The application is hosted in an Auto Scaling group.
There is only 1 instance in the ASG and the EC2 instance may be terminated and recreated from time to time.
The EC2 DNS name and IP are changed when a new instance is launched in the ASG.
You own a hosted zone in Route 53 and plan to create a record set to route the internal traffic to the instance.
Which method is the most cost-efficient to update the record set dynamically?
Click on the arrows to vote for the correct answer
A. B. C. D.Correct Answer - C.
A cost-efficient method is required in this scenario.
The combinations of CloudWatch Event + Lambda function should be chosen.
Please check https://aws.amazon.com/blogs/compute/building-a-dynamic-dns-for-route-53-using-cloudwatch-events-and-lambda/ for the reference.
Option A is incorrect: This option needs to configure a network load balancer for the record set.
It is not the most cost-efficient method.
Option B is incorrect: Because the Alias record in Route 53 cannot configure the Auto Scaling group ARN as its target.
This option does not work.
Option C is CORRECT: Both CloudWatch Event rule and Lambda function are serverless and very cheap.
CloudWatch Event can capture the ASG event and notify the Lambda function to update the record set accordingly.
Option D is incorrect: Option C is more cost-efficient as the T2.micro EC2 instance is unnecessary.
The most cost-efficient method to update the record set dynamically in Route 53 for a small project hosted in an Auto Scaling group with only 1 instance, which may be terminated and recreated from time to time, is to use option C.
Option A, creating a network load balancer to point to the Auto Scaling group and creating an Alias record that routes the traffic to the load balancer, is not cost-efficient for a small project because it requires additional resources and incurs additional costs.
Option B, creating an Alias record in Route 53 that has the Auto Scaling group ARN as its target, does not require dynamic changes to the Route 53 record set. However, it does not solve the problem of the changing IP address or DNS name of the EC2 instance when a new instance is launched in the ASG.
Option D, creating a T2.micro EC2 instance to periodically check the Auto Scaling group and update the Route 53 record set with the new IP address, is also not cost-efficient because it requires an additional EC2 instance to run continuously, and it also adds complexity to the architecture.
Option C, configuring a CloudWatch Event rule to monitor the Auto Scaling events and trigger a Lambda function to update the CNAME in the Route 53 record set to the private DNS of the new EC2 instance, is the most cost-efficient and straightforward solution.
The CloudWatch Event rule can be configured to trigger the Lambda function whenever an instance is launched or terminated in the Auto Scaling group. The Lambda function can then use the AWS SDK to update the CNAME in the Route 53 record set with the private DNS of the new instance.
This method does not require any additional resources other than the Lambda function, which is billed based on the number of requests and duration of the function execution. Therefore, it is the most cost-efficient solution for a small project with a single instance in an Auto Scaling group.