Bind a role
Updated at:2025-10-20
This API is designed to assign a role to a BCC instance.
- For the definition and functions of roles, see https://cloud.baidu.com/doc/IAM/s/Gjxlikxcf
Request structure
Plain Text
1POST /v{version}/instance/role?{action} HTTP/1.1
2Host: bcc.bj.baidubce.com
3Authorization: authorization string
4{
5 "roleName": roleName,
6 "instances": [{
7 "instanceId": instanceId
8 }]
9}
Request headers
There are no special headers required beyond the common headers.
Request parameters
| Parameter name | Types | Whether required | Parameter location | Description |
|---|---|---|---|---|
| version | String | Yes | URL parameter | API version number |
| action | String | Yes | Query | Action performed on the instance, current value: bind |
| roleName | String | Yes | requestBody parameters | Name of the role to be bound to the instance |
| instances | List<[InstancePassRoleModel](BCC/API Reference/Appendix.md#InstancePassRoleModel)> | Yes | requestBody parameters | List of instance IDs to which the role is to be bound |
Response headers
No special headers are required beyond the standard ones.
Response parameters
| Parameter name | Types | Description |
|---|---|---|
| failInstances | List<[InstancePassRoleFailModel](BCC/API Reference/Appendix.md#InstancePassRoleFailModel)> | List of instances for which role binding failed |
| instanceRoleAssociations | List<[InstanceRoleAssociationModel](BCC/API Reference/Appendix.md#InstanceRoleAssociationModel)> | List of instances with successful role binding |
Error codes
| Error code | Error description | HTTP status code | Chinese explanation |
|---|---|---|---|
| BadRequest | request is invalid | 400 | Invalid request parameters |
| BadRequest | instances is null or empty | 400 | Empty list of instances to which the role |
| BadRequest | roleName is null or empty | 400 | Empty role name to be bound |
| BadRequest | invalid roleName | 400 | Invalid role name |
| AccessDenied | No permission to accessor or permission error. | 403 | Operation prohibited |
Request example
Plain Text
1POST http://bcc.bj.baidubce.com/v2/instance/role?bind
2Host: bcc.bj.baidubce.com
3Authorization: bce-auth-v1/f81d3b34e48048fbb2634dc7882d7e21/2015-08-11T04:17:29Z/3600/host/74c506f68c65e26c633bfa104c863fffac5190fdec1ec24b7c03eb5d67d2e1de
4
5{
6 "roleName": "roleName",
7 "instances": [{
8 "instanceId": "i-123456"
9 }]
10}
Response example
Plain Text
1HTTP/1.1 200 OK
2Content-Type: application/json;charset=UTF-8
3Date: Wed, 08 Jul 2015 03:28:11 GMT
4x-bce-request-id: d8752367-38e8-45e4-b4c7-e53be3137ce5
5Server: BWS
6
7{
8 "failInstances": [{
9 "instanceId": "i-123456",
10 "failMessage": "failMessage"
11 }],
12 "instanceRoleAssociations": [{
13 "instanceId": "i-123456"
14 }]
15}
