Thursday, August 4, 2011

How to change AWS EC2 Security Group of an existing Instance

By Semir H.

If you find this tutorial useful, please consider making a donation to support future work like this:

Thank you :)


You have a few pre-made Security Groups and one of your Instances needs to change from one to another.


AWS EC2 does not have a way to easily switch these. You basically have to clone the Instance into an AMI and then deploy a new Instance out of that AMI, taking care to associate the new Instance with the desired Security Group at the time of creation.
You can delete the AMI and the associated Snapshot, if you desire so.


Create a Security Group with your desired port settings.

Clone your Instance by right clicking on it and choosing to create an Image (EBS AMI). It is best if the original Instance is turned off so that no data is lost.

After a bit of time your new AMI should be visible in the AMIs section. Please make sure you’re in the correct Region.

Right-click on your new AMI and pick “Launch Instance”.

Use the “Request Instance Wizard” to select settings you wish but please make sure you select the correct Security Group during this process.
You may also take this opportunity to change your Key Pair.

Finish the wizard and launch the Instance.

You should now see that the new Instance has the new Security Group associated with it.
Log into your new Instance and confirm that no data is missing.


Once you are sure no data is missing and that you will not need your original Instance or the resulting AMI then you can delete both.
Also delete the Snapshot that was made during the cloning process.

No comments:

Post a Comment