Skip to content

get_spot_placement_scores async

get_spot_placement_scores(
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    instance_types: Optional[InstanceTypes] = None,
    target_capacity: Optional[SpotPlacementScoresTargetCapacity] = None,
    target_capacity_unit_type: Optional[TargetCapacityUnitType] = None,
    single_availability_zone: Optional[Boolean] = None,
    region_names: Optional[RegionNames] = None,
    instance_requirements_with_metadata: Optional[
        InstanceRequirementsWithMetadataRequest
    ] = None,
    dry_run: Optional[Boolean] = None,
    max_results: Optional[SpotPlacementScoresMaxResults] = None,
    next_token: Optional[String] = None,
    include_local_zones: Optional[Boolean] = None,
) -> GetSpotPlacementScoresResult

Calculates the Spot placement score for a Region or Availability Zone based on the specified target capacity and compute requirements.

You can specify your compute requirements either by using InstanceRequirementsWithMetadata and letting Amazon EC2 choose the optimal instance types to fulfill your Spot request, or you can specify the instance types by using InstanceTypes.

For more information, see Spot placement score in the Amazon EC2 User Guide.

Parameters:

  • instance_types (Optional[InstanceTypes], default: None ) –

    The instance types. We recommend that you specify at least three instance types. If you specify one or two instance types, or specify variations of a single instance type (for example, an m3.xlarge with and without instance storage), the returned placement score will always be low.

    If you specify InstanceTypes, you can't specify InstanceRequirementsWithMetadata.

  • target_capacity (Optional[SpotPlacementScoresTargetCapacity], default: None ) –

    The target capacity.

  • target_capacity_unit_type (Optional[TargetCapacityUnitType], default: None ) –

    The unit for the target capacity.

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

    Specify true so that the response returns a list of scored Availability Zones. Otherwise, the response returns a list of scored Regions.

    A list of scored Availability Zones is useful if you want to launch all of your Spot capacity into a single Availability Zone.

  • region_names (Optional[RegionNames], default: None ) –

    The Regions used to narrow down the list of Regions to be scored. Enter the Region code, for example, us-east-1.

  • instance_requirements_with_metadata (Optional[InstanceRequirementsWithMetadataRequest], default: None ) –

    The attributes for the instance types. When you specify instance attributes, Amazon EC2 will identify instance types with those attributes.

    If you specify InstanceRequirementsWithMetadata, you can't specify InstanceTypes.

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

  • max_results (Optional[SpotPlacementScoresMaxResults], default: None ) –

    The maximum number of items to return for this request. To get the next page of items, make another request with the token returned in the output. For more information, see Pagination.

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

    The token returned from a previous paginated request. Pagination continues from the end of the items returned by the previous request.

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

    Specify true so that the response returns scores that include Local Zones. Otherwise, the response ignores Local Zones.

    When you request regional scores, Local Zone capacity counts toward its parent Region.

Raises:

Source code in docs_src/capo_ec2/_services/async_ec2.py
async def get_spot_placement_scores(
    self,
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    instance_types: Optional["capo_ec2.types.instance_types.InstanceTypes"] = None,
    target_capacity: Optional[
        "capo_ec2.types.spot_placement_scores_target_capacity.SpotPlacementScoresTargetCapacity"
    ] = None,
    target_capacity_unit_type: Optional[
        "capo_ec2.types.target_capacity_unit_type.TargetCapacityUnitType"
    ] = None,
    single_availability_zone: Optional["capo_ec2.types.boolean.Boolean"] = None,
    region_names: Optional["capo_ec2.types.region_names.RegionNames"] = None,
    instance_requirements_with_metadata: Optional[
        "capo_ec2.types.instance_requirements_with_metadata_request.InstanceRequirementsWithMetadataRequest"
    ] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
    max_results: Optional[
        "capo_ec2.types.spot_placement_scores_max_results.SpotPlacementScoresMaxResults"
    ] = None,
    next_token: Optional["capo_ec2.types.string.String"] = None,
    include_local_zones: Optional["capo_ec2.types.boolean.Boolean"] = None,
) -> "capo_ec2.types.get_spot_placement_scores_result.GetSpotPlacementScoresResult":
    """<p>Calculates the Spot placement score for a Region or Availability Zone based on the specified target capacity and compute requirements.</p> <p>You can specify your compute requirements either by using <code>InstanceRequirementsWithMetadata</code> and letting Amazon EC2 choose the optimal instance types to fulfill your Spot request, or you can specify the instance types by using <code>InstanceTypes</code>.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-placement-score.html">Spot placement score</a> in the <i>Amazon EC2 User Guide</i>.</p>

    Args:
        instance_types: <p>The instance types. We recommend that you specify at least three instance types. If you specify one or two instance types, or specify variations of a single instance type (for example, an <code>m3.xlarge</code> with and without instance storage), the returned placement score will always be low. </p> <p>If you specify <code>InstanceTypes</code>, you can't specify <code>InstanceRequirementsWithMetadata</code>.</p>
        target_capacity: <p>The target capacity.</p>
        target_capacity_unit_type: <p>The unit for the target capacity.</p>
        single_availability_zone: <p>Specify <code>true</code> so that the response returns a list of scored Availability Zones. Otherwise, the response returns a list of scored Regions.</p> <p>A list of scored Availability Zones is useful if you want to launch all of your Spot capacity into a single Availability Zone.</p>
        region_names: <p>The Regions used to narrow down the list of Regions to be scored. Enter the Region code, for example, <code>us-east-1</code>.</p>
        instance_requirements_with_metadata: <p>The attributes for the instance types. When you specify instance attributes, Amazon EC2 will identify instance types with those attributes.</p> <p>If you specify <code>InstanceRequirementsWithMetadata</code>, you can't specify <code>InstanceTypes</code>.</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>
        max_results: <p>The maximum number of items to return for this request. To get the next page of items, make another request with the token returned in the output. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Query-Requests.html#api-pagination">Pagination</a>.</p>
        next_token: <p>The token returned from a previous paginated request. Pagination continues from the end of the items returned by the previous request.</p>
        include_local_zones: <p>Specify <code>true</code> so that the response returns scores that include Local Zones. Otherwise, the response ignores Local Zones.</p> <p>When you request regional scores, Local Zone capacity counts toward its parent Region.</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.get_spot_placement_scores_request.GetSpotPlacementScoresRequest]",
    ) -> AsyncOperationResponse[
        "capo_ec2.types.get_spot_placement_scores_result.GetSpotPlacementScoresResult"
    ]:
        import capo_ec2._operations.amazon_ec2.get_spot_placement_scores

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetSpotPlacementScores")
    )
    input_: capo_ec2.types.get_spot_placement_scores_request.GetSpotPlacementScoresRequest = {}
    if instance_types is not None:
        input_["instance_types"] = instance_types
    if target_capacity is not None:
        input_["target_capacity"] = target_capacity
    if target_capacity_unit_type is not None:
        input_["target_capacity_unit_type"] = target_capacity_unit_type
    if single_availability_zone is not None:
        input_["single_availability_zone"] = single_availability_zone
    if region_names is not None:
        input_["region_names"] = region_names
    if instance_requirements_with_metadata is not None:
        input_["instance_requirements_with_metadata"] = (
            instance_requirements_with_metadata
        )
    if dry_run is not None:
        input_["dry_run"] = dry_run
    if max_results is not None:
        input_["max_results"] = max_results
    if next_token is not None:
        input_["next_token"] = next_token
    if include_local_zones is not None:
        input_["include_local_zones"] = include_local_zones

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