Associates resources or accounts with a resource share.
You can share your resources only with the member accounts in your resource directory.
In this example, the vSwitch vsw-bp183p93qs667muql****
is associated with the resource share rs-6GRmdD3X****
in the cn-hangzhou
region and is shared with the account 172050525300****
.
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | AssociateResourceShare |
The operation that you want to perform. Set the value to AssociateResourceShare. |
RegionId | String | Yes | cn-hangzhou |
The region ID. For more information about regions where the Resource Sharing service is available, see DescribeRegions. |
ResourceShareId | String | Yes | rs-6GRmdD3X**** |
The ID of the resource share. |
Resources.N.ResourceId | String | No | vsw-bp183p93qs667muql**** |
The ID of the shared resource. Valid values of N: 1 to 5. This indicates that a maximum of five shared resources can be specified at a time. Note Resources.N.ResourceId and Resources.N.ResourceType must be used in pairs.
|
Resources.N.ResourceType | String | No | VSwitch |
The type of the shared resource. Valid values of N: 1 to 5. This indicates that a maximum of five shared resources can be specified at a time. Set the value to VSwitch. Note
|
Targets.N | RepeatList | No | 172050525300**** |
The shared target. A shared target shares the resources of resource owners. You can share your resources only with the member accounts in your resource directory. A shared target is indicated by its account ID. For more information about how to obtain the ID, see View the basic information of a member account. Valid values of N: 1 to 5. This indicates that a maximum of five shared targets can be specified at a time. |
For more information about common parameters, see Common parameters.
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
RequestId | String | 111FB84A-60A9-403E-9067-E55D7EE95BD1 |
The ID of the request. |
ResourceShareAssociations | Array of ResourceShareAssociation |
The information of the entities that are associated with the resource share. |
|
AssociationStatus | String | Associating |
The association status. Valid values:
Note
The system automatically deletes the records of entities in the Failed or Disassociated state within 48 hours to 96 hours after you delete the entities.
|
AssociationStatusMessage | String | The reason for the association failure. |
The cause of the association failure. |
AssociationType | String | Resource |
The association type. Valid values:
|
CreateTime | String | 2020-12-04T09:40:41.246Z |
The time when the association was created. The value of this parameter depends on the value of the AssocisationType parameter:
|
EntityId | String | vsw-bp183p93qs667muql**** |
The ID of the entity. Valid values:
|
EntityType | String | VSwitch |
The type of the entity. Valid values:
|
ResourceShareId | String | rs-6GRmdD3X**** |
The ID of the resource share. |
ResourceShareName | String | test |
The name of the resource share. |
UpdateTime | String | 2020-12-04T09:40:41.246Z |
The time when the association was updated. The value of this parameter depends on the value of the AssocisationType parameter:
|
Examples
Sample requests
https://resourcesharing.aliyuncs.com/?Action=AssociateResourceShare
&RegionId=cn-hangzhou
&ResourceShareId=rs-6GRmdD3X****
&Resources.1.ResourceId=vsw-bp183p93qs667muql****
&Resources.1.ResourceType=VSwitch
&Targets.1=172050525300****
&RegionId=cn-hangzhou
&<Common request parameters>
Sample success responses
XML
format
<AssociateResourceShareResponse>
<ResourceShareAssociations>
<ResourceShareId>rs-6GRmdD3X****</ResourceShareId>
<EntityId>vsw-bp183p93qs667muql****</EntityId>
<EntityType>VSwitch</EntityType>
<AssociationStatusMessage></AssociationStatusMessage>
<AssociationType>Resource</AssociationType>
<CreateTime>2020-12-04T09:40:41.246Z</CreateTime>
<UpdateTime>2020-12-04T09:40:41.246Z</UpdateTime>
<ResourceShareName>test</ResourceShareName>
<AssociationStatus>Associating</AssociationStatus>
</ResourceShareAssociations>
<ResourceShareAssociations>
<ResourceShareId>rs-6GRmdD3X****</ResourceShareId>
<EntityId>172050525300****</EntityId>
<EntityType>Account</EntityType>
<AssociationStatusMessage></AssociationStatusMessage>
<AssociationType>Target</AssociationType>
<CreateTime>2020-12-04T09:40:41.250Z</CreateTime>
<UpdateTime>2020-12-04T09:40:41.250Z</UpdateTime>
<ResourceShareName>test1</ResourceShareName>
<AssociationStatus>Associating</AssociationStatus>
</ResourceShareAssociations>
<RequestId>111FB84A-60A9-403E-9067-E55D7EE95BD1</RequestId>
</AssociateResourceShareResponse>
JSON
format
{
"ResourceShareAssociations": [
{
"ResourceShareId": "rs-6GRmdD3X****",
"EntityId": "vsw-bp183p93qs667muql****",
"EntityType": "VSwitch",
"AssociationStatusMessage": "",
"AssociationType": "Resource",
"CreateTime": "2020-12-04T09:40:41.246Z",
"UpdateTime": "2020-12-04T09:40:41.246Z",
"ResourceShareName": "test",
"AssociationStatus": "Associating"
},
{
"ResourceShareId": "rs-6GRmdD3X****",
"EntityId": "172050525300****",
"EntityType": "Account",
"AssociationStatusMessage": "",
"AssociationType": "Target",
"CreateTime": "2020-12-04T09:40:41.250Z",
"UpdateTime": "2020-12-04T09:40:41.250Z",
"ResourceShareName": "test1",
"AssociationStatus": "Associating"
}
],
"RequestId": "111FB84A-60A9-403E-9067-E55D7EE95BD1"
}
Error codes
HTTP status code | Error code | Error message | Description |
---|---|---|---|
400 | MissingParameter.ResourceShareId | You must specify ResourceShareId. | The error message returned because the ResourceShareId parameter is not specified. |
400 | InvalidParameter.ResourceShareId | The ResourceShareId is invalid. | The error message returned because the value of the ResourceShareId parameter is invalid. |
400 | InvalidParameter.Resources | The Resources is invalid. | The error message returned because the specified resource is invalid. |
400 | InvalidParameter.Resources.Length | The maximum number of Resources exceeds 5. | The error message returned because the number of specified resources has exceeded the upper limit. Specify a maximum of five resources. |
400 | InvalidParameter.Resources.Duplicate | The Resources contains duplicate values. | The error message returned because duplicate resources are specified. |
400 | InvalidParameter.Targets | The Targets is invalid. | The error message returned because the value of the Targets parameter is invalid. |
400 | InvalidParameter.Targets.Length | The maximum number of Targets exceeds 5. | The error message returned because the number of specified shared targets has exceeded the upper limit. Specify a maximum of five shared targets. |
400 | InvalidParameter.Targets.Duplicate | The Targets contains duplicate values. | The error message returned because duplicate accounts are specified. |
409 | AccountNotInResourceDirectory | The account is not a master or a member of a resource directory. | The error message returned because the specified account is not in your resource directory. |
404 | EntityNotExists.ResourceShare | The resource share does not exist in the current account. | The error message returned because the resource share does not belong to your Alibaba Cloud account. |
409 | ResourceShareStatusMismatchAction | The status of the resource share does not allow the specified operation. | The error message returned because the operation is not supported while the resource share is in the current state. |
409 | QuotaExceeded.SharedResource.Count | The maximum number of shared resources per account exceeds 10. | The error message returned because the maximum number of shared resources within an Alibaba Cloud account has been reached. A maximum of 10 resources can be shared within an Alibaba Cloud account. |
409 | ShareWithYourself | You cannot share resources with yourself. | The error message returned because you are not allowed to share resources with yourself. |
400 | InvalidTarget | The shared target does not exist in the resource directory. | The error message returned because the specified account is not in your resource directory. |
400 | ResourceAndTargetBothEmpty | Either a resource or a shared target must be specified. | The error message returned because no resources or accounts are specified. |
409 | AssociateConflict | You cannot perform the operation while disassociation operation is being performed. | The error message returned because the operation is not supported while a disassociation operation is being performed. |
400 | InvalidParameter | The specified parameter is invalid. | The error message returned because a specified parameter is invalid. |
For a list of error codes, visit the API Error Center.