You can replace security groups of an ECS instance based on your business needs.

Prerequisites

The instance and the target security groups must belong to the same VPC.

Background information

You can replace security groups in the following scenarios:
  • Replace one or more basic security groups of an instance with other basic security groups.
  • Replace one or more advanced security groups of an instance with other advanced security groups.
  • Replace one or more basic security groups of an instance with advanced security groups.
  • Replace one or more advanced security groups of an instance with basic security groups.
Notice
  • Security groups can affect the network connections of your instances. We recommend that you debug the target security groups before you replace the security groups to ensure service availability.
  • An instance can only be added to security groups that are of the same type.

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, take one of the following steps based on the number of instances that you need to replace security groups for:
    • Replace security groups for a single instance

      Find the target instance and choose More > Network and Security Group > Replace in the Actions column.

    • Replace security groups for multiple instances

      Select the target instances and choose More > Network and Security Group > Replace in the lower part of the instance list.

  5. In the Replace Security Group for Instances dialog box, select new security groups to replace the original security groups.
    1. Security Group Type: Select Basic Security Group or Advanced Security Group.
    2. Select Security Groups: Select a security group from the drop-down list.
      Note If you want to select multiple security groups, click Add to select more security groups. One ECS instance can be added to a maximum of five security groups.
  6. Click Replace Security Group.

Result

After the operations are complete, security groups are replaced.