Skip to content

tag_resource async

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

Assigns one or more tags (key-value pairs) to the specified EventBridge resource. Tags can help you organize and categorize your resources. You can also use them to scope user permissions by granting a user permission to access or change only resources with certain tag values. In EventBridge, rules and event buses can be tagged.

Tags don't have any semantic meaning to Amazon Web Services and are interpreted strictly as strings of characters.

You can use the TagResource action with a resource that already has tags. If you specify a new tag key, this tag is appended to the list of tags associated with the resource. If you specify a tag key that is already associated with the resource, the new tag value that you specify replaces the previous value for that tag.

You can associate as many as 50 tags with a resource.

Parameters:

  • resource_arn (Arn) –

    The ARN of the EventBridge resource that you're adding tags to.

  • tags (TagList) –

    The list of key-value pairs to associate with the resource.

Raises:

  • ConcurrentModificationException –

    There is concurrent modification on a rule, target, archive, or replay.

  • InternalException –

    This exception occurs due to unexpected causes.

  • ManagedRuleException –

    This rule was created by an Amazon Web Services service on behalf of your account. It is managed by that service. If you see this error in response to DeleteRule or RemoveTargets, you can use the Force parameter in those calls to delete the rule or remove targets from the rule. You cannot modify these managed rules by using DisableRule, EnableRule, PutTargets, PutRule, TagResource, or UntagResource.

  • ResourceNotFoundException –

    An entity that you specified does not exist.

  • UnknownServiceError –

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

Source code in docs_src/capo_cloudwatch_events/_services/async_cloud_watch_events.py
async def tag_resource(
    self,
    resource_arn: "capo_cloudwatch_events.types.arn.Arn",
    tags: "capo_cloudwatch_events.types.tag_list.TagList",
    *,
    config_overrides: Optional[AsyncCloudWatchEventsClientConfig] = None,
) -> "capo_cloudwatch_events.types.tag_resource_response.TagResourceResponse":
    """<p>Assigns one or more tags (key-value pairs) to the specified EventBridge resource. Tags can help you organize and categorize your resources. You can also use them to scope user permissions by granting a user permission to access or change only resources with certain tag values. In EventBridge, rules and event buses can be tagged.</p> <p>Tags don't have any semantic meaning to Amazon Web Services and are interpreted strictly as strings of characters.</p> <p>You can use the <code>TagResource</code> action with a resource that already has tags. If you specify a new tag key, this tag is appended to the list of tags associated with the resource. If you specify a tag key that is already associated with the resource, the new tag value that you specify replaces the previous value for that tag.</p> <p>You can associate as many as 50 tags with a resource.</p>

    Args:
        resource_arn: <p>The ARN of the EventBridge resource that you're adding tags to.</p>
        tags: <p>The list of key-value pairs to associate with the resource.</p>

    Raises:
        capo_cloudwatch_events.errors.concurrent_modification_exception.ConcurrentModificationException: <p>There is concurrent modification on a rule, target, archive, or replay.</p>
        capo_cloudwatch_events.errors.internal_exception.InternalException: <p>This exception occurs due to unexpected causes.</p>
        capo_cloudwatch_events.errors.managed_rule_exception.ManagedRuleException: <p>This rule was created by an Amazon Web Services service on behalf of your account. It is managed by that service. If you see this error in response to <code>DeleteRule</code> or <code>RemoveTargets</code>, you can use the <code>Force</code> parameter in those calls to delete the rule or remove targets from the rule. You cannot modify these managed rules by using <code>DisableRule</code>, <code>EnableRule</code>, <code>PutTargets</code>, <code>PutRule</code>, <code>TagResource</code>, or <code>UntagResource</code>. </p>
        capo_cloudwatch_events.errors.resource_not_found_exception.ResourceNotFoundException: <p>An entity that you specified does not exist.</p>
        capo_cloudwatch_events.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_cloudwatch_events.types.tag_resource_request.TagResourceRequest]",
    ) -> AsyncOperationResponse[
        "capo_cloudwatch_events.types.tag_resource_response.TagResourceResponse"
    ]:
        import capo_cloudwatch_events._operations.aws_events.tag_resource

        (
            output,
            http_response,
        ) = await capo_cloudwatch_events._operations.aws_events.tag_resource.async_tag_resource(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

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

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output