associateResource method

Future<AssociateResourceResponse> associateResource({
  1. required String application,
  2. required String resource,
  3. required ResourceType resourceType,
  4. List<AssociationOption>? options,
})

Associates a resource with an application. The resource can be specified by its ARN or name. The application can be specified by ARN, ID, or name.

Minimum permissions

You must have the following permissions to associate a resource using the OPTIONS parameter set to APPLY_APPLICATION_TAG.

  • tag:GetResources
  • tag:TagResources
You must also have these additional permissions if you don't use the AWSServiceCatalogAppRegistryFullAccess policy. For more information, see AWSServiceCatalogAppRegistryFullAccess in the AppRegistry Administrator Guide.
  • resource-groups:AssociateResource
  • cloudformation:UpdateStack
  • cloudformation:DescribeStacks

May throw ConflictException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

Parameter application : The name, ID, or ARN of the application.

Parameter resource : The name or ID of the resource of which the application will be associated.

Parameter resourceType : The type of resource of which the application will be associated.

Parameter options : Determines whether an application tag is applied or skipped.

Implementation

Future<AssociateResourceResponse> associateResource({
  required String application,
  required String resource,
  required ResourceType resourceType,
  List<AssociationOption>? options,
}) async {
  final $payload = <String, dynamic>{
    if (options != null) 'options': options.map((e) => e.value).toList(),
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'PUT',
    requestUri:
        '/applications/${Uri.encodeComponent(application)}/resources/${Uri.encodeComponent(resourceType.value)}/${Uri.encodeComponent(resource)}',
    exceptionFnMap: _exceptionFns,
  );
  return AssociateResourceResponse.fromJson(response);
}