Skip to content

tag_resource

tag_resource(
    resource_arn: ResourceArn,
    tags: TagList,
    *,
    config_overrides: Optional[AssuranceClientConfig] = None,
) -> TagResourceOutput

Adds or overwrites tags on a resource.

Parameters:

  • resource_arn (ResourceArn) –

    The Amazon Resource Name (ARN) of the resource.

  • tags (TagList) –

    The tags attached to the resource, as key-value pairs.

Raises:

Examples:

Tag a governance environment Applies compliance-program and team tags to the governance environment so the payments team can track it alongside their other resources.

>>> client.tag_resource(resource_arn='arn:aws:assurance:us-east-1:111122223333:environment/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111', tags=[{'key': 'compliance-program', 'value': 'pci-dss'}, {'key': 'team', 'value': 'payments'}])
Source code in docs_src/capo_assurance/_services/assurance.py
def tag_resource(
    self,
    resource_arn: "capo_assurance.types.resource_arn.ResourceArn",
    tags: "capo_assurance.types.tag_list.TagList",
    *,
    config_overrides: Optional[AssuranceClientConfig] = None,
) -> "capo_assurance.types.tag_resource_output.TagResourceOutput":
    """<p>Adds or overwrites tags on a resource.</p>

    Args:
        resource_arn: <p>The Amazon Resource Name (ARN) of the resource.</p>
        tags: <p>The tags attached to the resource, as key-value pairs.</p>

    Raises:
        capo_assurance.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action. This error occurs when the request is unauthenticated, or is authenticated but lacks permission to invoke the operation.</p>
        capo_assurance.errors.internal_server_exception.InternalServerException: <p>An internal server error occurred.</p>
        capo_assurance.errors.resource_not_found_exception.ResourceNotFoundException: <p>The requested resource was not found.</p>
        capo_assurance.errors.throttling_exception.ThrottlingException: <p>The request was throttled.</p>
        capo_assurance.errors.validation_exception.ValidationException: <p>The request failed validation.</p>
        capo_assurance.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Tag a governance environment
        Applies compliance-program and team tags to the governance environment so the payments team can track it alongside their other resources.

        >>> client.tag_resource(resource_arn='arn:aws:assurance:us-east-1:111122223333:environment/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111', tags=[{'key': 'compliance-program', 'value': 'pci-dss'}, {'key': 'team', 'value': 'payments'}])
    """

    def _handler(
        req: "OperationRequest[capo_assurance.types.tag_resource_input.TagResourceInput]",
    ) -> OperationResponse[
        "capo_assurance.types.tag_resource_output.TagResourceOutput"
    ]:
        import capo_assurance._operations.assurance.tag_resource

        output, http_response = (
            capo_assurance._operations.assurance.tag_resource.tag_resource(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("TagResource")
    )
    input_: capo_assurance.types.tag_resource_input.TagResourceInput = {
        "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