Skip to content

untag_resources async

untag_resources(
    resource_arn_list: ResourceARNListForTagUntag,
    tag_keys: TagKeyListForUntag,
    *,
    config_overrides: Optional[AsyncResourceGroupsTaggingAPIClientConfig] = None,
) -> UntagResourcesOutput

Removes the specified tags from the specified resources. When you specify a tag key, the action removes both that key and its associated value. The operation succeeds even if you attempt to remove tags from a resource that were already removed. Note the following:

  • To remove tags from a resource, you need the necessary permissions for the service that the resource belongs to as well as permissions for removing tags. For more information, see the documentation for the service whose resource you want to untag.

  • You can only tag resources that are located in the specified Amazon Web Services Region for the calling Amazon Web Services account.

Minimum permissions

In addition to the tag:UntagResources permission required by this operation, you must also have the remove tags permission defined by the service that created the resource. For example, to remove the tags from an Amazon EC2 instance using the UntagResources operation, you must have both of the following permissions:

  • tag:UntagResources

  • ec2:DeleteTags

In addition, some services might have specific requirements for untagging some types of resources. For example, to untag Amazon Web Services Glue Connection, you must also have the glue:GetConnection permission. If the expected minimum permissions don't work, check the documentation for that service's tagging APIs for more information.

Parameters:

Raises:

  • InternalServiceException –

    The request processing failed because of an unknown error, exception, or failure. You can retry the request.

  • InvalidParameterException –

    The request failed because of one of the following reasons:

    • A required parameter is missing.

    • A provided string parameter is malformed.

    • An provided parameter value is out of range.

    • The target ID is invalid, unsupported, or doesn't exist.

    • You can't access the Amazon S3 bucket for report storage. For more information, see Amazon S3 bucket policy for report storage in the Tagging Amazon Web Services resources and Tag Editor user guide.

    • The partition specified in an ARN parameter in the request doesn't match the partition where you invoked the operation. The partition is specified by the second field of the ARN.

  • ThrottledException –

    The request failed because it exceeded the allowed frequency of submitted requests.

  • UnknownServiceError –

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

Source code in docs_src/capo_resource_groups_tagging_api/_services/async_resource_groups_tagging_api.py
async def untag_resources(
    self,
    resource_arn_list: "capo_resource_groups_tagging_api.types.resource_arn_list_for_tag_untag.ResourceARNListForTagUntag",
    tag_keys: "capo_resource_groups_tagging_api.types.tag_key_list_for_untag.TagKeyListForUntag",
    *,
    config_overrides: Optional[AsyncResourceGroupsTaggingAPIClientConfig] = None,
) -> "capo_resource_groups_tagging_api.types.untag_resources_output.UntagResourcesOutput":
    """<p>Removes the specified tags from the specified resources. When you specify a tag key, the action removes both that key and its associated value. The operation succeeds even if you attempt to remove tags from a resource that were already removed. Note the following:</p> <ul> <li> <p>To remove tags from a resource, you need the necessary permissions for the service that the resource belongs to as well as permissions for removing tags. For more information, see the documentation for the service whose resource you want to untag.</p> </li> <li> <p>You can only tag resources that are located in the specified Amazon Web Services Region for the calling Amazon Web Services account.</p> </li> </ul> <p> <b>Minimum permissions</b> </p> <p>In addition to the <code>tag:UntagResources</code> permission required by this operation, you must also have the remove tags permission defined by the service that created the resource. For example, to remove the tags from an Amazon EC2 instance using the <code>UntagResources</code> operation, you must have both of the following permissions:</p> <ul> <li> <p> <code>tag:UntagResources</code> </p> </li> <li> <p> <code>ec2:DeleteTags</code> </p> </li> </ul> <note> <p>In addition, some services might have specific requirements for untagging some types of resources. For example, to untag Amazon Web Services Glue Connection, you must also have the <code>glue:GetConnection</code> permission. If the expected minimum permissions don't work, check the documentation for that service's tagging APIs for more information.</p> </note>

    Args:
        resource_arn_list: <p>Specifies a list of ARNs of the resources that you want to remove tags from.</p> <p>An ARN (Amazon Resource Name) uniquely identifies a resource. For more information, see <a href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">Amazon Resource Names (ARNs) and Amazon Web Services Service Namespaces</a> in the <i>Amazon Web Services General Reference</i>.</p>
        tag_keys: <p>Specifies a list of tag keys that you want to remove from the specified resources.</p>

    Raises:
        capo_resource_groups_tagging_api.errors.internal_service_exception.InternalServiceException: <p>The request processing failed because of an unknown error, exception, or failure. You can retry the request.</p>
        capo_resource_groups_tagging_api.errors.invalid_parameter_exception.InvalidParameterException: <p>The request failed because of one of the following reasons:</p> <ul> <li> <p>A required parameter is missing.</p> </li> <li> <p>A provided string parameter is malformed.</p> </li> <li> <p>An provided parameter value is out of range.</p> </li> <li> <p>The target ID is invalid, unsupported, or doesn't exist.</p> </li> <li> <p>You can't access the Amazon S3 bucket for report storage. For more information, see <a href="https://docs.aws.amazon.com/tag-editor/latest/userguide/tag-policies-orgs.html#bucket-policy">Amazon S3 bucket policy for report storage</a> in the <i>Tagging Amazon Web Services resources and Tag Editor</i> user guide. </p> </li> <li> <p>The partition specified in an ARN parameter in the request doesn't match the partition where you invoked the operation. The partition is specified by the second field of the ARN.</p> </li> </ul>
        capo_resource_groups_tagging_api.errors.throttled_exception.ThrottledException: <p>The request failed because it exceeded the allowed frequency of submitted requests.</p>
        capo_resource_groups_tagging_api.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_resource_groups_tagging_api.types.untag_resources_input.UntagResourcesInput]",
    ) -> AsyncOperationResponse[
        "capo_resource_groups_tagging_api.types.untag_resources_output.UntagResourcesOutput"
    ]:
        import capo_resource_groups_tagging_api._operations.resource_groups_tagging_api_20170126.untag_resources

        (
            output,
            http_response,
        ) = await capo_resource_groups_tagging_api._operations.resource_groups_tagging_api_20170126.untag_resources.async_untag_resources(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UntagResources")
    )
    input_: capo_resource_groups_tagging_api.types.untag_resources_input.UntagResourcesInput = {
        "resource_arn_list": resource_arn_list,
        "tag_keys": tag_keys,
    }

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