全部产品
Search
文档中心

Resource Management:AssociateResourceShare

更新时间:Jan 21, 2026

Mengasosiasikan resource atau principal dengan sebuah resource share.

Deskripsi operasi

Contoh ini menunjukkan cara menambahkan vSwitch vsw-bp183p93qs667muql**** ke resource share rs-6GRmdD3X**** di wilayah cn-hangzhou dan membagikannya dengan anggota 172050525300**** dari ResourceDirectory.

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:AssociateResourceShare

update

*全部资源

*

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

Parameter permintaan

Parameter

Type

Required

Description

Example

ResourceShareId

string

Yes

ID dari resource share.

rs-6GRmdD3X****

Resources

array<object>

No

Resource yang dibagikan.

object

No

Resource yang akan diasosiasikan dengan resource share.

ResourceType

string

No

Tipe dari resource yang dibagikan.

Anda dapat menambahkan maksimal lima resource yang dibagikan sekaligus.

Untuk informasi lebih lanjut mengenai tipe resource yang dapat dibagikan, lihat Layanan yang kompatibel dengan Resource Sharing.

Catatan

Tentukan Resources.N.ResourceId dan Resources.N.ResourceType secara berpasangan.

VSwitch

ResourceId

string

No

ID dari resource yang dibagikan.

Anda dapat menambahkan maksimal lima resource yang dibagikan sekaligus.

Catatan

Tentukan Resources.N.ResourceId dan Resources.N.ResourceType secara berpasangan.

vsw-bp183p93qs667muql****

Targets

array

No

Pihak yang berwenang.

172050525300****

string

No

Principal. Nilai yang valid:

  • Jika AllowExternalTargets diatur ke false, resource hanya dapat dibagikan dalam satu resource directory. Principal dapat berupa ID resource directory, folder, atau anggota.

  • Jika AllowExternalTargets diatur ke true, resource dapat dibagikan ke akun mana pun. Principal dapat berupa ID Akun Alibaba Cloud, resource directory, folder, anggota, atau layanan Alibaba Cloud.

Untuk informasi lebih lanjut, lihat Metode berbagi resource, Lihat ID resource directory, Lihat ID folder, atau Lihat ID anggota.

Anda dapat menambahkan maksimal lima principal sekaligus.

172050525300****

ResourceArns

array

No

Nama Sumber Daya Alibaba Cloud (ARN) dari resource yang dibagikan.

Anda dapat menentukan maksimal lima ARN sekaligus.

string

No

ARN dari resource yang dibagikan.

Catatan

Untuk informasi lebih lanjut mengenai format ARN, lihat Layanan yang kompatibel dengan Resource Sharing.

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

PermissionNames

array

No

Nama izin. Jika Anda tidak menentukan parameter ini, sistem secara otomatis mengasosiasikan izin default dengan tipe resource tersebut. Untuk informasi lebih lanjut, lihat Pustaka izin.

string

No

Nama izin. Jika Anda tidak menentukan parameter ini, sistem secara otomatis mengasosiasikan izin default dengan tipe resource tersebut. Untuk informasi lebih lanjut, lihat Pustaka izin.

AliyunRSDefaultPermissionVSwitch

TargetProperties

array<object>

No

Properti dari principal.

Catatan

Anda hanya dapat menentukan parameter ini ketika principal adalah layanan Alibaba Cloud.

object

No

Properti dari principal.

Catatan

Anda hanya dapat menentukan parameter ini ketika principal adalah layanan Alibaba Cloud.

TargetId

string

No

ID dari principal.

Catatan

Tentukan TargetProperties.N.TargetId dan TargetProperties.N.Property secara berpasangan.

172050525300****

Property

string

No

Properti dari principal. Misalnya, Anda dapat menentukan rentang waktu untuk berbagi resource. Nilai yang valid untuk timeRangeType:

  • timeRange: rentang waktu tertentu.

  • day: sepanjang hari.

Catatan

Tentukan TargetProperties.N.TargetId dan TargetProperties.N.Property secara berpasangan.

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

Elemen respons

Element

Type

Description

Example

object

Data yang dikembalikan.

RequestId

string

ID dari permintaan.

111FB84A-60A9-403E-9067-E55D7EE95BD1

ResourceShareAssociations

array<object>

Informasi mengenai resource atau principal yang diasosiasikan dengan resource share.

object

Informasi mengenai resource atau principal yang diasosiasikan dengan resource share.

UpdateTime

string

Waktu saat asosiasi diperbarui.

  • Jika AssociationType adalah Resource, parameter ini menunjukkan waktu saat resource diperbarui.

  • Jika AssociationType adalah Target, parameter ini menunjukkan waktu saat principal diperbarui.

2020-12-04T09:40:41.246Z

ResourceArn

string

ARN dari resource yang diasosiasikan.

Catatan

Parameter ini tidak dikembalikan jika AssociationType adalah Target.

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

ResourceShareName

string

Nama dari resource share.

test

CreateTime

string

Waktu saat asosiasi dibuat.

  • Jika AssociationType adalah Resource, parameter ini menunjukkan waktu saat resource diasosiasikan.

  • Jika AssociationType adalah Target, parameter ini menunjukkan waktu saat principal diasosiasikan.

2020-12-04T09:40:41.246Z

EntityType

string

Tipe entitas yang diasosiasikan. Nilai yang valid:

VSwitch

ResourceShareId

string

ID dari resource share.

rs-6GRmdD3X****

AssociationStatusMessage

string

Alasan mengapa asosiasi gagal.

The reason for the association failure.

AssociationType

string

Tipe asosiasi. Nilai yang valid:

  • Resource: resource.

  • Target: principal.

Resource

AssociationStatus

string

Status asosiasi. Nilai yang valid:

  • Associating: Asosiasi sedang dibuat.

  • Associated: Asosiasi berhasil dibuat.

  • Failed: Asosiasi gagal.

  • Disassociating: Proses pembatalan asosiasi sedang berlangsung.

  • Disassociated: Entitas telah dibatalkan asosiasinya.

Catatan

Sistem secara otomatis menghapus catatan dengan status Failed dan Disassociated dalam waktu 48 hingga 96 jam.

Associating

TargetProperty

string

Properti dari principal. Misalnya, rentang waktu untuk berbagi resource.

Catatan

Parameter ini hanya dikembalikan ketika principal adalah layanan Alibaba Cloud.

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

EntityId

string

ID dari entitas yang diasosiasikan. Nilai yang valid:

  • Jika AssociationType adalah Resource, nilai parameter ini adalah ID dari resource tersebut.

  • Jika AssociationType adalah Target, nilai parameter ini adalah ID dari principal tersebut.

vsw-bp183p93qs667muql****

ResourceProperty

string

{"sharePrincipals":true,"shareTagOptions":false}

Contoh

Respons sukses

JSONformat

{
  "RequestId": "111FB84A-60A9-403E-9067-E55D7EE95BD1",
  "ResourceShareAssociations": [
    {
      "UpdateTime": "2020-12-04T09:40:41.246Z",
      "ResourceArn": "acs:vpc:cn-shanghai:103755469187****:vswitch/vsw-uf62b11ue4m8oz2di****",
      "ResourceShareName": "test",
      "CreateTime": "2020-12-04T09:40:41.246Z",
      "EntityType": "VSwitch",
      "ResourceShareId": "rs-6GRmdD3X****",
      "AssociationStatusMessage": "The reason for the association failure.",
      "AssociationType": "Resource",
      "AssociationStatus": "Associating",
      "TargetProperty": "{\n    \"plan\":{\n        \"timeRangeType\":\"timeRange\",\n        \"beginAtTime\":\"00:00\",\n        \"timezone\":\"UTC+8\",\n        \"endAtTime\":\"19:59\"\n    }\n}",
      "EntityId": "vsw-bp183p93qs667muql****",
      "ResourceProperty": "{\"sharePrincipals\":true,\"shareTagOptions\":false}"
    }
  ]
}

Kode kesalahan

HTTP status code

Error code

Error message

Description

400 MissingParameter.ResourceShareId You must specify ResourceShareId.
400 InvalidParameter.ResourceShareId The ResourceShareId is invalid.
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 ResourceAndTargetBothEmpty Either a resource or a shared target must be specified.
400 InvalidParameter The specified parameter is invalid.
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.ResourceShare The resource share does not exist in the current account.
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 ResourceShareStatusMismatchAction The status of the resource share does not allow the specified operation.
409 QuotaExceeded.SharedResource.Count The maximum number of shared resources per account exceeds the limit.
409 ShareWithYourself You cannot share resources with yourself.
409 AssociateConflict You cannot perform the operation while disassociation operation is being performed.
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.
409 NotSupport.ResourcePropertyConflict The ResourceProperty can not be updated until the last operation is completed.

Lihat Error Codes untuk daftar lengkap.

Catatan rilis

Lihat Release Notes untuk daftar lengkap.