JoinSecurityGroup

Last Updated: Sep 21, 2017

Description

Add an ECS instance to a specified security group.

  • This operation can only be performed for instances in Stopped or Running status.
  • Each instance can be attached to a maximum of 5 security groups.
  • Each security group can have up to 1000 instances.
  • When you add an instance with VPC network type to a security group with classic network type, the error InvalidInstanceId.Mismatch will be returned.
  • When you add a security group with VPC network type to an instance with classic network type, the error InvalidInstanceId.Mismatch will be returned.

Request parameters

Name Type Required Description
Action String Yes Value: JoinSecurityGroup.
InstanceId String Yes The ID of the instance that you add to a security group.
SecurityGroupId String Yes The ID of the security group into which you add an instance.

Return parameters

All parameters are public return parameters. See Public parameters for details.

Error codes

Error code Description HTTP status code Meaning
InstanceSecurityGroupLimitExceeded Exceeding the allowed number of security groups that an instance can be in. 400 The instance has joined the maximum number of security groups allowed.
MissingParameter The input parameter InstanceId that is mandatory for processing this request is not supplied. 400 InstanceId value is missing.
MissingParameter The input parameter SecurityGroupId that is mandatory for processing this request is not supplied. 400 SecurityGroupId value is missing.
IncorrectInstanceStatus The current status of the resource does not support this operation. 403 The current status of the resource does not support this operation.
InstanceLockedForSecurity The specified operation is denied as your instance is locked for security reasons. 403 The operation is denied because the resource is locked for security reasons.
InvalidInstanceId.AlreadyExists The specified instance already exists in the specified security group. 403 The specified security group already contains the specified instance.
InvalidInstanceId.Mismatch Specified instance and security group are not in the same VPC. 403 The specified instance and security group do not belong to the same VPC.
SecurityGroupInstanceLimitExceeded Exceeding the allowed number of instances of a security group. 403 The number of instances in a security group has reached the upper limit.
InvalidInstanceId.NotFound The specified InstanceId does not exist. 404 The specified InstanceId does not exist.
InvalidSecurityGroupId.NotFound The specified SecurityGroupId does not exist. 404 The specified SecurityGroupId does not exist.

Examples

Request example

  1. https://ecs.aliyuncs.com/?Action=JoinSecurityGroup
  2. &InstanceId= i-instance1
  3. &SecurityGroupId=F876FF7BA984
  4. &<Public Request Parameters>

Return example

XML format

  1. <JoinSecurityGroupResponse>
  2. <RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E</RequestId>
  3. </JoinSecurityGroupResponse>

JSON format

  1. {
  2. "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
  3. }
Thank you! We've received your feedback.