Skip to content

launch_instances

launch_instances(
    *,
    config_overrides: Optional[AutoScalingClientConfig] = None,
    auto_scaling_group_name: Optional[XmlStringMaxLen255] = None,
    requested_capacity: Optional[RequestedCapacity] = None,
    client_token: Optional[ClientToken] = None,
    availability_zones: Optional[AvailabilityZonesLimit1] = None,
    availability_zone_ids: Optional[AvailabilityZoneIdsLimit1] = None,
    subnet_ids: Optional[SubnetIdsLimit1] = None,
    retry_strategy: Optional[RetryStrategy] = None,
) -> LaunchInstancesResult

Launches a specified number of instances in an Auto Scaling group. Returns instance IDs and other details if launch is successful or error details if launch is unsuccessful.

Parameters:

  • auto_scaling_group_name (Optional[XmlStringMaxLen255], default: None ) –

    The name of the Auto Scaling group to launch instances into.

  • requested_capacity (Optional[RequestedCapacity], default: None ) –

    The number of instances to launch. Although this value can exceed 100 for instance weights, the actual instance count is limited to 100 instances per launch.

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

    A unique, case-sensitive identifier to ensure idempotency of the request.

  • availability_zones (Optional[AvailabilityZonesLimit1], default: None ) –

    The Availability Zones for the instance launch. Must match or be included in the Auto Scaling group's Availability Zone configuration. Either AvailabilityZones or SubnetIds must be specified for groups with multiple Availability Zone configurations.

  • availability_zone_ids (Optional[AvailabilityZoneIdsLimit1], default: None ) –

    A list of Availability Zone IDs where instances should be launched. Must match or be included in the group's AZ configuration. You cannot specify both AvailabilityZones and AvailabilityZoneIds. Required for multi-AZ groups, optional for single-AZ groups.

  • subnet_ids (Optional[SubnetIdsLimit1], default: None ) –

    The subnet IDs for the instance launch. Either AvailabilityZones or SubnetIds must be specified. If both are specified, the subnets must reside in the specified Availability Zones.

  • retry_strategy (Optional[RetryStrategy], default: None ) –

    Specifies whether to retry asynchronously if the synchronous launch fails. Valid values are NONE (default, no async retry) and RETRY_WITH_GROUP_CONFIGURATION (increase desired capacity and retry with group configuration).

Raises:

  • IdempotentCallInProgressFault –

    The service is currently processing another request with the same client token. Retry the request with the same client token—the in-flight operation will complete and return its result.

  • IdempotentParameterMismatchError –

    Indicates that the parameters in the current request do not match the parameters from a previous request with the same client token within the idempotency window.

  • ResourceContentionFault –

    You already have a pending update to an Amazon EC2 Auto Scaling resource (for example, an Auto Scaling group, instance, or load balancer).

  • UnknownServiceError –

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

Source code in docs_src/capo_auto_scaling/_services/auto_scaling.py
def launch_instances(
    self,
    *,
    config_overrides: Optional[AutoScalingClientConfig] = None,
    auto_scaling_group_name: Optional[
        "capo_auto_scaling.types.xml_string_max_len255.XmlStringMaxLen255"
    ] = None,
    requested_capacity: Optional[
        "capo_auto_scaling.types.requested_capacity.RequestedCapacity"
    ] = None,
    client_token: Optional[
        "capo_auto_scaling.types.client_token.ClientToken"
    ] = None,
    availability_zones: Optional[
        "capo_auto_scaling.types.availability_zones_limit1.AvailabilityZonesLimit1"
    ] = None,
    availability_zone_ids: Optional[
        "capo_auto_scaling.types.availability_zone_ids_limit1.AvailabilityZoneIdsLimit1"
    ] = None,
    subnet_ids: Optional[
        "capo_auto_scaling.types.subnet_ids_limit1.SubnetIdsLimit1"
    ] = None,
    retry_strategy: Optional[
        "capo_auto_scaling.types.retry_strategy.RetryStrategy"
    ] = None,
) -> "capo_auto_scaling.types.launch_instances_result.LaunchInstancesResult":
    """<p> Launches a specified number of instances in an Auto Scaling group. Returns instance IDs and other details if launch is successful or error details if launch is unsuccessful. </p>

    Args:
        auto_scaling_group_name: <p> The name of the Auto Scaling group to launch instances into. </p>
        requested_capacity: <p> The number of instances to launch. Although this value can exceed 100 for instance weights, the actual instance count is limited to 100 instances per launch. </p>
        client_token: <p> A unique, case-sensitive identifier to ensure idempotency of the request. </p>
        availability_zones: <p> The Availability Zones for the instance launch. Must match or be included in the Auto Scaling group's Availability Zone configuration. Either <code>AvailabilityZones</code> or <code>SubnetIds</code> must be specified for groups with multiple Availability Zone configurations. </p>
        availability_zone_ids: <p> A list of Availability Zone IDs where instances should be launched. Must match or be included in the group's AZ configuration. You cannot specify both AvailabilityZones and AvailabilityZoneIds. Required for multi-AZ groups, optional for single-AZ groups. </p>
        subnet_ids: <p> The subnet IDs for the instance launch. Either <code>AvailabilityZones</code> or <code>SubnetIds</code> must be specified. If both are specified, the subnets must reside in the specified Availability Zones. </p>
        retry_strategy: <p> Specifies whether to retry asynchronously if the synchronous launch fails. Valid values are NONE (default, no async retry) and RETRY_WITH_GROUP_CONFIGURATION (increase desired capacity and retry with group configuration). </p>

    Raises:
        capo_auto_scaling.errors.idempotent_call_in_progress_fault.IdempotentCallInProgressFault: <p> The service is currently processing another request with the same client token. Retry the request with the same client token—the in-flight operation will complete and return its result. </p>
        capo_auto_scaling.errors.idempotent_parameter_mismatch_error.IdempotentParameterMismatchError: <p> Indicates that the parameters in the current request do not match the parameters from a previous request with the same client token within the idempotency window. </p>
        capo_auto_scaling.errors.resource_contention_fault.ResourceContentionFault: <p>You already have a pending update to an Amazon EC2 Auto Scaling resource (for example, an Auto Scaling group, instance, or load balancer).</p>
        capo_auto_scaling.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_auto_scaling.types.launch_instances_request.LaunchInstancesRequest]",
    ) -> OperationResponse[
        "capo_auto_scaling.types.launch_instances_result.LaunchInstancesResult"
    ]:
        import capo_auto_scaling._operations.auto_scaling_2011_01_01.launch_instances

        output, http_response = (
            capo_auto_scaling._operations.auto_scaling_2011_01_01.launch_instances.launch_instances(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("LaunchInstances")
    )
    input_: capo_auto_scaling.types.launch_instances_request.LaunchInstancesRequest = {}
    if auto_scaling_group_name is not None:
        input_["auto_scaling_group_name"] = auto_scaling_group_name
    if requested_capacity is not None:
        input_["requested_capacity"] = requested_capacity
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if availability_zones is not None:
        input_["availability_zones"] = availability_zones
    if availability_zone_ids is not None:
        input_["availability_zone_ids"] = availability_zone_ids
    if subnet_ids is not None:
        input_["subnet_ids"] = subnet_ids
    if retry_strategy is not None:
        input_["retry_strategy"] = retry_strategy

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