Todos los productos
Search
Centro de documentos

Resource Management:AssociateResourceShare

Última actualización: Sep 01, 2026

Asocia recursos compartidos o principales con un recurso compartido.

Descripción de la operación

Este ejemplo muestra cómo agregar el VSwitch vsw-bp183p93qs667muql**** al recurso compartido rs-6GRmdD3X**** en la región cn-hangzhou y compartirlo con el miembro 172050525300**** dentro de un directorio de recursos.

Pruébelo ahora

Pruebe esta API en OpenAPI Explorer sin necesidad de firma manual. Las llamadas exitosas generan automáticamente código SDK acorde a sus parámetros. Descárguelo con seguridad de credenciales integrada para uso local.

Test

Autorización de RAM

La siguiente tabla describe la autorización necesaria para invocar esta API. Puede definirla en una directiva de Resource Access Management (RAM). A continuación, se detallan las columnas de la tabla:

  • Action: Estas acciones se utilizan en el elemento Action de las declaraciones de directivas de permisos de RAM para otorgar permisos que permitan realizar la operación.

  • API: La API que debe invocarse para llevar a cabo la acción.

  • Nivel de acceso: Nivel de acceso predefinido que se concede para cada API. Valores válidos: create, list, get, update y delete.

  • Tipo de recurso: Tipo de recurso que admite autorización para ejecutar la acción. Indica si la acción es compatible con permisos a nivel de recurso. El recurso especificado debe ser compatible con la acción; de lo contrario, la directiva no surtirá efecto.

    • En las API con permisos a nivel de recurso, los tipos de recursos obligatorios se marcan con un asterisco (*). Especifique el Alibaba Cloud Resource Name (ARN) correspondiente en el elemento Resource de la directiva.

    • Para las API sin permisos a nivel de recurso, se muestra All Resources. Utilice un asterisco (*) en el elemento Resource de la directiva.

  • Clave de condición: Claves de condición definidas por el servicio. Permiten un control granular y se aplican ya sea solo a acciones o a acciones asociadas con recursos específicos. Además de las claves de condición específicas del servicio, Alibaba Cloud proporciona un conjunto de common condition keys aplicables a todos los servicios compatibles con RAM.

  • Acción dependiente: Acciones dependientes necesarias para ejecutar la acción principal. Para completar la operación, el usuario de RAM o el rol de RAM debe contar con permisos para realizar todas las acciones dependientes.

Action

Nivel de acceso

Tipo de recurso

Clave de condición

Acción dependiente

resourcesharing:AssociateResourceShare

update

*All Resource

*

  • resourcesharing:Target
  • resourcesharing:RequestedResourceType
  • resourcesharing:ResourceArn
Ninguna

Parámetros de la solicitud

Parámetro

Tipo

Obligatorio

Descripción

Ejemplo

ResourceShareId

string

Sí

El ID del recurso compartido.

rs-6GRmdD3X****

Resources

array<object>

No

Los recursos que se van a asociar con el recurso compartido.

object

No

Un recurso para asociar.

ResourceType

string

No

El tipo del recurso compartido.

Puede especificar hasta cinco recursos en una sola solicitud.

Para obtener una lista de los tipos de recursos compatibles, consulte Servicios compatibles con Resource Sharing.

Nota

Resources.N.ResourceId y Resources.N.ResourceType deben especificarse juntos.

VSwitch

ResourceId

string

No

El ID del recurso compartido.

Nota

Resources.N.ResourceId y Resources.N.ResourceType deben especificarse juntos.

vsw-bp183p93qs667muql****

Targets

array

No

Los principales que se van a asociar con el recurso compartido.

172050525300****

string

No

El ID de un principal. Los valores válidos dependen de la configuración AllowExternalTargets del recurso compartido:

  • Si AllowExternalTargets se establece en false, el uso compartido se restringe a su directorio de recursos. El principal puede ser el ID del directorio de recursos, una carpeta o un miembro.

  • Si AllowExternalTargets se establece en true, puede compartir con cualquier cuenta de Alibaba Cloud. El principal puede ser el ID de una cuenta de Alibaba Cloud, un directorio de recursos, una carpeta, un miembro o un servicio de Alibaba Cloud.

Para obtener más información, consulte Descripción general de Resource Sharing, Ver el ID de un directorio de recursos, Ver el ID de una carpeta o Ver el ID de un miembro.

Puede especificar hasta cinco principales en una sola solicitud.

172050525300****

ResourceArns

array

No

Los ARN de los recursos compartidos.

Puede especificar hasta cinco recursos en una sola solicitud.

string

No

El ARN del recurso compartido.

Nota

Para obtener detalles sobre el formato de ARN, consulte Servicios compatibles con Resource Sharing.

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

PermissionNames

array

No

Los nombres de los permisos que se van a aplicar. Si se omite este parámetro, el sistema aplica automáticamente el permiso predeterminado para el tipo de recurso. Para obtener más información, consulte Biblioteca de permisos.

string

No

El nombre de un permiso. Para obtener más información, consulte Biblioteca de permisos.

AliyunRSDefaultPermissionVSwitch

TargetProperties

array<object>

No

Las propiedades de los principales.

Nota

Este parámetro se aplica solo cuando un principal es un servicio de Alibaba Cloud.

object

No

Las propiedades de un principal.

TargetId

string

No

El ID del principal.

Nota

TargetProperties.N.TargetId y TargetProperties.N.Property deben especificarse juntos.

172050525300****

Property

string

No

La propiedad del principal. Por ejemplo, puede especificar el período de tiempo para el uso compartido de recursos. Los valores válidos para timeRangeType son:

  • timeRange: un período de tiempo específico.

  • day: un día completo.

Nota

TargetProperties.N.TargetId y TargetProperties.N.Property deben especificarse juntos.

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

ResourceProperties

array<object>

No

Las propiedades de los recursos.

object

No

Las propiedades de un recurso.

ResourceArn

string

No

El ARN del recurso.

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

Property

string

No

La propiedad del recurso.

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

Elementos de la respuesta

Elemento

Tipo

Descripción

Ejemplo

object

El cuerpo de la respuesta.

RequestId

string

El ID de la solicitud.

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

ResourceShareAssociations

array<object>

La información sobre los recursos o principales asociados con el recurso compartido.

object

La información sobre un recurso o principal asociado con el recurso compartido.

UpdateTime

string

La hora en que se actualizó la asociación. Este parámetro puede tener uno de los siguientes valores:

  • Si AssociationType se establece en Resource, este parámetro indica la hora en que se actualizó el recurso.

  • Si AssociationType se establece en Target, este parámetro indica la hora en que se actualizó el principal.

2020-12-04T09:40:41.246Z

ResourceArn

string

El nombre de recurso de Alibaba Cloud (ARN) del recurso asociado.

Nota

Este parámetro se devuelve solo cuando AssociationType se establece en Resource.

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

ResourceShareName

string

El nombre del recurso compartido.

test

CreateTime

string

La hora en que se creó la asociación. Este parámetro puede tener uno de los siguientes valores:

  • Si AssociationType se establece en Resource, este parámetro indica la hora en que se agregó el recurso.

  • Si AssociationType se establece en Target, este parámetro indica la hora en que se agregó el principal.

2020-12-04T09:40:41.246Z

EntityType

string

El tipo de la entidad asociada. Valores válidos:

  • Si la entidad asociada es un recurso, el valor es el tipo de recurso. Para obtener más información, consulte Servicios compatibles con Resource Sharing.

  • Si la entidad asociada es un principal, el valor es Account.

VSwitch

ResourceShareId

string

El ID del recurso compartido.

rs-6GRmdD3X****

AssociationStatusMessage

string

El motivo por el cual falló la asociación.

The reason for the association failure

AssociationType

string

Target.

Resource

AssociationStatus

string

Disassociated.

Associating

TargetProperty

string

Las propiedades del principal. Por ejemplo, el intervalo de tiempo para el uso compartido de recursos.

Nota

Este parámetro se devuelve solo si el principal es un servicio de Alibaba Cloud.

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

EntityId

string

El ID de la entidad asociada. Este parámetro puede tener uno de los siguientes valores:

  • Si AssociationType se establece en Resource, este parámetro indica el ID del recurso.

  • Si AssociationType se establece en Target, este parámetro indica el ID del principal.

vsw-bp183p93qs667muql****

ResourceProperty

string

Las propiedades del recurso.

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

Ejemplos

Respuesta exitosa

JSON Formato

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

Códigos de error

Código de estado HTTP

Código de error

Mensaje de error

Descripción

400 MissingParameter.ResourceShareId You must specify ResourceShareId. You must specify ResourceShareId.
400 InvalidParameter.ResourceShareId The ResourceShareId is invalid. The ResourceShareId parameter is invalid.
400 InvalidParameter.Resources The Resources is invalid. The specified shared resource is invalid.
400 InvalidParameter.Resources.Duplicate The Resources contains duplicate values. The specified Resources parameter contains duplicate values.
400 InvalidParameter.Resources.Length The maximum number of Resources exceeds 5. The number of specified shared resources cannot exceed 5.
400 InvalidParameter.Targets The Targets is invalid. The specified Targets parameter is invalid.
400 InvalidParameter.Targets.Duplicate The Targets contains duplicate values. The specified Targets parameter contains duplicate values.
400 InvalidParameter.Targets.Length The maximum number of Targets exceeds 5. The number of Targets values cannot exceed 5.
400 InvalidTarget The shared target does not exist in the resource directory. The specified Targets value is not a member in the resource directory.
400 ResourceAndTargetBothEmpty Either a resource or a shared target must be specified. You must specify a resource or a resource account.
400 InvalidParameter The specified parameter is invalid. The specified parameter is invalid.
400 InvalidParameter.ResourceType The ResourceType is invalid. The specified ResourceType parameter is invalid.
400 InvalidParameter.PermissionNames.Duplicate The PermissionNames duplicate values. Duplicate values are specified for the PermissionNames parameter.
400 InvalidParameter.PermissionNames.Length The maximum length of PermissionNames exceeds quota limit. The length of the value specified for the PermissionNames parameter exceeds the limit.
400 InvalidParameter.TargetProperties The TargetProperties is invalid. The TargetProperties is invalid.
400 InvalidParameter.TargetProperties.Duplicate The TargetProperties contains duplicate values. TargetProperties contains duplicate parameters.
400 InvalidParameter.TargetProperties.Length The TargetProperties beyond the length limit. The TargetProperties beyond the length limit.
400 InvalidParameter.ResourceArns The ResourceArns is invalid. The ResourceArns parameter is invalid.
400 InvalidParameter.ResourceArns.Duplicate The ResourceArns contains duplicate values. The ResourceArns contains duplicate values.
400 InvalidParameter.ResourceArns.Length The ResourceArns beyond the length limit. The maximum number of ResourceArns exceeds 5.
400 InvalidParameter.ResourceConflict Both Resources and ResourceArns cannot be specified simultaneously. Please provide only one of these parameters. 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. The Resources parameter does not support this resource type. Please use ResourceArns instead.
400 InvalidParameter.ResourceProperties The ResourceProperties is invalid. The ResourceProperties is invalid.
400 InvalidParameter.ResourceProperties.Duplicate The ResourceProperties contains duplicate values. The ResourceProperties contains duplicate values.
400 InvalidParameter.ResourceProperties.Length The ResourceProperties beyond the length limit. The ResourceProperties beyond the length limit.
400 NotSupport.ResourceProperty The resource type does not support resource property. 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. You do not have the required permissions.
409 NotEnableSharingWithResourceDirectory You have not enabled sharing with your Resource Directory. You have not enabled sharing with Resource Directory.
409 AccountNotInResourceDirectory The account is not a master or a member of a resource directory. The specified Targets value is not a member in the 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 Resources values per account is exceeded.
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. The association operation is not supported while an disassociation is being performed.
409 NotManagementAccount Only the management account of the service is allowed to share such resources. 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.
409 QuotaExceeded.PendingInvitations The maximum number of pending invitations exceeds the limit. The number of invitations exceeds the upper limit.
409 InvalidTarget.LegalEntityMismatch The target account does not have the same legal entity as the resource owner account. The enterprise name of the principal is inconsistent with that of the resource owner.
409 ExternalTargetsNotAllowed.ResourceType The resource share includes resource types that cannot be shared with accounts outside the resource directory. The resource share contains resources that do not support this operation.
409 InvalidTarget.SiteMismatch Cross-site resource sharing is not supported. The principal and resource owner are registered at different sites.
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. The ResourceProperty can not be updated until the last operation is completed.

Consulte Códigos de error para ver la lista completa.

Notas de la versión

Consulte Notas de la versión para ver la lista completa.