Sunday, April 17, 2011

Resizing an Amazon EC2 instance

We had overbuilt some of our Amazon instances because we were not sure of the performance requirements. This was costing us lots of money so we recently started downsizing some of these instances. This is how I was doing it:

  1. Confirm that Ec2SetComputerName is disabled
  2. Stop the instance
  3. Launch a new instance in the same zone
  4. Stop the new instance
  5. Attach the volumes from the old instance to the new one
  6. Start the new instance
  7. Terminate the old instance
  8. Delete the volume that came with the new instance
  9. Reassociate the Elastic IP address

Wow, that was rather cumbersome, but that is the only way to do this via the EC2 console. Looking at the API, I found the following Powershell command that replaces steps 3 to 8:
ec2-modify-instance-attribute <instance-id> --instance-type <new-instance-type>

That's it! I can't believe I did it the hard way that many times.

No comments:

Post a Comment