Todos los productos
Search
Centro de documentos

Elastic Compute Service:JoinSecurityGroup

Última actualización: Sep 01, 2026

Agrega una instancia de ECS o una interfaz de red elástica a un security group.

Descripción de la operación

Nota

Esta API está obsoleta. Se recomienda llamar a la operación ModifyInstanceAttribute para agregar o eliminar una instancia de ECS de un security group, o llamar a la operación ModifyNetworkInterfaceAttribute para agregar o eliminar una interfaz de red elástica (ENI) de un security group.

  • No puede agregar una instancia y una interfaz de red elástica a un security group en la misma llamada. Los parámetros InstanceId y NetworkInterfaceId son mutuamente excluyentes.

  • El security group y la instancia deben estar en la misma región de Alibaba Cloud.

  • El security group y la instancia deben tener el mismo tipo de red. Si el tipo de red es VPC, también deben pertenecer a la misma VPC.

  • Solo puede agregar una instancia a un security group si la instancia se encuentra en estado Stopped o Running.

  • Una instancia o una interfaz de red elástica puede pertenecer a un máximo de cinco security groups. Para obtener más información, consulte Límites de los security groups.

Pruébelo ahora

Pruebe esta API en OpenAPI Explorer sin necesidad de firma manual. Las llamadas exitosas generan automáticamente código SDK acorde a sus parámetros. Descárguelo con seguridad de credenciales integrada para uso local.

Test

Autorización de RAM

La siguiente tabla describe la autorización necesaria para invocar esta API. Puede definirla en una directiva de Resource Access Management (RAM). A continuación, se detallan las columnas de la tabla:

  • Action: Estas acciones se utilizan en el elemento Action de las declaraciones de directivas de permisos de RAM para otorgar permisos que permitan realizar la operación.

  • API: La API que debe invocarse para llevar a cabo la acción.

  • Nivel de acceso: Nivel de acceso predefinido que se concede para cada API. Valores válidos: create, list, get, update y delete.

  • Tipo de recurso: Tipo de recurso que admite autorización para ejecutar la acción. Indica si la acción es compatible con permisos a nivel de recurso. El recurso especificado debe ser compatible con la acción; de lo contrario, la directiva no surtirá efecto.

    • En las API con permisos a nivel de recurso, los tipos de recursos obligatorios se marcan con un asterisco (*). Especifique el Alibaba Cloud Resource Name (ARN) correspondiente en el elemento Resource de la directiva.

    • Para las API sin permisos a nivel de recurso, se muestra All Resources. Utilice un asterisco (*) en el elemento Resource de la directiva.

  • Clave de condición: Claves de condición definidas por el servicio. Permiten un control granular y se aplican ya sea solo a acciones o a acciones asociadas con recursos específicos. Además de las claves de condición específicas del servicio, Alibaba Cloud proporciona un conjunto de common condition keys aplicables a todos los servicios compatibles con RAM.

  • Acción dependiente: Acciones dependientes necesarias para ejecutar la acción principal. Para completar la operación, el usuario de RAM o el rol de RAM debe contar con permisos para realizar todas las acciones dependientes.

Action

Nivel de acceso

Tipo de recurso

Clave de condición

Acción dependiente

ecs:JoinSecurityGroup

update

*Instance

acs:ecs:{#regionId}:{#accountId}:instance/{#instanceId}

*SecurityGroup

acs:ecs:{#regionId}:{#accountId}:securitygroup/{#securitygroupId}

Ninguna Ninguna

Parámetros de la solicitud

Parámetro

Tipo

Obligatorio

Descripción

Ejemplo

SecurityGroupId

string

Sí

El ID del security group. Llame a DescribeSecurityGroups para ver sus security groups disponibles.

sg-bp67acfmxazb4p****

InstanceId

string

No

El ID de la instancia.

Nota

Si especifica este parámetro, debe dejar NetworkInterfaceId vacío.

i-bp67acfmxazb4p****

NetworkInterfaceId

string

No

El ID de la interfaz de red elástica.

Nota

Si especifica este parámetro, debe dejar InstanceId vacío.

eni-bp13kd656hxambfe****

RegionId

string

No

El ID de la región. Llame a DescribeRegions para ver la lista más reciente de regiones de Alibaba Cloud.

  • Este parámetro es opcional cuando agrega una instancia a un security group.

  • Este parámetro es obligatorio cuando agrega una interfaz de red elástica a un security group. El valor debe ser el ID de la región donde se encuentra la interfaz de red elástica.

cn-hangzhou

Elementos de la respuesta

Elemento

Tipo

Descripción

Ejemplo

object

RequestId

string

El ID de la solicitud.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

Ejemplos

Respuesta exitosa

JSON Formato

{
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
}

Códigos de error

Código de estado HTTP

Código de error

Mensaje de error

Descripción

400 InstanceSecurityGroupLimitExceeded Exceeding the allowed amount of security groups that an instance can be in. The number of security groups bound to the instance has reached the maximum limit.
400 InvalidInstanceId.Mismatch Specified instance and security group are not in the same VPC. The specified instance and security group do not belong to the same VPC, or one of the following cases has occurred: 1. The security group is of the VPC network type but the instance is not. 2. The instance is of the VPC network type but the security group is not.
400 InvalidInstanceId.Malformed The specified parameter "InstanceId" is not valid.
400 InvalidOperation.NotSupportEnterpriseGroup The specified instance type doesn't support enterprise level security group.
400 InvalidOperation.MultiGroupType The specified instance can't join different types of security group.
400 InvalidOperation.InvalidEniState %s The current status of the ENI does not allow modifying ENI attributes.
400 InvalidOperation.EniAndGroupNotBelongSameUser %s
400 NotBelongUser %s You are not authorized to manage the specified resource.
400 MissingParameter.RegionId The specified RegionId should not be null. The RegionId parameter is required.
400 InvalidStatus.EniOrInstanceIsBeingCreated %s. The specified ECS instance or ENI is currently being created. Please wait for the creation process to complete and try again.
500 InternalError The request processing has failed due to some unknown error.
403 IncorrectInstanceStatus The current status of the resource does not support this operation.
403 InstanceLockedForSecurity The specified operation is denied as your instance is locked for security reasons. The instance is locked for security reasons. Contact security technical support.
403 SecurityGroupInstanceLimitExceeded The maximum number of instances in a security group is exceeded. The maximum number of instances in the specified security group has been reached.
403 InvalidInstanceId.AlreadyExists The specified instance already exists in the specified security group. The specified instance is already present in the specified security group.
403 AclLimitExceed %s The number of ACL rules for an ENI or instance exceeds the upper limit.
403 InstanceSecurityGroupLimitExceeded %s The number of security groups bound to the instance has reached the maximum limit.
403 InvalidOperation.NetworkInterfaceCountExceeded The maximum number of NetworkInterface in a enterprise level security group is exceeded. The number of NICs in the specified enterprise security group exceeds the limit.
403 InvalidOperation.ResourceManagedByCloudProduct %s You cannot modify security groups managed by cloud services.
403 InvalidOperation.InvalidEniType %s The current type of the Elastic Network Interface (ENI) does not support this operation.
403 InvalidOperation.VpcMismatch %s The operation is invalid. Check whether the VPC in the operation corresponds to other parameters.
403 InvalidOperation.EniServiceManaged %s The operation is invalid.
403 InvalidParam.Malformed %s Invalid parameter
403 InvalidParam.EniIdAndInstanceId.Conflict %s The InstanceId and NetworkInterfaceId parameters are mutually exclusive and cannot be both specified.
403 Forbidden.InstanceIsBeingCreated The specified instance is being created. The specified instance is being created.
404 InvalidSecurityGroupId.NotFound The specified SecurityGroupId does not exist. The specified security group does not exist in this account. Check whether the security group ID is correct.
404 InvalidInstanceId.NotFound The specified InstanceId does not exist. The specified instanceId is invalid.
404 InvalidEniId.NotFound %s
409 InvalidOperation.Conflict Request was denied due to conflict with a previous request, please try again later. A conflicting task exists in the port list.

Consulte Códigos de error para ver la lista completa.

Notas de la versión

Consulte Notas de la versión para ver la lista completa.