すべてのプロダクト
Search
ドキュメントセンター

:AssociateResourceShare

最終更新日:Feb 26, 2026

共有リソースまたはプリンシパルを共有ユニットに関連付けます。

操作説明

この例では、cn-hangzhou リージョンの Resource Share rs-6GRmdD3X**** に VSwitch vsw-bp183p93qs667muql**** を追加し、リソースディレクトリ内のメンバー 172050525300**** と共有する方法を示します。

今すぐお試しください

この API を OpenAPI Explorer でお試しください。手作業による署名は必要ありません。呼び出しに成功すると、入力したパラメーターに基づき、資格情報が組み込まれた SDK コードが自動的に生成されます。このコードをダウンロードしてローカルで使用できます。

テスト

RAM 認証

下表に、この API を呼び出すために必要な認証情報を示します。認証情報は、RAM (Resource Access Management) ポリシーを使用して定義できます。以下で各列名について説明します。

  • アクション:特定のリソースに対して実行可能な操作。ポリシー構文ではAction要素として指定します。

  • API:アクションを具体的に実行するための API。

  • アクセスレベル:各 API に対して事前定義されているアクセスの種類。有効な値:create、list、get、update、delete。

  • リソースタイプ:アクションが作用するリソースの種類。リソースレベルでの権限をサポートするかどうかを示すことができます。ポリシーの有効性を確保するため、アクションの対象として適切なリソースを指定してください。

    • リソースレベルの権限を持つ API の場合、必要なリソースタイプはアスタリスク (*) でマークされます。ポリシーのResource要素で対応する ARN を指定してください。

    • リソースレベルの権限を持たない API の場合、「すべてのリソース」と表示され、ポリシーのResource要素でアスタリスク (*) でマークされます。

  • 条件キー:サービスによって定義された条件のキー。このキーにより、きめ細やかなアクセス制御が可能になります。この制御は、アクション単体に適用することも、特定のリソースに対するアクションに適用することもできます。Alibaba Cloud は、サービス固有の条件キーに加えて、すべての RAM 統合サービスに適用可能な一連の共通条件キーを提供しています。

  • 依存アクション:ある特定のアクションを実行するために、前提として実行が必要となる他のアクション。依存アクションの権限も RAM ユーザーまたは RAM ロールに付与する必要があります。

アクション

アクセスレベル

リソースタイプ

条件キー

依存アクション

resourcesharing:AssociateResourceShare

update

*All Resource

*

  • resourcesharing:Target
  • resourcesharing:RequestedResourceType
  • resourcesharing:ResourceArn
なし

リクエストパラメーター

パラメーター

必須 / 任意

説明

ResourceShareId

string

必須

共有ユニットの ID です。

rs-6GRmdD3X****

Resources

array<object>

任意

共有ユニットに関連付けるリソースです。

object

任意

関連付けるリソースです。

ResourceType

string

任意

共有リソースのタイプです。

1 回のリクエストで最大 5 つのリソースを指定できます。

サポートされているリソースタイプの一覧については、「リソース共有で利用可能なサービス」をご参照ください。

説明

Resources.N.ResourceId および Resources.N.ResourceType は、必ず同時に指定する必要があります。

VSwitch

ResourceId

string

任意

共有リソースの ID です。

説明

Resources.N.ResourceId および Resources.N.ResourceType は、必ず同時に指定する必要があります。

vsw-bp183p93qs667muql****

Targets

array

任意

共有ユニットに関連付けるプリンシパルです。

172050525300****

string

任意

プリンシパルの ID です。有効な値は、共有ユニットの AllowExternalTargets 設定によって異なります。

  • AllowExternalTargetsfalse に設定されている場合、共有範囲はご利用のリソースディレクトリ内に制限されます。プリンシパルには、リソースディレクトリ、フォルダ、またはメンバーの ID を指定できます。

  • AllowExternalTargetstrue に設定されている場合、任意の Alibaba Cloud アカウントと共有できます。プリンシパルには、Alibaba Cloud アカウント、リソースディレクトリ、フォルダ、メンバー、または Alibaba Cloud サービスの ID を指定できます。

詳細については、「リソース共有の概要」、「リソースディレクトリの ID の確認」、「フォルダの ID の確認」、または「メンバーの ID の確認」をご参照ください。

1 回のリクエストで最大 5 つのプリンシパルを指定できます。

172050525300****

ResourceArns

array

任意

共有リソースの ARN です。

1 回のリクエストで最大 5 つのリソースを指定できます。

string

任意

共有リソースの ARN です。

説明

ARN 形式の詳細については、「リソース共有で利用可能なサービス」をご参照ください。

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

PermissionNames

array

任意

適用する権限の名前です。このパラメーターを省略した場合、システムは自動的にリソースタイプのデフォルト権限を適用します。詳細については、「権限ライブラリ」をご参照ください。

string

任意

権限の名前です。詳細については、「権限ライブラリ」をご参照ください。

AliyunRSDefaultPermissionVSwitch

TargetProperties

array<object>

任意

プリンシパルのプロパティです。

説明

このパラメーターは、プリンシパルが Alibaba Cloud サービスの場合にのみ適用されます。

object

任意

プリンシパルのプロパティです。

TargetId

string

任意

プリンシパルの ID です。

説明

TargetProperties.N.TargetId および TargetProperties.N.Property は、必ず同時に指定する必要があります。

172050525300****

Property

string

任意

プリンシパルのプロパティです。たとえば、リソース共有の期間を指定できます。timeRangeType の有効な値は次のとおりです。

  • timeRange:特定の期間。

  • day:終日。

説明

TargetProperties.N.TargetId および TargetProperties.N.Property は、必ず同時に指定する必要があります。

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

ResourceProperties

array<object>

任意

リソースのプロパティです。

object

任意

リソースのプロパティです。

ResourceArn

string

任意

リソースの ARN です。

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

Property

string

任意

リソースのプロパティです。

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

レスポンスフィールド

フィールド

説明

object

レスポンス本文です。

RequestId

string

リクエストの ID です。

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

ResourceShareAssociations

array<object>

共有ユニットに関連付けられたリソースまたはプリンシパルに関する情報です。

object

共有ユニットに関連付けられたリソースまたはプリンシパルに関する情報です。

UpdateTime

string

関連付けが更新された時刻です。このパラメーターの値は、次のいずれかになります。

  • AssociationTypeResource に設定されている場合、このパラメーターはリソースが更新された時刻を示します。

  • AssociationTypeTarget に設定されている場合、このパラメーターはプリンシパルが更新された時刻を示します。

2020-12-04T09:40:41.246Z

ResourceArn

string

関連付けられたリソースの Alibaba Cloud リソースネーム (ARN) です。

説明

このパラメーターは、AssociationTypeResource に設定されている場合にのみ返されます。

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

ResourceShareName

string

共有ユニットの名前です。

test

CreateTime

string

関連付けが作成された時刻です。このパラメーターの値は、次のいずれかになります。

  • AssociationTypeResource に設定されている場合、このパラメーターはリソースが追加された時刻を示します。

  • AssociationTypeTarget に設定されている場合、このパラメーターはプリンシパルが追加された時刻を示します。

2020-12-04T09:40:41.246Z

EntityType

string

関連付けられたエンティティのタイプです。有効な値は次のとおりです。

  • 関連付けられたエンティティがリソースの場合、値はリソースタイプです。詳細については、「リソース共有で利用可能なサービス」をご参照ください。

  • 関連付けられたエンティティがプリンシパルの場合、値は Account です。

VSwitch

ResourceShareId

string

共有ユニットの ID です。

rs-6GRmdD3X****

AssociationStatusMessage

string

関連付けが失敗した理由です。

The reason for the association failure.

AssociationType

string

関連付けのタイプです。有効な値は次のとおりです。

  • Resource:関連付けられたエンティティはリソースです。

  • Target:関連付けられたエンティティはプリンシパルです。

Resource

AssociationStatus

string

関連付けのステータスです。有効な値は次のとおりです。

  • Associating:関連付けが進行中です。

  • Associated:関連付けが成功しました。

  • Failed:関連付けが失敗しました。

  • Disassociating:関連付け解除が進行中です。

  • Disassociated:関連付け解除が成功しました。

説明

Failed および Disassociated の状態のレコードは、システムにより 48~96 時間以内に自動的に削除されます。

Associating

TargetProperty

string

プリンシパルのプロパティです。たとえば、リソース共有の時間範囲などです。

説明

このパラメーターは、プリンシパルが Alibaba Cloud サービスの場合にのみ返されます。

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

EntityId

string

関連付けられたエンティティの ID です。このパラメーターの値は、次のいずれかになります。

  • AssociationTypeResource に設定されている場合、このパラメーターはリソースの ID を示します。

  • AssociationTypeTarget に設定されている場合、このパラメーターはプリンシパルの ID を示します。

vsw-bp183p93qs667muql****

ResourceProperty

string

リソースのプロパティです。

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

成功レスポンス

JSONJSON

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

エラーコード

HTTP ステータスコード

エラーコード

エラーメッセージ

説明

400 MissingParameter.ResourceShareId You must specify ResourceShareId. You must specify ResourceShareId.
400 InvalidParameter.ResourceShareId The ResourceShareId is invalid. The ResourceShareId is invalid.
400 InvalidParameter.Resources The Resources is invalid. The Resources is invalid.
400 InvalidParameter.Resources.Duplicate The Resources contains duplicate values. The Resources contains duplicate values.
400 InvalidParameter.Resources.Length The maximum number of Resources exceeds 5. The maximum number of Resources exceeds 5.
400 InvalidParameter.Targets The Targets is invalid. The Targets is invalid.
400 InvalidParameter.Targets.Duplicate The Targets contains duplicate values. The Targets contains duplicate values.
400 InvalidParameter.Targets.Length The maximum number of Targets exceeds 5. The maximum number of Targets exceeds 5.
400 InvalidTarget The shared target does not exist in the resource directory. The target you are sharing does not exist in your resource directory.
400 ResourceAndTargetBothEmpty Either a resource or a shared target must be specified. Either a resource or a target must be specified.
400 InvalidParameter The specified parameter is invalid. The specified parameter is invalid.
400 InvalidParameter.ResourceType The ResourceType is invalid. 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. 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. 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. 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. The maximum number of shared resources per account exceeds the limit.
409 ShareWithYourself You cannot share resources with yourself. You cannot share resources with yourself.
409 AssociateConflict You cannot perform the operation while disassociation operation is being performed. You cannot perform the operation while disassociation is in progress.
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.

完全なリストについては、「エラーコード」をご参照ください。

変更履歴

完全なリストについては、「変更履歴」をご参照ください。