Skip to content

start_tag_sync_task async

start_tag_sync_task(
    group: GroupStringV2,
    role_arn: RoleArn,
    *,
    config_overrides: Optional[AsyncResourceGroupsClientConfig] = None,
    tag_key: Optional[TagKey] = None,
    tag_value: Optional[TagValue] = None,
    resource_query: Optional[ResourceQuery] = None,
) -> StartTagSyncTaskOutput

Creates a new tag-sync task to onboard and sync resources tagged with a specific tag key-value pair to an application. To start a tag-sync task, you need a resource tagging role. The resource tagging role grants permissions to tag and untag applications resources and must include a trust policy that allows Resource Groups to assume the role and perform resource tagging tasks on your behalf.

For instructions on creating a tag-sync task, see Create a tag-sync using the Resource Groups API in the Amazon Web Services Service Catalog AppRegistry Administrator Guide.

Minimum permissions

To run this command, you must have the following permissions:

  • resource-groups:StartTagSyncTask on the application group

  • resource-groups:CreateGroup

  • iam:PassRole on the role provided in the request

Parameters:

  • group (GroupStringV2) –

    The Amazon resource name (ARN) or name of the application group for which you want to create a tag-sync task.

  • tag_key (Optional[TagKey], default: None ) –

    The tag key. Resources tagged with this tag key-value pair will be added to the application. If a resource with this tag is later untagged, the tag-sync task removes the resource from the application.

    When using the TagKey parameter, you must also specify the TagValue parameter. If you specify a tag key-value pair, you can't use the ResourceQuery parameter.

  • tag_value (Optional[TagValue], default: None ) –

    The tag value. Resources tagged with this tag key-value pair will be added to the application. If a resource with this tag is later untagged, the tag-sync task removes the resource from the application.

    When using the TagValue parameter, you must also specify the TagKey parameter. If you specify a tag key-value pair, you can't use the ResourceQuery parameter.

  • resource_query (Optional[ResourceQuery], default: None ) –

    The query you can use to create the tag-sync task. With this method, all resources matching the query are added to the specified application group. A ResourceQuery specifies both a query Type and a Query string as JSON string objects. For more information on defining a resource query for a tag-sync task, see the tag-based query type in Types of resource group queries in Resource Groups User Guide.

    When using the ResourceQuery parameter, you cannot use the TagKey and TagValue parameters.

    When you combine all of the elements together into a single string, any double quotes that are embedded inside another double quote pair must be escaped by preceding the embedded double quote with a backslash character (\). For example, a complete ResourceQuery parameter must be formatted like the following CLI parameter example:

    --resource-query '{"Type":"TAG_FILTERS_1_0","Query":"{\"ResourceTypeFilters\":[\"AWS::AllSupported\"],\"TagFilters\":[{\"Key\":\"Stage\",\"Values\":[\"Test\"]}]}"}'

    In the preceding example, all of the double quote characters in the value part of the Query element must be escaped because the value itself is surrounded by double quotes. For more information, see Quoting strings in the Command Line Interface User Guide.

    For the complete list of resource types that you can use in the array value for ResourceTypeFilters, see Resources you can use with Resource Groups and Tag Editor in the Resource Groups User Guide. For example:

    "ResourceTypeFilters":["AWS::S3::Bucket", "AWS::EC2::Instance"]

  • role_arn (RoleArn) –

    The Amazon resource name (ARN) of the role assumed by the service to tag and untag resources on your behalf.

Raises:

Source code in docs_src/capo_resource_groups/_services/async_resource_groups.py
async def start_tag_sync_task(
    self,
    group: "capo_resource_groups.types.group_string_v2.GroupStringV2",
    role_arn: "capo_resource_groups.types.role_arn.RoleArn",
    *,
    config_overrides: Optional[AsyncResourceGroupsClientConfig] = None,
    tag_key: Optional["capo_resource_groups.types.tag_key.TagKey"] = None,
    tag_value: Optional["capo_resource_groups.types.tag_value.TagValue"] = None,
    resource_query: Optional[
        "capo_resource_groups.types.resource_query.ResourceQuery"
    ] = None,
) -> "capo_resource_groups.types.start_tag_sync_task_output.StartTagSyncTaskOutput":
    r"""<p>Creates a new tag-sync task to onboard and sync resources tagged with a specific tag key-value pair to an application. To start a tag-sync task, you need a <a href="https://docs.aws.amazon.com/servicecatalog/latest/arguide/app-tag-sync.html#tag-sync-role">resource tagging role</a>. The resource tagging role grants permissions to tag and untag applications resources and must include a trust policy that allows Resource Groups to assume the role and perform resource tagging tasks on your behalf. </p> <p>For instructions on creating a tag-sync task, see <a href="https://docs.aws.amazon.com/servicecatalog/latest/arguide/app-tag-sync.html#create-tag-sync">Create a tag-sync using the Resource Groups API</a> in the <i>Amazon Web Services Service Catalog AppRegistry Administrator Guide</i>. </p> <p> <b>Minimum permissions</b> </p> <p>To run this command, you must have the following permissions:</p> <ul> <li> <p> <code>resource-groups:StartTagSyncTask</code> on the application group</p> </li> <li> <p> <code>resource-groups:CreateGroup</code> </p> </li> <li> <p> <code>iam:PassRole</code> on the role provided in the request </p> </li> </ul>

    Args:
        group: <p>The Amazon resource name (ARN) or name of the application group for which you want to create a tag-sync task. </p>
        tag_key: <p>The tag key. Resources tagged with this tag key-value pair will be added to the application. If a resource with this tag is later untagged, the tag-sync task removes the resource from the application. </p> <p>When using the <code>TagKey</code> parameter, you must also specify the <code>TagValue</code> parameter. If you specify a tag key-value pair, you can't use the <code>ResourceQuery</code> parameter. </p>
        tag_value: <p>The tag value. Resources tagged with this tag key-value pair will be added to the application. If a resource with this tag is later untagged, the tag-sync task removes the resource from the application. </p> <p>When using the <code>TagValue</code> parameter, you must also specify the <code>TagKey</code> parameter. If you specify a tag key-value pair, you can't use the <code>ResourceQuery</code> parameter. </p>
        resource_query: <p>The query you can use to create the tag-sync task. With this method, all resources matching the query are added to the specified application group. A <code>ResourceQuery</code> specifies both a query <code>Type</code> and a <code>Query</code> string as JSON string objects. For more information on defining a resource query for a tag-sync task, see the tag-based query type in <a href="https://docs.aws.amazon.com/ARG/latest/userguide/gettingstarted-query.html#getting_started-query_types"> Types of resource group queries</a> in <i>Resource Groups User Guide</i>. </p> <p>When using the <code>ResourceQuery</code> parameter, you cannot use the <code>TagKey</code> and <code>TagValue</code> parameters. </p> <p>When you combine all of the elements together into a single string, any double quotes that are embedded inside another double quote pair must be escaped by preceding the embedded double quote with a backslash character (\). For example, a complete <code>ResourceQuery</code> parameter must be formatted like the following CLI parameter example:</p> <p> <code>--resource-query '{"Type":"TAG_FILTERS_1_0","Query":"{\"ResourceTypeFilters\":[\"AWS::AllSupported\"],\"TagFilters\":[{\"Key\":\"Stage\",\"Values\":[\"Test\"]}]}"}'</code> </p> <p>In the preceding example, all of the double quote characters in the value part of the <code>Query</code> element must be escaped because the value itself is surrounded by double quotes. For more information, see <a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-parameters-quoting-strings.html">Quoting strings</a> in the <i>Command Line Interface User Guide</i>.</p> <p>For the complete list of resource types that you can use in the array value for <code>ResourceTypeFilters</code>, see <a href="https://docs.aws.amazon.com/ARG/latest/userguide/supported-resources.html">Resources you can use with Resource Groups and Tag Editor</a> in the <i>Resource Groups User Guide</i>. For example:</p> <p> <code>"ResourceTypeFilters":["AWS::S3::Bucket", "AWS::EC2::Instance"]</code> </p>
        role_arn: <p>The Amazon resource name (ARN) of the role assumed by the service to tag and untag resources on your behalf.</p>

    Raises:
        capo_resource_groups.errors.bad_request_exception.BadRequestException: <p>The request includes one or more parameters that violate validation rules.</p>
        capo_resource_groups.errors.forbidden_exception.ForbiddenException: <p>The caller isn't authorized to make the request. Check permissions.</p>
        capo_resource_groups.errors.internal_server_error_exception.InternalServerErrorException: <p>An internal error occurred while processing the request. Try again later.</p>
        capo_resource_groups.errors.method_not_allowed_exception.MethodNotAllowedException: <p>The request uses an HTTP method that isn't allowed for the specified resource.</p>
        capo_resource_groups.errors.not_found_exception.NotFoundException: <p>One or more of the specified resources don't exist.</p>
        capo_resource_groups.errors.too_many_requests_exception.TooManyRequestsException: <p>You've exceeded throttling limits by making too many requests in a period of time.</p>
        capo_resource_groups.errors.unauthorized_exception.UnauthorizedException: <p>The request was rejected because it doesn't have valid credentials for the target resource.</p>
        capo_resource_groups.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_resource_groups.types.start_tag_sync_task_input.StartTagSyncTaskInput]",
    ) -> AsyncOperationResponse[
        "capo_resource_groups.types.start_tag_sync_task_output.StartTagSyncTaskOutput"
    ]:
        import capo_resource_groups._operations.ardi.start_tag_sync_task

        (
            output,
            http_response,
        ) = await capo_resource_groups._operations.ardi.start_tag_sync_task.async_start_tag_sync_task(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("StartTagSyncTask")
    )
    input_: capo_resource_groups.types.start_tag_sync_task_input.StartTagSyncTaskInput = {
        "group": group,
        "role_arn": role_arn,
    }
    if tag_key is not None:
        input_["tag_key"] = tag_key
    if tag_value is not None:
        input_["tag_value"] = tag_value
    if resource_query is not None:
        input_["resource_query"] = resource_query

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