Skip to content

create_capacity_reservation_fleet async

create_capacity_reservation_fleet(
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    allocation_strategy: Optional[String] = None,
    client_token: Optional[String] = None,
    instance_type_specifications: Optional[
        ReservationFleetInstanceSpecificationList
    ] = None,
    tenancy: Optional[FleetCapacityReservationTenancy] = None,
    total_target_capacity: Optional[Integer] = None,
    end_date: Optional[MillisecondDateTime] = None,
    instance_match_criteria: Optional[FleetInstanceMatchCriteria] = None,
    tag_specifications: Optional[TagSpecificationList] = None,
    dry_run: Optional[Boolean] = None,
) -> CreateCapacityReservationFleetResult

Creates a Capacity Reservation Fleet. For more information, see Create a Capacity Reservation Fleet in the Amazon EC2 User Guide.

Parameters:

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

    The strategy used by the Capacity Reservation Fleet to determine which of the specified instance types to use. Currently, only the prioritized allocation strategy is supported. For more information, see Allocation strategy in the Amazon EC2 User Guide.

    Valid values: prioritized

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

    Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see Ensure Idempotency.

  • instance_type_specifications (Optional[ReservationFleetInstanceSpecificationList], default: None ) –

    Information about the instance types for which to reserve the capacity.

  • tenancy (Optional[FleetCapacityReservationTenancy], default: None ) –

    Indicates the tenancy of the Capacity Reservation Fleet. All Capacity Reservations in the Fleet inherit this tenancy. The Capacity Reservation Fleet can have one of the following tenancy settings:

    • default - The Capacity Reservation Fleet is created on hardware that is shared with other Amazon Web Services accounts.

    • dedicated - The Capacity Reservations are created on single-tenant hardware that is dedicated to a single Amazon Web Services account.

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

    The total number of capacity units to be reserved by the Capacity Reservation Fleet. This value, together with the instance type weights that you assign to each instance type used by the Fleet determine the number of instances for which the Fleet reserves capacity. Both values are based on units that make sense for your workload. For more information, see Total target capacity in the Amazon EC2 User Guide.

  • end_date (Optional[MillisecondDateTime], default: None ) –

    The date and time at which the Capacity Reservation Fleet expires. When the Capacity Reservation Fleet expires, its state changes to expired and all of the Capacity Reservations in the Fleet expire.

    The Capacity Reservation Fleet expires within an hour after the specified time. For example, if you specify 5/31/2019, 13:30:55, the Capacity Reservation Fleet is guaranteed to expire between 13:30:55 and 14:30:55 on 5/31/2019.

  • instance_match_criteria (Optional[FleetInstanceMatchCriteria], default: None ) –

    Indicates the type of instance launches that the Capacity Reservation Fleet accepts. All Capacity Reservations in the Fleet inherit this instance matching criteria.

    Currently, Capacity Reservation Fleets support open instance matching criteria only. This means that instances that have matching attributes (instance type, platform, and Availability Zone) run in the Capacity Reservations automatically. Instances do not need to explicitly target a Capacity Reservation Fleet to use its reserved capacity.

  • tag_specifications (Optional[TagSpecificationList], default: None ) –

    The tags to assign to the Capacity Reservation Fleet. The tags are automatically assigned to the Capacity Reservations in the Fleet.

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

Raises:

Source code in docs_src/capo_ec2/_services/async_ec2.py
async def create_capacity_reservation_fleet(
    self,
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    allocation_strategy: Optional["capo_ec2.types.string.String"] = None,
    client_token: Optional["capo_ec2.types.string.String"] = None,
    instance_type_specifications: Optional[
        "capo_ec2.types.reservation_fleet_instance_specification_list.ReservationFleetInstanceSpecificationList"
    ] = None,
    tenancy: Optional[
        "capo_ec2.types.fleet_capacity_reservation_tenancy.FleetCapacityReservationTenancy"
    ] = None,
    total_target_capacity: Optional["capo_ec2.types.integer.Integer"] = None,
    end_date: Optional[
        "capo_ec2.types.millisecond_date_time.MillisecondDateTime"
    ] = None,
    instance_match_criteria: Optional[
        "capo_ec2.types.fleet_instance_match_criteria.FleetInstanceMatchCriteria"
    ] = None,
    tag_specifications: Optional[
        "capo_ec2.types.tag_specification_list.TagSpecificationList"
    ] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
) -> "capo_ec2.types.create_capacity_reservation_fleet_result.CreateCapacityReservationFleetResult":
    """<p>Creates a Capacity Reservation Fleet. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/work-with-cr-fleets.html#create-crfleet">Create a Capacity Reservation Fleet</a> in the <i>Amazon EC2 User Guide</i>.</p>

    Args:
        allocation_strategy: <p>The strategy used by the Capacity Reservation Fleet to determine which of the specified instance types to use. Currently, only the <code>prioritized</code> allocation strategy is supported. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/crfleet-concepts.html#allocation-strategy"> Allocation strategy</a> in the <i>Amazon EC2 User Guide</i>.</p> <p>Valid values: <code>prioritized</code> </p>
        client_token: <p>Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html">Ensure Idempotency</a>.</p>
        instance_type_specifications: <p>Information about the instance types for which to reserve the capacity.</p>
        tenancy: <p>Indicates the tenancy of the Capacity Reservation Fleet. All Capacity Reservations in the Fleet inherit this tenancy. The Capacity Reservation Fleet can have one of the following tenancy settings:</p> <ul> <li> <p> <code>default</code> - The Capacity Reservation Fleet is created on hardware that is shared with other Amazon Web Services accounts.</p> </li> <li> <p> <code>dedicated</code> - The Capacity Reservations are created on single-tenant hardware that is dedicated to a single Amazon Web Services account.</p> </li> </ul>
        total_target_capacity: <p>The total number of capacity units to be reserved by the Capacity Reservation Fleet. This value, together with the instance type weights that you assign to each instance type used by the Fleet determine the number of instances for which the Fleet reserves capacity. Both values are based on units that make sense for your workload. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/crfleet-concepts.html#target-capacity">Total target capacity</a> in the <i>Amazon EC2 User Guide</i>.</p>
        end_date: <p>The date and time at which the Capacity Reservation Fleet expires. When the Capacity Reservation Fleet expires, its state changes to <code>expired</code> and all of the Capacity Reservations in the Fleet expire.</p> <p>The Capacity Reservation Fleet expires within an hour after the specified time. For example, if you specify <code>5/31/2019</code>, <code>13:30:55</code>, the Capacity Reservation Fleet is guaranteed to expire between <code>13:30:55</code> and <code>14:30:55</code> on <code>5/31/2019</code>. </p>
        instance_match_criteria: <p>Indicates the type of instance launches that the Capacity Reservation Fleet accepts. All Capacity Reservations in the Fleet inherit this instance matching criteria.</p> <p>Currently, Capacity Reservation Fleets support <code>open</code> instance matching criteria only. This means that instances that have matching attributes (instance type, platform, and Availability Zone) run in the Capacity Reservations automatically. Instances do not need to explicitly target a Capacity Reservation Fleet to use its reserved capacity.</p>
        tag_specifications: <p>The tags to assign to the Capacity Reservation Fleet. The tags are automatically assigned to the Capacity Reservations in the Fleet.</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>

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

    async def _handler(
        req: "AsyncOperationRequest[capo_ec2.types.create_capacity_reservation_fleet_request.CreateCapacityReservationFleetRequest]",
    ) -> AsyncOperationResponse[
        "capo_ec2.types.create_capacity_reservation_fleet_result.CreateCapacityReservationFleetResult"
    ]:
        import capo_ec2._operations.amazon_ec2.create_capacity_reservation_fleet

        (
            output,
            http_response,
        ) = await capo_ec2._operations.amazon_ec2.create_capacity_reservation_fleet.async_create_capacity_reservation_fleet(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateCapacityReservationFleet")
    )
    input_: capo_ec2.types.create_capacity_reservation_fleet_request.CreateCapacityReservationFleetRequest = {}
    if allocation_strategy is not None:
        input_["allocation_strategy"] = allocation_strategy
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if instance_type_specifications is not None:
        input_["instance_type_specifications"] = instance_type_specifications
    if tenancy is not None:
        input_["tenancy"] = tenancy
    if total_target_capacity is not None:
        input_["total_target_capacity"] = total_target_capacity
    if end_date is not None:
        input_["end_date"] = end_date
    if instance_match_criteria is not None:
        input_["instance_match_criteria"] = instance_match_criteria
    if tag_specifications is not None:
        input_["tag_specifications"] = tag_specifications
    if dry_run is not None:
        input_["dry_run"] = dry_run

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