Creates a resource share.
Operation description
Resource Sharing allows you to share your resources with one or more accounts and access the resources shared by other accounts. For more information, see Resource Sharing overview.
This topic provides an example on how to call the API operation to create a resource share named test
in the cn-hangzhou
region to share the vSwitch vsw-bp183p93qs667muql****
with the member 172050525300****
in a resource directory. In this example, the management account of the resource directory is used to call this API operation.
Debugging
Authorization information
The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action
policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:
- Operation: the value that you can use in the Action element to specify the operation on a resource.
- Access level: the access level of each operation. The levels are read, write, and list.
- Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
- The required resource types are displayed in bold characters.
- If the permissions cannot be granted at the resource level,
All Resources
is used in the Resource type column of the operation.
- Condition Key: the condition key that is defined by the cloud service.
- Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
*All Resources * |
| 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, periods (.), underscores (_), and hyphens (-). | test |
Resources | array<object> | No | The information about the shared resources. | |
object | No | The shared resource. | ||
ResourceId | string | No | The ID of a 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.
| vsw-bp183p93qs667muql**** |
ResourceType | string | No | The type of a shared resource. Valid values of N: 1 to 5. This indicates that a maximum of five shared resources can be specified at a time. For more information about the types of resources that can be shared, see Services that work with Resource Sharing. Note
Resources.N.ResourceId and Resources.N.ResourceType must be used in pairs.
| VSwitch |
Targets | array | No | The information about the principals. | |
string | No | The information about a principal.
For more information, see Resource sharing modes, 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. This indicates that a maximum of five principals can be specified at a time. | 172050525300**** | |
PermissionNames | array | No | The information about the permissions. If you do not configure this parameter, the system automatically associates the default permission for the specified resource type with the resource share. For more information, see Permission library. | |
string | No | The name of a permission. If you do not configure this parameter, the system automatically associates the default permission for the specified resource type with the resource share. For more information, see Permission library. | AliyunRSDefaultPermissionVSwitch | |
AllowExternalTargets | boolean | No | Specifies whether resources in the resource share can be shared with accounts outside the resource directory. Valid values:
| false |
ResourceGroupId | string | No | The resource group ID. | rg-aekz5nlvlak**** |
TargetProperties | array<object> | No | The properties of the principal. Note
This parameter is available only when you specify an Alibaba Cloud service as a principal.
| |
object | No | |||
Property | string | No | The property parameter of the principal. For example, you can specify a parameter that indicates the time range for resource sharing. Valid values of
Note
TargetProperties.N.TargetId and TargetProperties.N.Property must be used in pairs.
| { "timeRange":{ "timeRangeType":"timeRange", "beginAtTime":"00:00", "timezone":"UTC+8", "endAtTime":"19:59" } } |
TargetId | string | No | The ID of the principal. Note
TargetProperties.N.TargetId and TargetProperties.N.Property must be used in pairs.
| 172050525300**** |
Tag | array<object> | No | The tags. You can specify up to 20 tags. | |
object | No | The tags. | ||
Key | string | No | The tag key. Note
The tag key can be up to 128 characters in length and cannot start with acs: or aliyun . The tag key cannot contain http:// or https:// .
| k1 |
Value | string | No | The tag value. Note
The tag value can be up to 128 characters in length and cannot start with acs: . The tag value cannot contain http:// or https:// .
| v1 |
Response parameters
Examples
Sample success responses
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 |
---|---|---|---|
The ResourceShareName parameter is invalid. | |||
The length of ResourceShareName cannot exceed 50 characters. | |||
The specified shared resource is invalid. | |||
The specified Resources parameter contains duplicate values. | |||
The number of specified shared resources cannot exceed 5. | |||
The specified Targets parameter is invalid. | |||
The specified Targets parameter contains duplicate values. | |||
The number of Targets values cannot exceed 5. | |||
The specified Targets value is not a member in the resource directory. | |||
The specified parameter is invalid. | |||
The ResourceShareName parameter is missing. | |||
The specified ResourceType parameter is invalid. | |||
Duplicate values are specified for the PermissionNames parameter. | |||
The length of the value specified for the PermissionNames parameter exceeds the limit. | |||
The TargetProperties is invalid. | |||
TargetProperties contains duplicate parameters. | |||
The TargetProperties beyond the length limit. | |||
You do not have the required permissions. | |||
You have not enabled sharing with Resource Directory. | |||
The specified Targets value is not a member in the resource directory. | |||
The maximum number of ResourceShare exceeds the limit. | |||
The specified resource share ID already exists. | |||
The maximum number of Resources values per account is exceeded. | |||
You cannot share resources with yourself. | |||
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. | |||
The number of invitations exceeds the upper limit. | |||
The enterprise name of the principal is inconsistent with that of the resource owner. | |||
The resource share contains resources that do not support this operation. | |||
The principal and resource owner are registered at different sites. | |||
- | |||
- |
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|---|---|
View Change Details | ||
View Change Details | ||
View Change Details | ||
View Change Details | ||
View Change Details | ||
View Change Details |