Associates tags with the specified Amazon Web Services resource. Tags are key:value pairs that you can use to categorize and manage your resources, for purposes like billing. For example, you might set the tag key to "customer" and the value to the customer name or ID. You can specify one or more tags to add to each Amazon Web Services resource, up to 50 tags for a resource.
You can tag the Amazon Web Services resources that you manage through WAF: web ACLs, rule groups, IP sets, and regex pattern sets. You can't manage or view tags through the WAF console.
Parameters:
-
resource_arn
(ResourceArn)
–
The Amazon Resource Name (ARN) of the resource.
-
tags
(TagList)
–
An array of key:value pairs to associate with the resource.
Raises:
-
WAFInternalErrorException
–
Your request is valid, but WAF couldn’t perform the operation because of a system problem. Retry your request.
-
WAFInvalidOperationException
–
The operation isn't valid.
-
WAFInvalidParameterException
–
The operation failed because WAF didn't recognize a parameter in the request. For example:
-
You specified a parameter name or value that isn't valid.
-
Your nested statement isn't valid. You might have tried to nest a statement that can’t be nested.
-
You tried to update a WebACL with a DefaultAction that isn't among the types available at DefaultAction.
-
Your request references an ARN that is malformed, or corresponds to a resource with which a web ACL can't be associated.
-
WAFLimitsExceededException
–
WAF couldn’t perform the operation because you exceeded your resource limit. For example, the maximum number of WebACL objects that you can create for an Amazon Web Services account. For more information, see WAF quotas in the WAF Developer Guide.
-
WAFNonexistentItemException
–
WAF couldn’t perform the operation because your resource doesn't exist. If you've just created a resource that you're using in this operation, you might just need to wait a few minutes. It can take from a few seconds to a number of minutes for changes to propagate.
-
WAFTagOperationException
–
An error occurred during the tagging operation. Retry your request.
-
WAFTagOperationInternalErrorException
–
WAF couldn’t perform your tagging operation because of an internal error. Retry your request.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Source code in docs_src/capo_wafv2/_services/async_wafv2.py
| async def tag_resource(
self,
resource_arn: "capo_wafv2.types.resource_arn.ResourceArn",
tags: "capo_wafv2.types.tag_list.TagList",
*,
config_overrides: Optional[AsyncWAFV2ClientConfig] = None,
) -> "capo_wafv2.types.tag_resource_response.TagResourceResponse":
"""<p>Associates tags with the specified Amazon Web Services resource. Tags are key:value pairs that you can use to categorize and manage your resources, for purposes like billing. For example, you might set the tag key to "customer" and the value to the customer name or ID. You can specify one or more tags to add to each Amazon Web Services resource, up to 50 tags for a resource.</p> <p>You can tag the Amazon Web Services resources that you manage through WAF: web ACLs, rule groups, IP sets, and regex pattern sets. You can't manage or view tags through the WAF console. </p>
Args:
resource_arn: <p>The Amazon Resource Name (ARN) of the resource.</p>
tags: <p>An array of key:value pairs to associate with the resource.</p>
Raises:
capo_wafv2.errors.waf_internal_error_exception.WAFInternalErrorException: <p>Your request is valid, but WAF couldn’t perform the operation because of a system problem. Retry your request. </p>
capo_wafv2.errors.waf_invalid_operation_exception.WAFInvalidOperationException: <p>The operation isn't valid. </p>
capo_wafv2.errors.waf_invalid_parameter_exception.WAFInvalidParameterException: <p>The operation failed because WAF didn't recognize a parameter in the request. For example: </p> <ul> <li> <p>You specified a parameter name or value that isn't valid.</p> </li> <li> <p>Your nested statement isn't valid. You might have tried to nest a statement that can’t be nested. </p> </li> <li> <p>You tried to update a <code>WebACL</code> with a <code>DefaultAction</code> that isn't among the types available at <a>DefaultAction</a>.</p> </li> <li> <p>Your request references an ARN that is malformed, or corresponds to a resource with which a web ACL can't be associated.</p> </li> </ul>
capo_wafv2.errors.waf_limits_exceeded_exception.WAFLimitsExceededException: <p>WAF couldn’t perform the operation because you exceeded your resource limit. For example, the maximum number of <code>WebACL</code> objects that you can create for an Amazon Web Services account. For more information, see <a href="https://docs.aws.amazon.com/waf/latest/developerguide/limits.html">WAF quotas</a> in the <i>WAF Developer Guide</i>.</p>
capo_wafv2.errors.waf_nonexistent_item_exception.WAFNonexistentItemException: <p>WAF couldn’t perform the operation because your resource doesn't exist. If you've just created a resource that you're using in this operation, you might just need to wait a few minutes. It can take from a few seconds to a number of minutes for changes to propagate. </p>
capo_wafv2.errors.waf_tag_operation_exception.WAFTagOperationException: <p>An error occurred during the tagging operation. Retry your request.</p>
capo_wafv2.errors.waf_tag_operation_internal_error_exception.WAFTagOperationInternalErrorException: <p>WAF couldn’t perform your tagging operation because of an internal error. Retry your request.</p>
capo_wafv2.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
async def _handler(
req: "AsyncOperationRequest[capo_wafv2.types.tag_resource_request.TagResourceRequest]",
) -> AsyncOperationResponse[
"capo_wafv2.types.tag_resource_response.TagResourceResponse"
]:
import capo_wafv2._operations.awswaf_20190729.tag_resource
(
output,
http_response,
) = await capo_wafv2._operations.awswaf_20190729.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_wafv2.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
|