Reputation: 109
Objective: What we are trying to achieve is an automated way to configure EC2 instance from scratch rather than doing it manually. For this, we have written some ansible playbooks
Problem: Now I have an existing EC2 instance(say Machine1). I have to test provisioning( ansible playbooks) in new EC2 instance having the same Private IP as Machine1.
We are allowed to stop Machine1 (no data/config should be lost in this process)
Reason to use same IP: the same IP is used so that the internal DNS records don't have to change because of the re-creation
I tried looking into AWS documentation but nothing helped.
Upvotes: 1
Views: 2124
Reputation: 269101
When an Amazon EC2 instance is created, it is assigned a Private IP address. This is either a random IP address assigned within the subnet's CIDR range, or a specific IP address requested when the instance is started.
The instance will retain that IP address until it is terminated. Once it is terminated, the same IP address can be used again for another instance. However, until it is terminated, no other instance within the same VPC can use the same IP address. This is regardless of the instance state (running, stopped).
Upvotes: 2
Reputation: 741
This cannot be done in one step. you have to take backup and terminate the instance then create new. see this link for more information.
Upvotes: 1