Skip to content

run_scheduled_instances

run_scheduled_instances(
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    client_token: Optional[String] = None,
    dry_run: Optional[Boolean] = None,
    instance_count: Optional[Integer] = None,
    launch_specification: Optional[ScheduledInstancesLaunchSpecification] = None,
    scheduled_instance_id: Optional[ScheduledInstanceId] = None,
) -> RunScheduledInstancesResult

Launches the specified Scheduled Instances.

Before you can launch a Scheduled Instance, you must purchase it and obtain an identifier using PurchaseScheduledInstances.

You must launch a Scheduled Instance during its scheduled time period. You can't stop or reboot a Scheduled Instance, but you can terminate it as needed. If you terminate a Scheduled Instance before the current scheduled time period ends, you can launch it again after a few minutes.

Parameters:

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

    Unique, case-sensitive identifier that ensures the idempotency of the request. For more information, see Ensuring Idempotency.

  • dry_run (Optional[Boolean], default: None ) –

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

  • instance_count (Optional[Integer], default: None ) –

    The number of instances.

    Default: 1

  • launch_specification (Optional[ScheduledInstancesLaunchSpecification], default: None ) –

    The launch specification. You must match the instance type, Availability Zone, network, and platform of the schedule that you purchased.

  • scheduled_instance_id (Optional[ScheduledInstanceId], default: None ) –

    The Scheduled Instance ID.

Raises:

Source code in docs_src/capo_ec2/_services/ec2.py
def run_scheduled_instances(
    self,
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    client_token: Optional["capo_ec2.types.string.String"] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
    instance_count: Optional["capo_ec2.types.integer.Integer"] = None,
    launch_specification: Optional[
        "capo_ec2.types.scheduled_instances_launch_specification.ScheduledInstancesLaunchSpecification"
    ] = None,
    scheduled_instance_id: Optional[
        "capo_ec2.types.scheduled_instance_id.ScheduledInstanceId"
    ] = None,
) -> "capo_ec2.types.run_scheduled_instances_result.RunScheduledInstancesResult":
    """<p>Launches the specified Scheduled Instances.</p> <p>Before you can launch a Scheduled Instance, you must purchase it and obtain an identifier using <a>PurchaseScheduledInstances</a>.</p> <p>You must launch a Scheduled Instance during its scheduled time period. You can't stop or reboot a Scheduled Instance, but you can terminate it as needed. If you terminate a Scheduled Instance before the current scheduled time period ends, you can launch it again after a few minutes.</p>

    Args:
        client_token: <p>Unique, case-sensitive identifier that ensures the idempotency of the request. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html">Ensuring Idempotency</a>.</p>
        dry_run: <p>Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>
        instance_count: <p>The number of instances.</p> <p>Default: 1</p>
        launch_specification: <p>The launch specification. You must match the instance type, Availability Zone, network, and platform of the schedule that you purchased.</p>
        scheduled_instance_id: <p>The Scheduled Instance ID.</p>

    Raises:
        capo_ec2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_ec2.types.run_scheduled_instances_request.RunScheduledInstancesRequest]",
    ) -> OperationResponse[
        "capo_ec2.types.run_scheduled_instances_result.RunScheduledInstancesResult"
    ]:
        import capo_ec2._operations.amazon_ec2.run_scheduled_instances

        output, http_response = (
            capo_ec2._operations.amazon_ec2.run_scheduled_instances.run_scheduled_instances(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_ec2.types.run_scheduled_instances_request.RunScheduledInstancesRequest",
    ) -> dict[str, Any]:
        import capo_ec2.types.run_scheduled_instances_request

        return capo_ec2.types.run_scheduled_instances_request.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("RunScheduledInstances", redact_input=_redact_input),
    )
    input_: capo_ec2.types.run_scheduled_instances_request.RunScheduledInstancesRequest = {}
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if dry_run is not None:
        input_["dry_run"] = dry_run
    if instance_count is not None:
        input_["instance_count"] = instance_count
    if launch_specification is not None:
        input_["launch_specification"] = launch_specification
    if scheduled_instance_id is not None:
        input_["scheduled_instance_id"] = scheduled_instance_id

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