CreateResourceShare
Creates a resource share.
Operation description
Alibaba Cloud Resource Sharing allows you to share specific resources under one account with one or more target accounts. For more information, see Overview of Resource Sharing.
This topic provides an example on how to use a resource directory management account to create a resource share named test in the cn-hangzhou region, and share the vSwitch vsw-bp183p93qs667muql**** with the member 172050525300**** in the resource directory.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
resourcesharing:CreateResourceShare |
create |
*All Resource
|
|
None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| ResourceShareName |
string |
Yes |
The name of the resource share. The name must be 1 to 50 characters in length. The name can contain letters, digits, Chinese characters, periods (.), underscores (_), and hyphens (-). |
test |
| Resources |
array<object> |
No |
The list of shared resources. |
|
|
object |
No |
The list of shared resources. |
||
| ResourceId |
string |
No |
The ID of the shared resource. Valid values of N: 1 to 5. You can add up to 5 shared resources at a time. Note
|
vsw-bp183p93qs667muql**** |
| ResourceType |
string |
No |
The type of the shared resource. Valid values of N: 1 to 5. You can add up to 5 shared resources at a time. For more information about the supported resource types, see Cloud services that support Resource Sharing. Note
|
VSwitch |
| Targets |
array |
No |
The principals. |
172050525300**** |
|
string |
No |
The principal. Valid values:
For more information, see Resource sharing methods, View the ID of a resource directory, View the ID of a folder, or View the ID of a member. Valid values of N: 1 to 5. You can add up to 5 principals at a time. |
172050525300**** |
|
| ResourceArns |
array |
No |
The list of ARNs of the shared resources. Valid values of N: 1 to 5. You can add up to 5 shared resources at a time. |
|
|
string |
No |
The ARN of the shared resource. Note
For more information about the ARN format, see Cloud services that support Resource Sharing. |
acs:vpc:cn-shanghai:103755469187****:vswitch/vsw-uf62b11ue4m8oz2di**** |
|
| PermissionNames |
array |
No |
The names of the shared permissions. If this parameter is left empty, the system automatically associates the default permissions that are related to the resource type. For more information, see Permission library. |
|
|
string |
No |
The names of the shared permissions. If this parameter is left empty, the system automatically associates the default permissions that are related to the resource type. For more information, see Permission library. |
AliyunRSDefaultPermissionVSwitch |
|
| AllowExternalTargets |
boolean |
No |
Specifies whether sharing with accounts outside the resource directory or folder is allowed. Valid values:
|
false |
| ResourceGroupId |
string |
No |
The ID of the resource group. |
rg-aekz5nlvlak**** |
| TargetProperties |
array<object> |
No |
The properties of the principal. Note
You can set this parameter only when the principal is an Alibaba Cloud service. |
|
|
object |
No |
The properties of the principal. Note
You can set this parameter only when the principal is an Alibaba Cloud service. |
||
| Property |
string |
No |
The property parameter of the principal. For example, you can set the time period for resource sharing. Valid values of
Note
|
{ "timeRange":{ "timeRangeType":"timeRange", "beginAtTime":"00:00", "timezone":"UTC+8", "endAtTime":"19:59" } } |
| TargetId |
string |
No |
The ID of the principal. Note
|
172050525300**** |
| ResourceProperties |
array<object> |
No |
The list of resource properties. |
|
|
object |
No |
The list of resource properties. |
||
| Property |
string |
No |
The resource property. |
{"sharePrincipals":true,"shareTagOptions":false} |
| ResourceArn |
string |
No |
The ARN of the resource. |
acs:vpc:cn-shanghai:103755469187****:vswitch/vsw-uf62b11ue4m8oz2di**** |
| Tag |
array<object> |
No |
The list of tags. You can add up to 20 tags. |
|
|
object |
No |
The list of tags. |
||
| Key |
string |
No |
The tag key. Note
The key can be up to 128 characters in length. It cannot start with |
k1 |
| Value |
string |
No |
The tag value. Note
The value can be up to 128 characters in length. It cannot start with |
v1 |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The response parameters. |
||
| RequestId |
string |
The request ID. |
2C3FA051-61DC-4F3E-81E9-E4830524DF4B |
| ResourceShare |
object |
The information about the resource share. |
|
| AllowExternalTargets |
boolean |
Indicates whether sharing with accounts outside the resource directory or folder is allowed. Valid values:
|
false |
| CreateTime |
string |
The time when the resource share was created. |
2020-12-03T08:02:22.413Z |
| ResourceShareId |
string |
The ID of the resource share. |
rs-qSkW1HBY**** |
| ResourceShareName |
string |
The name of the resource share. |
test |
| ResourceShareOwner |
string |
The owner of the resource share. |
151266687691**** |
| ResourceShareStatus |
string |
The status of the resource share. Valid values:
Note
Records of resource shares in the Deleted state are automatically deleted by the system within 48 to 96 hours. |
Active |
| UpdateTime |
string |
The time when the resource share was updated. |
2020-12-03T08:02:22.413Z |
Examples
Success response
JSON format
{
"RequestId": "2C3FA051-61DC-4F3E-81E9-E4830524DF4B",
"ResourceShare": {
"AllowExternalTargets": false,
"CreateTime": "2020-12-03T08:02:22.413Z",
"ResourceShareId": "rs-qSkW1HBY****",
"ResourceShareName": "test",
"ResourceShareOwner": "151266687691****",
"ResourceShareStatus": "Active",
"UpdateTime": "2020-12-03T08:02:22.413Z"
}
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | InvalidParameter.ResourceShareName | The ResourceShareName is invalid. | The ResourceShareName parameter is invalid. |
| 400 | InvalidParameter.ResourceShareName.Length | The maximum length of ResourceShareName exceeds 50 characters. | The length of ResourceShareName cannot exceed 50 characters. |
| 400 | InvalidParameter.Resources | The Resources is invalid. | The specified shared resource is invalid. |
| 400 | InvalidParameter.Resources.Duplicate | The Resources contains duplicate values. | The specified Resources parameter contains duplicate values. |
| 400 | InvalidParameter.Resources.Length | The maximum number of Resources exceeds 5. | The number of specified shared resources cannot exceed 5. |
| 400 | InvalidParameter.Targets | The Targets is invalid. | The specified Targets parameter is invalid. |
| 400 | InvalidParameter.Targets.Duplicate | The Targets contains duplicate values. | The specified Targets parameter contains duplicate values. |
| 400 | InvalidParameter.Targets.Length | The maximum number of Targets exceeds 5. | The number of Targets values cannot exceed 5. |
| 400 | InvalidTarget | The shared target does not exist in the resource directory. | The specified Targets value is not a member in the resource directory. |
| 400 | InvalidParameter | The specified parameter is invalid. | The specified parameter is invalid. |
| 400 | MissingParameter.ResourceShareName | You must specify ResourceShareName. | The ResourceShareName parameter is missing. |
| 400 | InvalidParameter.ResourceType | The ResourceType is invalid. | The specified ResourceType parameter is invalid. |
| 400 | InvalidParameter.PermissionNames.Duplicate | The PermissionNames duplicate values. | Duplicate values are specified for the PermissionNames parameter. |
| 400 | InvalidParameter.PermissionNames.Length | The maximum length of PermissionNames exceeds quota limit. | The length of the value specified for the PermissionNames parameter exceeds the limit. |
| 400 | InvalidParameter.TargetProperties | The TargetProperties is invalid. | The TargetProperties is invalid. |
| 400 | InvalidParameter.TargetProperties.Duplicate | The TargetProperties contains duplicate values. | TargetProperties contains duplicate parameters. |
| 400 | InvalidParameter.TargetProperties.Length | The TargetProperties beyond the length limit. | The TargetProperties beyond the length limit. |
| 400 | InvalidParameter.ResourceArns | The ResourceArns is invalid. | The ResourceArns parameter is invalid. |
| 400 | InvalidParameter.ResourceArns.Duplicate | The ResourceArns contains duplicate values. | The ResourceArns contains duplicate values. |
| 400 | InvalidParameter.ResourceArns.Length | The ResourceArns beyond the length limit. | The maximum number of ResourceArns exceeds 5. |
| 400 | InvalidParameter.ResourceConflict | Both Resources and ResourceArns cannot be specified simultaneously. Please provide only one of these parameters. | Both Resources and ResourceArns cannot be specified simultaneously. Please provide only one of these parameters. |
| 400 | NotSupport.ResourceType.ResourcesParameter | The Resources parameter does not support this resource type. Please use ResourceArns instead. | The Resources parameter does not support this resource type. Please use ResourceArns instead. |
| 400 | InvalidParameter.ResourceProperties | The ResourceProperties is invalid. | The ResourceProperties is invalid. |
| 400 | InvalidParameter.ResourceProperties.Duplicate | The ResourceProperties contains duplicate values. | The ResourceProperties contains duplicate values. |
| 400 | InvalidParameter.ResourceProperties.Length | The ResourceProperties beyond the length limit. | The ResourceProperties beyond the length limit. |
| 400 | NotSupport.ResourceProperty | The resource type does not support resource property. | The resource type does not support resource property. |
| 404 | EntityNotExists.Permission | The resource share permission does not exist. | You do not have the required permissions. |
| 409 | NotEnableSharingWithResourceDirectory | You have not enabled sharing with your Resource Directory. | You have not enabled sharing with Resource Directory. |
| 409 | AccountNotInResourceDirectory | The account is not a master or a member of a resource directory. | The specified Targets value is not a member in the resource directory. |
| 409 | QuotaExceeded.ResourceShare.Count | The maximum number of ResourceShare exceeds the limit. | The maximum number of ResourceShare exceeds the limit. |
| 409 | EntityAlreadyExists.ResourceShare | The specified resource share ID already exists. | The specified resource share ID already exists. |
| 409 | QuotaExceeded.SharedResource.Count | The maximum number of shared resources per account exceeds the limit. | The maximum number of Resources values per account is exceeded. |
| 409 | ShareWithYourself | You cannot share resources with yourself. | You cannot share resources with yourself. |
| 409 | NotManagementAccount | Only the management account of the service is allowed to share such resources. | Only the management account of the resource directory can be used to share the current type of resource. If you still want to use the current account, contact the owner of the management account to configure the current account as a delegated administrator account of the trusted service to which the resource belongs. |
| 409 | QuotaExceeded.PendingInvitations | The maximum number of pending invitations exceeds the limit. | The number of invitations exceeds the upper limit. |
| 409 | InvalidTarget.LegalEntityMismatch | The target account does not have the same legal entity as the resource owner account. | The enterprise name of the principal is inconsistent with that of the resource owner. |
| 409 | ExternalTargetsNotAllowed.ResourceType | The resource share includes resource types that cannot be shared with accounts outside the resource directory. | The resource share contains resources that do not support this operation. |
| 409 | InvalidTarget.SiteMismatch | Cross-site resource sharing is not supported. | The principal and resource owner are registered at different sites. |
| 409 | NotSupport.Service.ExistInOtherResourceShare | The resource type has been shared to the target service through other resourceShare. Please share it in the same resourceShare. | |
| 409 | NotSupport.Service.AssociateConflict | The same resource cannot be shared repeatedly to the target service. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.