All Products
Search
Document Center

Resource Management:AssociateResourceShare

Last Updated:Jun 10, 2026

Mengaitkan resource yang dibagikan atau pihak yang berwenang dengan Bagian Sumber Daya.

Deskripsi operasi

This example shows how to add the VSwitch vsw-bp183p93qs667muql**** to the Resource Share rs-6GRmdD3X**** in the cn-hangzhou Region and share it with Member 172050525300**** within a resource directory.

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 Bagian Sumber Daya.

rs-6GRmdD3X****

Resources

array<object>

No

Resource yang akan dikaitkan dengan Bagian Sumber Daya.

object

No

A resource to associate.

ResourceType

string

No

The type of the shared resource.

You can specify up to five resources in a single request.

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

Catatan

Resources.N.ResourceId and Resources.N.ResourceType must be specified together.

VSwitch

ResourceId

string

No

The ID of the shared resource.

Catatan

Resources.N.ResourceId and Resources.N.ResourceType must be specified together.

vsw-bp183p93qs667muql****

Targets

array

No

Pihak yang berwenang yang akan dikaitkan dengan Bagian Sumber Daya.

172050525300****

string

No

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

  • If AllowExternalTargets is set to false, sharing is restricted to your Resource Directory. The principal can be the ID of the Resource Directory, a Folder, or a member.

  • If AllowExternalTargets is set to true, you can share with any Alibaba Cloud account. The principal 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 Resource Sharing overview, View the ID of a resource directory, View the ID of a folder, or View the ID of a member.

You can specify up to five principals in a single request.

172050525300****

ResourceArns

array

No

ARN Resource yang dibagikan.

Anda dapat menentukan hingga lima Sumber daya dalam satu permintaan.

string

No

The ARN of the shared resource.

Catatan

For details on the ARN format, see Services that work with Resource Sharing.

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

PermissionNames

array

No

Nama izin yang akan diterapkan. Jika parameter ini dihilangkan, sistem secara otomatis menerapkan izin default untuk tipe Sumber daya. Untuk informasi selengkapnya, lihat Pustaka izin.

string

No

The name of a permission. For more information, see Permission library.

AliyunRSDefaultPermissionVSwitch

TargetProperties

array<object>

No

Properti pihak yang berwenang.

Catatan

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

object

No

The properties for a principal.

TargetId

string

No

The ID of the principal.

Catatan

TargetProperties.N.TargetId and TargetProperties.N.Property must be specified together.

172050525300****

Property

string

No

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

  • timeRange: a specific period of time.

  • day: an entire day.

Catatan

TargetProperties.N.TargetId and TargetProperties.N.Property must be specified together.

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

ResourceProperties

array<object>

No

Properti Sumber daya.

object

No

The properties of a resource.

ResourceArn

string

No

The ARN of the resource.

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

Property

string

No

The property of the resource.

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

Elemen respons

Element

Type

Description

Example

object

The response body.

RequestId

string

The ID of the request.

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

ResourceShareAssociations

array<object>

The information about the resources or principals that are associated with the resource share.

object

The information about a resource or principal that is associated with the resource share.

UpdateTime

string

The time when the association was updated. This parameter can be one of the following values:

  • If AssociationType is set to Resource, this parameter indicates the time when the resource was updated.

  • If AssociationType is set to Target, this parameter indicates the time when the principal was updated.

2020-12-04T09:40:41.246Z

ResourceArn

string

The Alibaba Cloud Resource Name (ARN) of the associated resource.

Catatan

This parameter is returned only when AssociationType is set to Resource.

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

ResourceShareName

string

The name of the resource share.

test

CreateTime

string

The time when the association was created. This parameter can be one of the following values:

  • If AssociationType is set to Resource, this parameter indicates the time when the resource was added.

  • If AssociationType is set to Target, this parameter indicates the time when the principal was added.

2020-12-04T09:40:41.246Z

EntityType

string

The type of the associated entity. Valid values:

  • If the associated entity is a resource, the value is the resource type. For more information, see Services that work with Resource Sharing.

  • If the associated entity is a principal, the value is Account.

VSwitch

ResourceShareId

string

The ID of the resource share.

rs-6GRmdD3X****

AssociationStatusMessage

string

The reason why the association failed.

The reason for the association failure.

AssociationType

string

Target

Resource

AssociationStatus

string

Disassociated

Associating

TargetProperty

string

The properties of the principal. For example, the time range for resource sharing.

Catatan

This parameter is returned only if the principal is an Alibaba Cloud service.

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

EntityId

string

The ID of the associated entity. This parameter can be one of the following values:

  • If AssociationType is set to Resource, this parameter indicates the ID of the resource.

  • If AssociationType is set to Target, this parameter indicates the ID of the principal.

vsw-bp183p93qs667muql****

ResourceProperty

string

The properties of the resource.

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