tagResource method

Future<void> tagResource({
  1. required String resourceArn,
  2. required Map<String, String> tags,
})

Apply cost-allocation tags to a specified stack or layer in AWS OpsWorks Stacks. For more information about how tagging works, see Tags in the AWS OpsWorks User Guide.

May throw ValidationException. May throw ResourceNotFoundException.

Parameter resourceArn : The stack or layer's Amazon Resource Number (ARN).

Parameter tags : A map that contains tag keys and tag values that are attached to a stack or layer.

  • The key cannot be empty.
  • The key can be a maximum of 127 characters, and can contain only Unicode letters, numbers, or separators, or the following special characters: + - = . _ : /
  • The value can be a maximum 255 characters, and contain only Unicode letters, numbers, or separators, or the following special characters: + - = . _ : /
  • Leading and trailing white spaces are trimmed from both the key and value.
  • A maximum of 40 tags is allowed for any resource.

Implementation

Future<void> tagResource({
  required String resourceArn,
  required Map<String, String> tags,
}) async {
  ArgumentError.checkNotNull(resourceArn, 'resourceArn');
  ArgumentError.checkNotNull(tags, 'tags');
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'OpsWorks_20130218.TagResource'
  };
  await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ResourceArn': resourceArn,
      'Tags': tags,
    },
  );
}