tagResources method

Future<TagResourcesOutput> tagResources({
  1. required List<String> resourceARNList,
  2. required Map<String, String> tags,
})

Applies one or more tags to the specified resources. Note the following:

  • Not all resources can have tags. For a list of services that support tagging, see this list.
  • Each resource can have up to 50 tags. For other limits, see Tag Naming and Usage Conventions in the AWS General Reference.
  • You can only tag resources that are located in the specified Region for the AWS account.
  • To add tags to a resource, you need the necessary permissions for the service that the resource belongs to as well as permissions for adding tags. For more information, see this list.

May throw InvalidParameterException. May throw ThrottledException. May throw InternalServiceException.

Parameter resourceARNList : A list of ARNs. An ARN (Amazon Resource Name) uniquely identifies a resource. For more information, see Amazon Resource Names (ARNs) and AWS Service Namespaces in the AWS General Reference.

Parameter tags : The tags that you want to add to the specified resources. A tag consists of a key and a value that you define.

Implementation

Future<TagResourcesOutput> tagResources({
  required List<String> resourceARNList,
  required Map<String, String> tags,
}) async {
  ArgumentError.checkNotNull(resourceARNList, 'resourceARNList');
  ArgumentError.checkNotNull(tags, 'tags');
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'ResourceGroupsTaggingAPI_20170126.TagResources'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ResourceARNList': resourceARNList,
      'Tags': tags,
    },
  );

  return TagResourcesOutput.fromJson(jsonResponse.body);
}