You can replace the security groups of Elastic Compute Service (ECS) instances as your business needs change. This topic describes how to replace the original security groups of instances with the destination security groups.

Prerequisites

  • The instances and the destination security groups belong to the same virtual private cloud (VPC).
  • If you want to replace the security groups of multiple instances at a time, the instances reside within the same VPC.

Background information

You can replace the security groups of instances in the following scenarios:
  • The original basic security groups of the instances need to be replaced with other basic security groups or advanced security groups.
  • The original advanced security groups of the instances need to be replaced with other advanced security groups or basic security groups.
Notice
  • Security groups can affect the network connectivity of instances. Before you replace the security groups of instances, make sure that the destination security groups suit your network connectivity requirements and do not affect service availability.
  • An ECS instance cannot belong to both basic and advanced security groups at the same time.

Procedure

  1. Log on to the ECS console.
  2. In the left-side navigation pane, choose Instances & Images > Instances.
  3. In the top navigation bar, select a region.
  4. On the Instances page, use one of the following methods to replace the security groups of one or more instances:
    • Replace the security groups of a specific instance on the Security Groups tab of the Instance Details page.
      1. Find the instance whose security groups you want to replace and click Manage in the Actions column.
      2. On the Instance Details page, click the Security Groups tab.
      3. Click Replace.
    • Replace the security groups of one or more instances on the Instances page.
      • Replace the security groups of a single instance

        Find the instance whose security groups you want to replace and choose More > Network and Security Group > Replace Security Groups in the Actions column.

      • Replace the security groups of multiple instances

        Select the instances whose security groups you want to replace and choose More > Network and Security Group > Replace Security Groups in the lower part of the instance list.

  5. In the Replace Security Group for Instances dialog box, select security groups to replace the original security groups.
    1. In the Security Group Type section, select Basic Security Group or Advanced Security Group.
    2. In the Select Security Groups section, select a security group from the drop-down list.
      Note
      • If you want to select more security groups, click Add. By default, an ECS instance can be added to a maximum of five security groups.
      • If you select some security groups that do not match your expectations, click Delete in the Actions column corresponding to the security groups. After the security groups are deleted, you can select security groups that you expect.
  6. Click Replace Security Group.

Result

After you perform the preceding operations, the original security groups of the instances are replaced with the destination security groups. The destination security group rules automatically take effect on the instances. For more information about security groups, see Overview.