Reputation: 125
I want to point a subdomain to an EC2 and I don't want to use Elastic IP and every time I start/stop the instance I want my subdomain point to the new Instance public IP address.
Upvotes: 2
Views: 177
Reputation: 269330
The easiest method is to use an Elastic IP address. It will remain attached to the instance and will not change. There is no additional charge for an Elastic IP address if it is attached to a running instance.
Alternatively, you could configure the operating system running on the instance to run a script whenever the instance starts. The script can update the DNS entry for the current public IP address associated with the instance. If you are using Amazon Route 53 for DNS, then you can make an API call that updates the A-Record to the current IP address being used by the instance.
I suspect it could be done with the change-resource-record-sets command in the AWS CLI.
Upvotes: 2