Skip to content

create_task_set async

create_task_set(
    service: String,
    cluster: String,
    task_definition: String,
    *,
    config_overrides: Optional[AsyncECSClientConfig] = None,
    external_id: Optional[String] = None,
    network_configuration: Optional[NetworkConfiguration] = None,
    load_balancers: Optional[LoadBalancers] = None,
    service_registries: Optional[ServiceRegistries] = None,
    launch_type: Optional[LaunchType] = None,
    capacity_provider_strategy: Optional[CapacityProviderStrategy] = None,
    platform_version: Optional[String] = None,
    scale: Optional[Scale] = None,
    client_token: Optional[String] = None,
    tags: Optional[Tags] = None,
) -> CreateTaskSetResponse

Create a task set in the specified cluster and service. This is used when a service uses the EXTERNAL deployment controller type. For more information, see Amazon ECS deployment types in the Amazon Elastic Container Service Developer Guide.

On March 21, 2024, a change was made to resolve the task definition revision before authorization. When a task definition revision is not specified, authorization will occur using the latest revision of a task definition.

For information about the maximum number of task sets and other quotas, see Amazon ECS service quotas in the Amazon Elastic Container Service Developer Guide.

Parameters:

  • service (String) –

    The short name or full Amazon Resource Name (ARN) of the service to create the task set in.

  • cluster (String) –

    The short name or full Amazon Resource Name (ARN) of the cluster that hosts the service to create the task set in.

  • external_id (Optional[String], default: None ) –

    An optional non-unique tag that identifies this task set in external systems. If the task set is associated with a service discovery registry, the tasks in this task set will have the ECS_TASK_SET_EXTERNAL_ID Cloud Map attribute set to the provided value.

  • task_definition (String) –

    The task definition for the tasks in the task set to use. If a revision isn't specified, the latest ACTIVE revision is used.

  • network_configuration (Optional[NetworkConfiguration], default: None ) –

    An object representing the network configuration for a task set.

  • load_balancers (Optional[LoadBalancers], default: None ) –

    A load balancer object representing the load balancer to use with the task set. The supported load balancer types are either an Application Load Balancer or a Network Load Balancer.

  • service_registries (Optional[ServiceRegistries], default: None ) –

    The details of the service discovery registries to assign to this task set. For more information, see Service discovery.

  • launch_type (Optional[LaunchType], default: None ) –

    The launch type that new tasks in the task set uses. For more information, see Amazon ECS launch types in the Amazon Elastic Container Service Developer Guide.

    If a launchType is specified, the capacityProviderStrategy parameter must be omitted.

  • capacity_provider_strategy (Optional[CapacityProviderStrategy], default: None ) –

    The capacity provider strategy to use for the task set.

    A capacity provider strategy consists of one or more capacity providers along with the base and weight to assign to them. A capacity provider must be associated with the cluster to be used in a capacity provider strategy. The PutClusterCapacityProviders API is used to associate a capacity provider with a cluster. Only capacity providers with an ACTIVE or UPDATING status can be used.

    If a capacityProviderStrategy is specified, the launchType parameter must be omitted. If no capacityProviderStrategy or launchType is specified, the defaultCapacityProviderStrategy for the cluster is used.

    If specifying a capacity provider that uses an Auto Scaling group, the capacity provider must already be created. New capacity providers can be created with the CreateCapacityProviderProviderAPI operation.

    To use a Fargate capacity provider, specify either the FARGATE or FARGATE_SPOT capacity providers. The Fargate capacity providers are available to all accounts and only need to be associated with a cluster to be used.

    The PutClusterCapacityProviders API operation is used to update the list of available capacity providers for a cluster after the cluster is created.

  • platform_version (Optional[String], default: None ) –

    The platform version that the tasks in the task set uses. A platform version is specified only for tasks using the Fargate launch type. If one isn't specified, the LATEST platform version is used.

  • scale (Optional[Scale], default: None ) –

    A floating-point percentage of the desired number of tasks to place and keep running in the task set.

  • client_token (Optional[String], default: None ) –

    An identifier that you provide to ensure the idempotency of the request. It must be unique and is case sensitive. Up to 36 ASCII characters in the range of 33-126 (inclusive) are allowed.

  • tags (Optional[Tags], default: None ) –

    The metadata that you apply to the task set to help you categorize and organize them. Each tag consists of a key and an optional value. You define both. When a service is deleted, the tags are deleted.

    The following basic restrictions apply to tags:

    • Maximum number of tags per resource - 50

    • For each resource, each tag key must be unique, and each tag key can have only one value.

    • Maximum key length - 128 Unicode characters in UTF-8

    • Maximum value length - 256 Unicode characters in UTF-8

    • If your tagging schema is used across multiple services and resources, remember that other services may have restrictions on allowed characters. Generally allowed characters are: letters, numbers, and spaces representable in UTF-8, and the following characters: + - = . _ : / @.

    • Tag keys and values are case-sensitive.

    • Do not use aws:, AWS:, or any upper or lowercase combination of such as a prefix for either keys or values as it is reserved for Amazon Web Services use. You cannot edit or delete tag keys or values with this prefix. Tags with this prefix do not count against your tags per resource limit.

Raises:

Examples:

To create a task set This example creates a task set in a service that uses the EXTERNAL deployment controller.

>>> await client.create_task_set(service='MyService', cluster='MyCluster', task_definition='MyTaskDefinition:2', network_configuration={'awsvpcConfiguration': {'subnets': ['subnet-12344321'], 'securityGroups': ['sg-12344321']}})
Source code in docs_src/capo_ecs/_services/async_ecs.py
async def create_task_set(
    self,
    service: "capo_ecs.types.string.String",
    cluster: "capo_ecs.types.string.String",
    task_definition: "capo_ecs.types.string.String",
    *,
    config_overrides: Optional[AsyncECSClientConfig] = None,
    external_id: Optional["capo_ecs.types.string.String"] = None,
    network_configuration: Optional[
        "capo_ecs.types.network_configuration.NetworkConfiguration"
    ] = None,
    load_balancers: Optional["capo_ecs.types.load_balancers.LoadBalancers"] = None,
    service_registries: Optional[
        "capo_ecs.types.service_registries.ServiceRegistries"
    ] = None,
    launch_type: Optional["capo_ecs.types.launch_type.LaunchType"] = None,
    capacity_provider_strategy: Optional[
        "capo_ecs.types.capacity_provider_strategy.CapacityProviderStrategy"
    ] = None,
    platform_version: Optional["capo_ecs.types.string.String"] = None,
    scale: Optional["capo_ecs.types.scale.Scale"] = None,
    client_token: Optional["capo_ecs.types.string.String"] = None,
    tags: Optional["capo_ecs.types.tags.Tags"] = None,
) -> "capo_ecs.types.create_task_set_response.CreateTaskSetResponse":
    """<p>Create a task set in the specified cluster and service. This is used when a service uses the <code>EXTERNAL</code> deployment controller type. For more information, see <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-types.html">Amazon ECS deployment types</a> in the <i>Amazon Elastic Container Service Developer Guide</i>.</p> <note> <p>On March 21, 2024, a change was made to resolve the task definition revision before authorization. When a task definition revision is not specified, authorization will occur using the latest revision of a task definition.</p> </note> <p>For information about the maximum number of task sets and other quotas, see <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-quotas.html">Amazon ECS service quotas</a> in the <i>Amazon Elastic Container Service Developer Guide</i>.</p>

    Args:
        service: <p>The short name or full Amazon Resource Name (ARN) of the service to create the task set in.</p>
        cluster: <p>The short name or full Amazon Resource Name (ARN) of the cluster that hosts the service to create the task set in.</p>
        external_id: <p>An optional non-unique tag that identifies this task set in external systems. If the task set is associated with a service discovery registry, the tasks in this task set will have the <code>ECS_TASK_SET_EXTERNAL_ID</code> Cloud Map attribute set to the provided value.</p>
        task_definition: <p>The task definition for the tasks in the task set to use. If a revision isn't specified, the latest <code>ACTIVE</code> revision is used.</p>
        network_configuration: <p>An object representing the network configuration for a task set.</p>
        load_balancers: <p>A load balancer object representing the load balancer to use with the task set. The supported load balancer types are either an Application Load Balancer or a Network Load Balancer.</p>
        service_registries: <p>The details of the service discovery registries to assign to this task set. For more information, see <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-discovery.html">Service discovery</a>.</p>
        launch_type: <p>The launch type that new tasks in the task set uses. For more information, see <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/launch_types.html">Amazon ECS launch types</a> in the <i>Amazon Elastic Container Service Developer Guide</i>.</p> <p>If a <code>launchType</code> is specified, the <code>capacityProviderStrategy</code> parameter must be omitted.</p>
        capacity_provider_strategy: <p>The capacity provider strategy to use for the task set.</p> <p>A capacity provider strategy consists of one or more capacity providers along with the <code>base</code> and <code>weight</code> to assign to them. A capacity provider must be associated with the cluster to be used in a capacity provider strategy. The <a href="https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_PutClusterCapacityProviders.html">PutClusterCapacityProviders</a> API is used to associate a capacity provider with a cluster. Only capacity providers with an <code>ACTIVE</code> or <code>UPDATING</code> status can be used.</p> <p>If a <code>capacityProviderStrategy</code> is specified, the <code>launchType</code> parameter must be omitted. If no <code>capacityProviderStrategy</code> or <code>launchType</code> is specified, the <code>defaultCapacityProviderStrategy</code> for the cluster is used.</p> <p>If specifying a capacity provider that uses an Auto Scaling group, the capacity provider must already be created. New capacity providers can be created with the <a href="https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_CreateCapacityProviderProvider.html">CreateCapacityProviderProvider</a>API operation.</p> <p>To use a Fargate capacity provider, specify either the <code>FARGATE</code> or <code>FARGATE_SPOT</code> capacity providers. The Fargate capacity providers are available to all accounts and only need to be associated with a cluster to be used.</p> <p>The <a href="https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_PutClusterCapacityProviders.html">PutClusterCapacityProviders</a> API operation is used to update the list of available capacity providers for a cluster after the cluster is created.</p>
        platform_version: <p>The platform version that the tasks in the task set uses. A platform version is specified only for tasks using the Fargate launch type. If one isn't specified, the <code>LATEST</code> platform version is used.</p>
        scale: <p>A floating-point percentage of the desired number of tasks to place and keep running in the task set.</p>
        client_token: <p>An identifier that you provide to ensure the idempotency of the request. It must be unique and is case sensitive. Up to 36 ASCII characters in the range of 33-126 (inclusive) are allowed.</p>
        tags: <p>The metadata that you apply to the task set to help you categorize and organize them. Each tag consists of a key and an optional value. You define both. When a service is deleted, the tags are deleted.</p> <p>The following basic restrictions apply to tags:</p> <ul> <li> <p>Maximum number of tags per resource - 50</p> </li> <li> <p>For each resource, each tag key must be unique, and each tag key can have only one value.</p> </li> <li> <p>Maximum key length - 128 Unicode characters in UTF-8</p> </li> <li> <p>Maximum value length - 256 Unicode characters in UTF-8</p> </li> <li> <p>If your tagging schema is used across multiple services and resources, remember that other services may have restrictions on allowed characters. Generally allowed characters are: letters, numbers, and spaces representable in UTF-8, and the following characters: + - = . _ : / @.</p> </li> <li> <p>Tag keys and values are case-sensitive.</p> </li> <li> <p>Do not use <code>aws:</code>, <code>AWS:</code>, or any upper or lowercase combination of such as a prefix for either keys or values as it is reserved for Amazon Web Services use. You cannot edit or delete tag keys or values with this prefix. Tags with this prefix do not count against your tags per resource limit.</p> </li> </ul>

    Raises:
        capo_ecs.errors.access_denied_exception.AccessDeniedException: <p>You don't have authorization to perform the requested action.</p>
        capo_ecs.errors.client_exception.ClientException: <p>These errors are usually caused by a client action. This client action might be using an action or resource on behalf of a user that doesn't have permissions to use the action or resource. Or, it might be specifying an identifier that isn't valid.</p>
        capo_ecs.errors.cluster_not_found_exception.ClusterNotFoundException: <p>The specified cluster wasn't found. You can view your available clusters with <a href="https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ListClusters.html">ListClusters</a>. Amazon ECS clusters are Region specific.</p>
        capo_ecs.errors.invalid_parameter_exception.InvalidParameterException: <p>The specified parameter isn't valid. Review the available parameters for the API request.</p> <p>For more information about service event errors, see <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-event-messages-list.html">Amazon ECS service event messages</a>. </p>
        capo_ecs.errors.limit_exceeded_exception.LimitExceededException: <p>The limit for the resource was exceeded.</p>
        capo_ecs.errors.namespace_not_found_exception.NamespaceNotFoundException: <p>The specified namespace wasn't found.</p>
        capo_ecs.errors.platform_task_definition_incompatibility_exception.PlatformTaskDefinitionIncompatibilityException: <p>The specified platform version doesn't satisfy the required capabilities of the task definition.</p>
        capo_ecs.errors.platform_unknown_exception.PlatformUnknownException: <p>The specified platform version doesn't exist.</p>
        capo_ecs.errors.server_exception.ServerException: <p>These errors are usually caused by a server issue.</p>
        capo_ecs.errors.service_not_active_exception.ServiceNotActiveException: <p>The specified service isn't active. You can't update a service that's inactive. If you have previously deleted a service, you can re-create it with <a href="https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_CreateService.html">CreateService</a>.</p>
        capo_ecs.errors.service_not_found_exception.ServiceNotFoundException: <p>The specified service wasn't found. You can view your available services with <a href="https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ListServices.html">ListServices</a>. Amazon ECS services are cluster specific and Region specific.</p>
        capo_ecs.errors.unsupported_feature_exception.UnsupportedFeatureException: <p>The specified task isn't supported in this Region.</p>
        capo_ecs.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To create a task set
        This example creates a task set in a service that uses the EXTERNAL deployment controller.

        >>> await client.create_task_set(service='MyService', cluster='MyCluster', task_definition='MyTaskDefinition:2', network_configuration={'awsvpcConfiguration': {'subnets': ['subnet-12344321'], 'securityGroups': ['sg-12344321']}})
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_ecs.types.create_task_set_request.CreateTaskSetRequest]",
    ) -> AsyncOperationResponse[
        "capo_ecs.types.create_task_set_response.CreateTaskSetResponse"
    ]:
        import capo_ecs._operations.amazon_ec2_container_service_v20141113.create_task_set

        (
            output,
            http_response,
        ) = await capo_ecs._operations.amazon_ec2_container_service_v20141113.create_task_set.async_create_task_set(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateTaskSet")
    )
    input_: capo_ecs.types.create_task_set_request.CreateTaskSetRequest = {
        "service": service,
        "cluster": cluster,
        "task_definition": task_definition,
    }
    if external_id is not None:
        input_["external_id"] = external_id
    if network_configuration is not None:
        input_["network_configuration"] = network_configuration
    if load_balancers is not None:
        input_["load_balancers"] = load_balancers
    if service_registries is not None:
        input_["service_registries"] = service_registries
    if launch_type is not None:
        input_["launch_type"] = launch_type
    if capacity_provider_strategy is not None:
        input_["capacity_provider_strategy"] = capacity_provider_strategy
    if platform_version is not None:
        input_["platform_version"] = platform_version
    if scale is not None:
        input_["scale"] = scale
    if client_token is not None:
        input_["client_token"] = client_token
    if tags is not None:
        input_["tags"] = tags

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