Skip to content

tag_resource

tag_resource(
    resource_arn: AmazonResourceName,
    tags: TagList,
    *,
    config_overrides: Optional[ConfigServiceClientConfig] = None,
) -> None

Associates the specified tags to a resource with the specified ResourceArn. If existing tags on a resource are not specified in the request parameters, they are not changed. If existing tags are specified, however, then their values will be updated. When a resource is deleted, the tags associated with that resource are deleted as well.

Parameters:

  • resource_arn (AmazonResourceName) –

    The Amazon Resource Name (ARN) that identifies the resource for which to list the tags. The following resources are supported:

    • ConfigurationRecorder

    • ConfigRule

    • OrganizationConfigRule

    • ConformancePack

    • OrganizationConformancePack

    • ConfigurationAggregator

    • AggregationAuthorization

    • StoredQuery

    • Connector

  • tags (TagList) –

    An array of tag object.

Raises:

  • ResourceNotFoundException –

    You have specified a resource that does not exist.

  • TooManyTagsException –

    You have reached the limit of the number of tags you can use. For more information, see Service Limits in the Config Developer Guide.

  • ValidationException –

    The requested operation is not valid. You will see this exception if there are missing required fields or if the input value fails the validation.

    For PutStoredQuery, one of the following errors:

    • There are missing required fields.

    • The input value fails the validation.

    • You are trying to create more than 300 queries.

    For DescribeConfigurationRecorders and DescribeConfigurationRecorderStatus, one of the following errors:

    • You have specified more than one configuration recorder.

    • You have provided a service principal for service-linked configuration recorder that is not valid.

    For AssociateResourceTypes and DisassociateResourceTypes, one of the following errors:

    • Your configuraiton recorder has a recording strategy that does not allow the association or disassociation of resource types.

    • One or more of the specified resource types are already associated or disassociated with the configuration recorder.

    • For service-linked configuration recorders, the configuration recorder does not record one or more of the specified resource types.

    For DeleteServiceLinkedConfigurationRecorder, one of the following errors:

    • You have provided both Arn and ServicePrincipal. Only one of Arn or ServicePrincipal can be specified.

    • You have provided a service principal for service-linked configuration recorder that is not valid.

  • UnknownServiceError –

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

Source code in docs_src/capo_config_service/_services/config_service.py
def tag_resource(
    self,
    resource_arn: "capo_config_service.types.amazon_resource_name.AmazonResourceName",
    tags: "capo_config_service.types.tag_list.TagList",
    *,
    config_overrides: Optional[ConfigServiceClientConfig] = None,
) -> None:
    """<p>Associates the specified tags to a resource with the specified <code>ResourceArn</code>. If existing tags on a resource are not specified in the request parameters, they are not changed. If existing tags are specified, however, then their values will be updated. When a resource is deleted, the tags associated with that resource are deleted as well.</p>

    Args:
        resource_arn: <p>The Amazon Resource Name (ARN) that identifies the resource for which to list the tags. The following resources are supported:</p> <ul> <li> <p> <code>ConfigurationRecorder</code> </p> </li> <li> <p> <code>ConfigRule</code> </p> </li> <li> <p> <code>OrganizationConfigRule</code> </p> </li> <li> <p> <code>ConformancePack</code> </p> </li> <li> <p> <code>OrganizationConformancePack</code> </p> </li> <li> <p> <code>ConfigurationAggregator</code> </p> </li> <li> <p> <code>AggregationAuthorization</code> </p> </li> <li> <p> <code>StoredQuery</code> </p> </li> <li> <p> <code>Connector</code> </p> </li> </ul>
        tags: <p>An array of tag object.</p>

    Raises:
        capo_config_service.errors.resource_not_found_exception.ResourceNotFoundException: <p>You have specified a resource that does not exist.</p>
        capo_config_service.errors.too_many_tags_exception.TooManyTagsException: <p>You have reached the limit of the number of tags you can use. For more information, see <a href="https://docs.aws.amazon.com/config/latest/developerguide/configlimits.html"> <b>Service Limits</b> </a> in the <i>Config Developer Guide</i>.</p>
        capo_config_service.errors.validation_exception.ValidationException: <p>The requested operation is not valid. You will see this exception if there are missing required fields or if the input value fails the validation.</p> <p>For <a href="https://docs.aws.amazon.com/config/latest/APIReference/API_PutStoredQuery.html">PutStoredQuery</a>, one of the following errors:</p> <ul> <li> <p>There are missing required fields.</p> </li> <li> <p>The input value fails the validation.</p> </li> <li> <p>You are trying to create more than 300 queries.</p> </li> </ul> <p>For <a href="https://docs.aws.amazon.com/config/latest/APIReference/API_DescribeConfigurationRecorders.html">DescribeConfigurationRecorders</a> and <a href="https://docs.aws.amazon.com/config/latest/APIReference/API_DescribeConfigurationRecorderStatus.html">DescribeConfigurationRecorderStatus</a>, one of the following errors:</p> <ul> <li> <p>You have specified more than one configuration recorder.</p> </li> <li> <p>You have provided a service principal for service-linked configuration recorder that is not valid.</p> </li> </ul> <p>For <a href="https://docs.aws.amazon.com/config/latest/APIReference/API_AssociateResourceTypes.html">AssociateResourceTypes</a> and <a href="https://docs.aws.amazon.com/config/latest/APIReference/API_DisassociateResourceTypes.html">DisassociateResourceTypes</a>, one of the following errors:</p> <ul> <li> <p>Your configuraiton recorder has a recording strategy that does not allow the association or disassociation of resource types.</p> </li> <li> <p>One or more of the specified resource types are already associated or disassociated with the configuration recorder.</p> </li> <li> <p>For service-linked configuration recorders, the configuration recorder does not record one or more of the specified resource types.</p> </li> </ul> <p>For <a href="https://docs.aws.amazon.com/config/latest/APIReference/API_DeleteServiceLinkedConfigurationRecorder.html">DeleteServiceLinkedConfigurationRecorder</a>, one of the following errors:</p> <ul> <li> <p>You have provided both <code>Arn</code> and <code>ServicePrincipal</code>. Only one of <code>Arn</code> or <code>ServicePrincipal</code> can be specified.</p> </li> <li> <p>You have provided a service principal for service-linked configuration recorder that is not valid.</p> </li> </ul>
        capo_config_service.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_config_service.types.tag_resource_request.TagResourceRequest]",
    ) -> OperationResponse[None]:
        import capo_config_service._operations.starling_dove_service.tag_resource

        output, http_response = (
            capo_config_service._operations.starling_dove_service.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_config_service.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