All Products
Search
Document Center

Resource Management:CreateResourceShare

Last Updated:Jun 10, 2026

Membuat bagian sumber daya.

Deskripsi operasi

Alibaba Cloud Resource Sharing lets you share resources from your account with one or more Principals. For more information, see Resource Sharing overview.

This example shows how to use the management account of a Resource Directory to create a resource share named test in the cn-hangzhou region and share the vSwitch vsw-bp183p93qs667muql**** with member 172050525300****.

Coba sekarang

Coba API ini di OpenAPI Explorer tanpa perlu penandatanganan manual. Panggilan yang berhasil akan secara otomatis menghasilkan contoh kode SDK sesuai dengan parameter Anda. Unduh kode tersebut dengan kredensial bawaan yang aman untuk penggunaan lokal.

Test

RAM authorization

Tabel berikut menjelaskan otorisasi yang diperlukan untuk memanggil API ini. Anda dapat menentukannya dalam kebijakan Resource Access Management (RAM). Kolom pada tabel dijelaskan sebagai berikut:

  • Action: Aksi yang dapat digunakan dalam elemen Action pada pernyataan kebijakan izin RAM untuk memberikan izin guna melakukan operasi tersebut.

  • API: API yang dapat Anda panggil untuk melakukan aksi tersebut.

  • Access level: Tingkat akses yang telah ditentukan untuk setiap API. Nilai yang valid: create, list, get, update, dan delete.

  • Resource type: Jenis resource yang mendukung otorisasi untuk melakukan aksi tersebut. Ini menunjukkan apakah aksi tersebut mendukung izin tingkat resource. Resource yang ditentukan harus kompatibel dengan aksi tersebut. Jika tidak, kebijakan tersebut tidak akan berlaku.

    • Untuk API dengan izin tingkat resource, jenis resource yang diperlukan ditandai dengan tanda bintang (*). Tentukan Nama Sumber Daya Alibaba Cloud (ARN) yang sesuai dalam elemen Resource pada kebijakan.

    • Untuk API tanpa izin tingkat resource, ditampilkan sebagai All Resources. Gunakan tanda bintang (*) dalam elemen Resource pada kebijakan.

  • Condition key: Kunci kondisi yang didefinisikan oleh layanan. Kunci ini memungkinkan kontrol granular, berlaku baik hanya untuk aksi maupun untuk aksi yang terkait dengan resource tertentu. Selain kunci kondisi spesifik layanan, Alibaba Cloud menyediakan serangkaian common condition keys yang berlaku di semua layanan yang didukung RAM.

  • Dependent action: Aksi dependen yang diperlukan untuk menjalankan aksi tersebut. Untuk menyelesaikan aksi tersebut, pengguna RAM atau role RAM harus memiliki izin untuk melakukan semua aksi dependen.

Action

Access level

Resource type

Condition key

Dependent action

resourcesharing:CreateResourceShare

create

*全部资源

*

  • resourcesharing:RequestedAllowExternalTargets
  • resourcesharing:Target
  • resourcesharing:RequestedResourceType
  • resourcesharing:ResourceArn
None

Parameter permintaan

Parameter

Type

Required

Description

Example

ResourceShareName

string

Yes

Nama bagian sumber daya.

Panjang nama harus 1 hingga 50 karakter.

Dapat berisi huruf, angka, titik (.), garis bawah (_), dan tanda hubung (-).

test

Resources

array<object>

No

Daftar Resource yang dibagikan.

object

No

A shared resource.

ResourceId

string

No

The ID of the shared resource.

You can add up to five shared resources at a time.

Catatan

Specify the Resources.N.ResourceId and Resources.N.ResourceType parameters in pairs.

vsw-bp183p93qs667muql****

ResourceType

string

No

The type of the shared resource.

You can add up to five shared resources at a time.

For a list of supported resource types, see Services that work with Resource Sharing.

Catatan

Specify the Resources.N.ResourceId and Resources.N.ResourceType parameters in pairs.

VSwitch

Targets

array

No

Daftar pihak yang berwenang.

172050525300****

string

No

The ID of a principal. Valid values depend on the setting of AllowExternalTargets:

  • If AllowExternalTargets is set to false, the value can be the ID of a Resource Directory, a Folder, or a Member.

  • If AllowExternalTargets is set to true, the value can be the ID of an Alibaba Cloud Account, a Resource Directory, a Folder, a Member, or an Alibaba Cloud service.

For more information, see Methods used to share resources, View the ID of a resource directory, View the ID of a folder, or View the ID of a member.

You can add up to five principals at a time.

172050525300****

ResourceArns

array

No

Nama Sumber Daya Alibaba Cloud (ARN) Resource yang dibagikan.

Anda dapat menambahkan hingga lima Resource yang dibagikan sekaligus.

string

No

The ARN of the shared resource.

Catatan

For the format of a resource ARN, see Services that work with Resource Sharing.

acs:vpc:cn-shanghai:103755469187****:vswitch/vsw-uf62b11ue4m8oz2di****

PermissionNames

array

No

Nama izin. Jika tidak ditentukan, sistem akan melampirkan izin default untuk tipe Sumber daya. Untuk detail, lihat Permission Library.

string

No

The name of the permission. If unspecified, the system attaches the default permission for the resource type. For details, see Permission Library.

AliyunRSDefaultPermissionVSwitch

AllowExternalTargets

boolean

No

Apakah akan mengizinkan berbagi dengan akun di luar direktori sumber daya Anda. Nilai valid:

  • false (default): Resource hanya dapat dibagikan dengan akun di dalam direktori sumber daya Anda.

  • true: Resource dapat dibagikan dengan akun Alibaba Cloud mana pun.

false

ResourceGroupId

string

No

ID kelompok sumber daya.

rg-aekz5nlvlak****

TargetProperties

array<object>

No

Properti pihak yang berwenang.

Catatan

Parameter ini hanya tersedia ketika pihak yang berwenang adalah layanan Alibaba Cloud.

object

No

The properties of the principal.

Catatan

This parameter is available only when the principal is an Alibaba Cloud service.

Property

string

No

The property of the principal. For example, you can specify a time range for resource sharing. Valid values for timeRangeType:

  • timeRange: a specified time range.

  • day: the entire day.

Catatan

Specify the TargetProperties.N.TargetId and TargetProperties.N.Property parameters in pairs.

{ "timeRange":{ "timeRangeType":"timeRange", "beginAtTime":"00:00", "timezone":"UTC+8", "endAtTime":"19:59" } }

TargetId

string

No

The ID of the principal.

Catatan

Specify the TargetProperties.N.TargetId and TargetProperties.N.Property parameters in pairs.

172050525300****

ResourceProperties

array<object>

No

Daftar properti Sumber daya.

object

No

A resource property.

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

Tag bagian sumber daya. Anda dapat menambahkan maksimum 20 tag.

object

No

A tag.

Key

string

No

The tag key.

Catatan

The tag key can be up to 128 characters in length. It cannot start with aliyun or acs:, and cannot contain http:// or https://.

k1

Value

string

No

The tag value.

Catatan

The tag value can be up to 128 characters in length. It cannot start with acs: and cannot contain http:// or https://.

v1

Elemen respons

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 accounts outside the resource directory are allowed to access the shared resources. Valid values:

  • false: Sharing with accounts outside the resource directory is not allowed.

  • true: Sharing with any account is allowed.

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:

  • Active: The resource share is enabled.

  • Pending: The resource share is waiting for the invitee to confirm the invitation.

  • Deleting: The resource share is being deleted.

  • Deleted: The resource share is deleted.

Catatan

A resource share in the Deleted state is automatically removed by the system within 48 to 96 hours.

Active

UpdateTime

string

The time when the resource share was last updated.

2020-12-03T08:02:22.413Z

Contoh

Respons sukses

JSONformat

{
  "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"
  }
}

Kode kesalahan

HTTP status code

Error code

Error message

Description

400 InvalidParameter.ResourceShareName The ResourceShareName is invalid.
400 InvalidParameter.ResourceShareName.Length The maximum length of ResourceShareName exceeds 50 characters.
400 InvalidParameter.Resources The Resources is invalid.
400 InvalidParameter.Resources.Duplicate The Resources contains duplicate values.
400 InvalidParameter.Resources.Length The maximum number of Resources exceeds 5.
400 InvalidParameter.Targets The Targets is invalid.
400 InvalidParameter.Targets.Duplicate The Targets contains duplicate values.
400 InvalidParameter.Targets.Length The maximum number of Targets exceeds 5.
400 InvalidTarget The shared target does not exist in the resource directory.
400 InvalidParameter The specified parameter is invalid.
400 MissingParameter.ResourceShareName You must specify ResourceShareName.
400 InvalidParameter.ResourceType The ResourceType is invalid.
400 InvalidParameter.PermissionNames.Duplicate The PermissionNames duplicate values.
400 InvalidParameter.PermissionNames.Length The maximum length of PermissionNames exceeds quota limit.
400 InvalidParameter.TargetProperties The TargetProperties is invalid.
400 InvalidParameter.TargetProperties.Duplicate The TargetProperties contains duplicate values.
400 InvalidParameter.TargetProperties.Length The TargetProperties beyond the length limit.
400 InvalidParameter.ResourceArns The ResourceArns is invalid.
400 InvalidParameter.ResourceArns.Duplicate The ResourceArns contains duplicate values.
400 InvalidParameter.ResourceArns.Length The ResourceArns beyond the length limit.
400 InvalidParameter.ResourceConflict 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.
400 InvalidParameter.ResourceProperties The ResourceProperties is invalid.
400 InvalidParameter.ResourceProperties.Duplicate The ResourceProperties contains duplicate values.
400 InvalidParameter.ResourceProperties.Length The ResourceProperties beyond the length limit.
400 NotSupport.ResourceProperty The resource type does not support resource property.
404 EntityNotExists.Permission The resource share permission does not exist.
409 NotEnableSharingWithResourceDirectory You have not enabled sharing with your Resource Directory.
409 AccountNotInResourceDirectory The account is not a master or a member of a resource directory.
409 QuotaExceeded.ResourceShare.Count The maximum number of ResourceShare exceeds the limit.
409 EntityAlreadyExists.ResourceShare The specified resource share ID already exists.
409 QuotaExceeded.SharedResource.Count The maximum number of shared resources per account exceeds the limit.
409 ShareWithYourself You cannot share resources with yourself.
409 NotManagementAccount Only the management account of the service is allowed to share such resources.
409 QuotaExceeded.PendingInvitations The maximum number of pending invitations exceeds the limit.
409 InvalidTarget.LegalEntityMismatch The target account does not have the same legal entity as the resource owner account.
409 ExternalTargetsNotAllowed.ResourceType The resource share includes resource types that cannot be shared with accounts outside the resource directory.
409 InvalidTarget.SiteMismatch Cross-site resource sharing is not supported.
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.

Lihat Error Codes untuk daftar lengkap.

Catatan rilis

Lihat Release Notes untuk daftar lengkap.