Skip to content

tag_resource

tag_resource(
    resource_arn: String,
    tags: Tags,
    *,
    config_overrides: Optional[MPAClientConfig] = None,
) -> TagResourceResponse

Creates or updates a resource tag. Each tag is a label consisting of a user-defined key and value. Tags can help you manage, identify, organize, search for, and filter resources.

Parameters:

  • resource_arn (String) –

    Amazon Resource Name (ARN) for the resource you want to tag.

  • tags (Tags) –

    Tags that you have added to the specified resource.

Raises:

  • AccessDeniedException –

    You do not have sufficient access to perform this action. Check your permissions, and try again.

  • InternalServerException –

    The service encountered an internal error. Try your request again. If the problem persists, contact Amazon Web Services Support.

  • ResourceNotFoundException –

    The specified resource doesn't exist. Check the resource ID, and try again.

  • ThrottlingException –

    The request was denied due to request throttling.

  • TooManyTagsException –

    The request exceeds the maximum number of tags allowed for this resource. Remove some tags, and try again.

  • ValidationException –

    The input fails to satisfy the constraints specified by an Amazon Web Services service.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_mpa/_services/mpa.py
def tag_resource(
    self,
    resource_arn: "capo_mpa.types.string.String",
    tags: "capo_mpa.types.tags.Tags",
    *,
    config_overrides: Optional[MPAClientConfig] = None,
) -> "capo_mpa.types.tag_resource_response.TagResourceResponse":
    """<p>Creates or updates a resource tag. Each tag is a label consisting of a user-defined key and value. Tags can help you manage, identify, organize, search for, and filter resources.</p>

    Args:
        resource_arn: <p>Amazon Resource Name (ARN) for the resource you want to tag.</p>
        tags: <p>Tags that you have added to the specified resource.</p>

    Raises:
        capo_mpa.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action. Check your permissions, and try again.</p>
        capo_mpa.errors.internal_server_exception.InternalServerException: <p>The service encountered an internal error. Try your request again. If the problem persists, contact Amazon Web Services Support.</p>
        capo_mpa.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource doesn't exist. Check the resource ID, and try again.</p>
        capo_mpa.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling.</p>
        capo_mpa.errors.too_many_tags_exception.TooManyTagsException: <p>The request exceeds the maximum number of tags allowed for this resource. Remove some tags, and try again.</p>
        capo_mpa.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by an Amazon Web Services service.</p>
        capo_mpa.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_mpa.types.tag_resource_request.TagResourceRequest]",
    ) -> OperationResponse[
        "capo_mpa.types.tag_resource_response.TagResourceResponse"
    ]:
        import capo_mpa._operations.aws_fluffy_core_service.tag_resource

        output, http_response = (
            capo_mpa._operations.aws_fluffy_core_service.tag_resource.tag_resource(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_mpa.types.tag_resource_request.TagResourceRequest",
    ) -> dict[str, Any]:
        import capo_mpa.types.tag_resource_request

        return capo_mpa.types.tag_resource_request.redact_sensitive(input_)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("TagResource", redact_input=_redact_input),
    )
    input_: capo_mpa.types.tag_resource_request.TagResourceRequest = {
        "resource_arn": resource_arn,
        "tags": tags,
    }

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output