Skip to content

tag_resource

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

Use this operation to add tags to a resource. A tag is a key-value pair where the key and value are case-sensitive. You can use tags to categorize and track all your MemoryDB resources. For more information, see Tagging your MemoryDB resources.

When you add tags to multi region clusters, you might not immediately see the latest effective tags in the ListTags API response due to it being eventually consistent specifically for multi region clusters. For more information, see Tagging your MemoryDB resources.

You can specify cost-allocation tags for your MemoryDB resources, Amazon generates a cost allocation report as a comma-separated value (CSV) file with your usage and costs aggregated by your tags. You can apply tags that represent business categories (such as cost centers, application names, or owners) to organize your costs across multiple services. For more information, see Using Cost Allocation Tags.

Parameters:

  • resource_arn (String) –

    The Amazon Resource Name (ARN) of the resource to which the tags are to be added.

  • tags (TagList) –

    A list of tags to be added to this resource. A tag is a key-value pair. A tag key must be accompanied by a tag value, although null is accepted.

Raises:

Source code in docs_src/capo_memorydb/_services/memory_db.py
def tag_resource(
    self,
    resource_arn: "capo_memorydb.types.string.String",
    tags: "capo_memorydb.types.tag_list.TagList",
    *,
    config_overrides: Optional[MemoryDBClientConfig] = None,
) -> "capo_memorydb.types.tag_resource_response.TagResourceResponse":
    """<p> Use this operation to add tags to a resource. A tag is a key-value pair where the key and value are case-sensitive. You can use tags to categorize and track all your MemoryDB resources. For more information, see <a href="https://docs.aws.amazon.com/MemoryDB/latest/devguide/Tagging-Resources.html">Tagging your MemoryDB resources</a>.</p> <p>When you add tags to multi region clusters, you might not immediately see the latest effective tags in the ListTags API response due to it being eventually consistent specifically for multi region clusters. For more information, see <a href="https://docs.aws.amazon.com/MemoryDB/latest/devguide/Tagging-Resources.html">Tagging your MemoryDB resources</a>.</p> <p>You can specify cost-allocation tags for your MemoryDB resources, Amazon generates a cost allocation report as a comma-separated value (CSV) file with your usage and costs aggregated by your tags. You can apply tags that represent business categories (such as cost centers, application names, or owners) to organize your costs across multiple services. For more information, see <a href="https://docs.aws.amazon.com/MemoryDB/latest/devguide/tagging.html">Using Cost Allocation Tags</a>.</p>

    Args:
        resource_arn: <p>The Amazon Resource Name (ARN) of the resource to which the tags are to be added.</p>
        tags: <p>A list of tags to be added to this resource. A tag is a key-value pair. A tag key must be accompanied by a tag value, although null is accepted.</p>

    Raises:
        capo_memorydb.errors.acl_not_found_fault.ACLNotFoundFault: <p>The specified ACL does not exist.</p>
        capo_memorydb.errors.cluster_not_found_fault.ClusterNotFoundFault: <p>The specified cluster does not exist.</p>
        capo_memorydb.errors.invalid_arn_fault.InvalidARNFault: <p>The specified Amazon Resource Name (ARN) is not valid.</p>
        capo_memorydb.errors.invalid_cluster_state_fault.InvalidClusterStateFault: <p>The cluster is not in a valid state for the requested operation.</p>
        capo_memorydb.errors.invalid_parameter_value_exception.InvalidParameterValueException: <p>The specified parameter value is not valid.</p>
        capo_memorydb.errors.multi_region_cluster_not_found_fault.MultiRegionClusterNotFoundFault: <p>The specified multi-Region cluster does not exist.</p>
        capo_memorydb.errors.multi_region_parameter_group_not_found_fault.MultiRegionParameterGroupNotFoundFault: <p>The specified multi-Region parameter group does not exist.</p>
        capo_memorydb.errors.parameter_group_not_found_fault.ParameterGroupNotFoundFault: <p>The specified parameter group does not exist.</p>
        capo_memorydb.errors.service_linked_role_not_found_fault.ServiceLinkedRoleNotFoundFault: <p>The required service-linked role was not found.</p>
        capo_memorydb.errors.snapshot_not_found_fault.SnapshotNotFoundFault: <p>The specified snapshot does not exist.</p>
        capo_memorydb.errors.subnet_group_not_found_fault.SubnetGroupNotFoundFault: <p>The specified subnet group does not exist.</p>
        capo_memorydb.errors.tag_quota_per_resource_exceeded.TagQuotaPerResourceExceeded: <p>The request cannot be processed because it would exceed the maximum number of tags allowed per resource.</p>
        capo_memorydb.errors.user_not_found_fault.UserNotFoundFault: <p>The specified user does not exist.</p>
        capo_memorydb.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

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

        output, http_response = (
            capo_memorydb._operations.amazon_memory_db.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_memorydb.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