Skip to content

tag_resource

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

Applies one or more user-defined tags to an Amazon S3 Tables resource or updates existing tags. Each tag is a label consisting of a key and value pair. Tags can help you organize, track costs for, and control access to your resources. You can add up to 50 tags for each S3 resource.

For a list of S3 resources that support tagging, see Managing tags for Amazon S3 resources.

Permissions

For tables, table buckets, and S3 Storage Lens for Tables configurations, you must have the s3tables:TagResource permission to use this operation.

Parameters:

Raises:

  • BadRequestException –

    The request is invalid or malformed.

  • ConflictException –

    The request conflicts with the resource's current state, such as a previous write, an existing table, or a migration that's in progress or already in the requested state. If the conflict is with a concurrent write, you can retry the request.

  • ForbiddenException –

    The caller isn't authorized to make the request.

  • InternalServerErrorException –

    The request failed due to an internal server error.

  • NotFoundException –

    The request was rejected because the specified resource could not be found.

  • TooManyRequestsException –

    The limit on the number of requests per second was exceeded.

  • UnknownServiceError –

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

Source code in docs_src/capo_s3tables/_services/s3_tables.py
def tag_resource(
    self,
    resource_arn: "capo_s3tables.types.resource_arn.ResourceArn",
    tags: "capo_s3tables.types.tags.Tags",
    *,
    config_overrides: Optional[S3TablesClientConfig] = None,
) -> "capo_s3tables.types.tag_resource_response.TagResourceResponse":
    """<p>Applies one or more user-defined tags to an Amazon S3 Tables resource or updates existing tags. Each tag is a label consisting of a key and value pair. Tags can help you organize, track costs for, and control access to your resources. You can add up to 50 tags for each S3 resource. </p> <note> <p>For a list of S3 resources that support tagging, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/tagging.html#manage-tags">Managing tags for Amazon S3 resources</a>.</p> </note> <dl> <dt>Permissions</dt> <dd> <p>For tables, table buckets, and S3 Storage Lens for Tables configurations, you must have the <code>s3tables:TagResource</code> permission to use this operation.</p> </dd> </dl>

    Args:
        resource_arn: <p>The Amazon Resource Name (ARN) of the Amazon S3 Tables resource that you're applying tags to. The tagged resource can be a table bucket, a table, or an S3 Storage Lens for Tables configuration. For a list of all S3 resources that support tagging, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/tagging.html#manage-tags">Managing tags for Amazon S3 resources</a>.</p>
        tags: <p>The user-defined tag that you want to add to the specified S3 Tables resource. For more information, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/tagging.html">Tagging for cost allocation or attribute-based access control (ABAC)</a>.</p>

    Raises:
        capo_s3tables.errors.bad_request_exception.BadRequestException: <p>The request is invalid or malformed.</p>
        capo_s3tables.errors.conflict_exception.ConflictException: <p>The request conflicts with the resource's current state, such as a previous write, an existing table, or a migration that's in progress or already in the requested state. If the conflict is with a concurrent write, you can retry the request.</p>
        capo_s3tables.errors.forbidden_exception.ForbiddenException: <p>The caller isn't authorized to make the request.</p>
        capo_s3tables.errors.internal_server_error_exception.InternalServerErrorException: <p>The request failed due to an internal server error.</p>
        capo_s3tables.errors.not_found_exception.NotFoundException: <p>The request was rejected because the specified resource could not be found.</p>
        capo_s3tables.errors.too_many_requests_exception.TooManyRequestsException: <p>The limit on the number of requests per second was exceeded.</p>
        capo_s3tables.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

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

        output, http_response = (
            capo_s3tables._operations.s3_table_buckets.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_s3tables.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