Skip to content

add_tags

add_tags(
    *,
    config_overrides: Optional[ElasticLoadBalancingv2ClientConfig] = None,
    resource_arns: Optional[ResourceArns] = None,
    tags: Optional[TagList] = None,
) -> AddTagsOutput

Adds the specified tags to the specified Elastic Load Balancing resource. You can tag your Application Load Balancers, Network Load Balancers, Gateway Load Balancers, target groups, trust stores, listeners, and rules.

Each tag consists of a key and an optional value. If a resource already has a tag with the same key, AddTags updates its value.

Parameters:

Raises:

Examples:

To add tags to a load balancer This example adds the specified tags to the specified load balancer.

>>> client.add_tags(resource_arns=['arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188'], tags=[{'Key': 'project', 'Value': 'lima'}, {'Key': 'department', 'Value': 'digital-media'}])
Source code in docs_src/capo_elastic_load_balancing_v2/_services/elastic_load_balancingv2.py
def add_tags(
    self,
    *,
    config_overrides: Optional[ElasticLoadBalancingv2ClientConfig] = None,
    resource_arns: Optional[
        "capo_elastic_load_balancing_v2.types.resource_arns.ResourceArns"
    ] = None,
    tags: Optional["capo_elastic_load_balancing_v2.types.tag_list.TagList"] = None,
) -> "capo_elastic_load_balancing_v2.types.add_tags_output.AddTagsOutput":
    """<p>Adds the specified tags to the specified Elastic Load Balancing resource. You can tag your Application Load Balancers, Network Load Balancers, Gateway Load Balancers, target groups, trust stores, listeners, and rules.</p> <p>Each tag consists of a key and an optional value. If a resource already has a tag with the same key, <code>AddTags</code> updates its value.</p>

    Args:
        resource_arns: <p>The Amazon Resource Name (ARN) of the resource.</p>
        tags: <p>The tags.</p>

    Raises:
        capo_elastic_load_balancing_v2.errors.duplicate_tag_keys_exception.DuplicateTagKeysException: <p>A tag key was specified more than once.</p>
        capo_elastic_load_balancing_v2.errors.listener_not_found_exception.ListenerNotFoundException: <p>The specified listener does not exist.</p>
        capo_elastic_load_balancing_v2.errors.load_balancer_not_found_exception.LoadBalancerNotFoundException: <p>The specified load balancer does not exist.</p>
        capo_elastic_load_balancing_v2.errors.rule_not_found_exception.RuleNotFoundException: <p>The specified rule does not exist.</p>
        capo_elastic_load_balancing_v2.errors.target_group_not_found_exception.TargetGroupNotFoundException: <p>The specified target group does not exist.</p>
        capo_elastic_load_balancing_v2.errors.too_many_tags_exception.TooManyTagsException: <p>You've reached the limit on the number of tags for this resource.</p>
        capo_elastic_load_balancing_v2.errors.trust_store_not_found_exception.TrustStoreNotFoundException: <p>The specified trust store does not exist.</p>
        capo_elastic_load_balancing_v2.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To add tags to a load balancer
        This example adds the specified tags to the specified load balancer.

        >>> client.add_tags(resource_arns=['arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188'], tags=[{'Key': 'project', 'Value': 'lima'}, {'Key': 'department', 'Value': 'digital-media'}])
    """

    def _handler(
        req: "OperationRequest[capo_elastic_load_balancing_v2.types.add_tags_input.AddTagsInput]",
    ) -> OperationResponse[
        "capo_elastic_load_balancing_v2.types.add_tags_output.AddTagsOutput"
    ]:
        import capo_elastic_load_balancing_v2._operations.elastic_load_balancing_v10.add_tags

        output, http_response = (
            capo_elastic_load_balancing_v2._operations.elastic_load_balancing_v10.add_tags.add_tags(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("AddTags")
    )
    input_: capo_elastic_load_balancing_v2.types.add_tags_input.AddTagsInput = {}
    if resource_arns is not None:
        input_["resource_arns"] = resource_arns
    if tags is not None:
        input_["tags"] = tags

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output