Change Security Groups Accosiacted with a CVM

Last updated: 2018-09-10 21:47:32

1. API Description

This API (ModifySecurityGroupsOfInstance) is used to modify security groups associated with specified CVMs. Note: this API will be out of service soon. Please use the new API: ModifyInstancesAttribute
Domain name for API request:

1) CVMs are used as the index for operations with this API. The list of security group IDs to associate with needs to be set individually for each CVM.
2) Past-due CVMs or those in the process of migration and change are not allowed to be associated with security groups.
3) This API is used to modify the security groups associated with the primary ENI of the CVM. For other ENIs, please use ModifySecurityGroupsOfNetworkInterface.
4) Once this API is called, the new security group association will overwrite the previous ones. If you want to add new associated security groups but not to change the existing ones, please include all security group information in "sgId". To remove a security group, just delete it from the "sgId" parameter.
5) Similar to rules in security groups, security groups associated with one CVM are in a certain order, and take effect in the order the sgIds entered for this API are presented in. When your security group rule contains action = drop, a change in the order may lead to different network protection results, so you should be careful when making modifications.

2. Input Parameters

Parameter Name Required Type Description
instanceSet Yes Array List of security group associated with this CVM (up to 20)
Data fields for elastic CVM and security group association
Parameter Name Required Type Description
instanceId Yes String CVM instance ID; associates all the passed virtual machines with all the passed security groups in order
sgIds Yes Array List of unique IDs of associated security groups, in the order the sgIds members are presented in

3. Output Parameters

Parameter Name Type Description
code Int Error code, 0: succeeded, other values: failed
message String Error message

4. Error CodeS

Error Code Description
7000 Security group backend exception
7003 This CVM cannot be associated now

5. Example

  &Common request parameters


    "code": 0,
    "message": ""