Skip to content

purchase_reserved_instances_offering

purchase_reserved_instances_offering(
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    instance_count: Optional[Integer] = None,
    reserved_instances_offering_id: Optional[ReservedInstancesOfferingId] = None,
    purchase_time: Optional[DateTime] = None,
    dry_run: Optional[Boolean] = None,
    limit_price: Optional[ReservedInstanceLimitPrice] = None,
) -> PurchaseReservedInstancesOfferingResult

Purchases a Reserved Instance for use with your account. With Reserved Instances, you pay a lower hourly rate compared to On-Demand instance pricing.

Use DescribeReservedInstancesOfferings to get a list of Reserved Instance offerings that match your specifications. After you've purchased a Reserved Instance, you can check for your new Reserved Instance with DescribeReservedInstances.

To queue a purchase for a future date and time, specify a purchase time. If you do not specify a purchase time, the default is the current time.

For more information, see Reserved Instances and Sell in the Reserved Instance Marketplace in the Amazon EC2 User Guide.

Parameters:

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

    The number of Reserved Instances to purchase.

  • reserved_instances_offering_id (Optional[ReservedInstancesOfferingId], default: None ) –

    The ID of the Reserved Instance offering to purchase.

  • purchase_time (Optional[DateTime], default: None ) –

    The time at which to purchase the Reserved Instance, in UTC format (for example, YYYY-MM-DDTHH:MM:SSZ).

  • 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.

  • limit_price (Optional[ReservedInstanceLimitPrice], default: None ) –

    Specified for Reserved Instance Marketplace offerings to limit the total order and ensure that the Reserved Instances are not purchased at unexpected prices.

Raises:

Source code in docs_src/capo_ec2/_services/ec2.py
def purchase_reserved_instances_offering(
    self,
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    instance_count: Optional["capo_ec2.types.integer.Integer"] = None,
    reserved_instances_offering_id: Optional[
        "capo_ec2.types.reserved_instances_offering_id.ReservedInstancesOfferingId"
    ] = None,
    purchase_time: Optional["capo_ec2.types.date_time.DateTime"] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
    limit_price: Optional[
        "capo_ec2.types.reserved_instance_limit_price.ReservedInstanceLimitPrice"
    ] = None,
) -> "capo_ec2.types.purchase_reserved_instances_offering_result.PurchaseReservedInstancesOfferingResult":
    """<p>Purchases a Reserved Instance for use with your account. With Reserved Instances, you pay a lower hourly rate compared to On-Demand instance pricing.</p> <p>Use <a>DescribeReservedInstancesOfferings</a> to get a list of Reserved Instance offerings that match your specifications. After you've purchased a Reserved Instance, you can check for your new Reserved Instance with <a>DescribeReservedInstances</a>.</p> <p>To queue a purchase for a future date and time, specify a purchase time. If you do not specify a purchase time, the default is the current time.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/concepts-on-demand-reserved-instances.html">Reserved Instances</a> and <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ri-market-general.html">Sell in the Reserved Instance Marketplace</a> in the <i>Amazon EC2 User Guide</i>.</p>

    Args:
        instance_count: <p>The number of Reserved Instances to purchase.</p>
        reserved_instances_offering_id: <p>The ID of the Reserved Instance offering to purchase.</p>
        purchase_time: <p>The time at which to purchase the Reserved Instance, in UTC format (for example, <i>YYYY</i>-<i>MM</i>-<i>DD</i>T<i>HH</i>:<i>MM</i>:<i>SS</i>Z).</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>
        limit_price: <p>Specified for Reserved Instance Marketplace offerings to limit the total order and ensure that the Reserved Instances are not purchased at unexpected prices.</p>

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

    def _handler(
        req: "OperationRequest[capo_ec2.types.purchase_reserved_instances_offering_request.PurchaseReservedInstancesOfferingRequest]",
    ) -> OperationResponse[
        "capo_ec2.types.purchase_reserved_instances_offering_result.PurchaseReservedInstancesOfferingResult"
    ]:
        import capo_ec2._operations.amazon_ec2.purchase_reserved_instances_offering

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PurchaseReservedInstancesOffering")
    )
    input_: capo_ec2.types.purchase_reserved_instances_offering_request.PurchaseReservedInstancesOfferingRequest = {}
    if instance_count is not None:
        input_["instance_count"] = instance_count
    if reserved_instances_offering_id is not None:
        input_["reserved_instances_offering_id"] = reserved_instances_offering_id
    if purchase_time is not None:
        input_["purchase_time"] = purchase_time
    if dry_run is not None:
        input_["dry_run"] = dry_run
    if limit_price is not None:
        input_["limit_price"] = limit_price

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