1. Packages
  2. AWS Classic
  3. API Docs
  4. ec2
  5. getSpotPrice

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.27.0 published on Monday, Mar 18, 2024 by Pulumi

aws.ec2.getSpotPrice

Explore with Pulumi AI

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.27.0 published on Monday, Mar 18, 2024 by Pulumi

    Information about most recent Spot Price for a given EC2 instance.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const example = aws.ec2.getSpotPrice({
        instanceType: "t3.medium",
        availabilityZone: "us-west-2a",
        filters: [{
            name: "product-description",
            values: ["Linux/UNIX"],
        }],
    });
    
    import pulumi
    import pulumi_aws as aws
    
    example = aws.ec2.get_spot_price(instance_type="t3.medium",
        availability_zone="us-west-2a",
        filters=[aws.ec2.GetSpotPriceFilterArgs(
            name="product-description",
            values=["Linux/UNIX"],
        )])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := ec2.GetSpotPrice(ctx, &ec2.GetSpotPriceArgs{
    			InstanceType:     pulumi.StringRef("t3.medium"),
    			AvailabilityZone: pulumi.StringRef("us-west-2a"),
    			Filters: []ec2.GetSpotPriceFilter{
    				{
    					Name: "product-description",
    					Values: []string{
    						"Linux/UNIX",
    					},
    				},
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var example = Aws.Ec2.GetSpotPrice.Invoke(new()
        {
            InstanceType = "t3.medium",
            AvailabilityZone = "us-west-2a",
            Filters = new[]
            {
                new Aws.Ec2.Inputs.GetSpotPriceFilterInputArgs
                {
                    Name = "product-description",
                    Values = new[]
                    {
                        "Linux/UNIX",
                    },
                },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.ec2.Ec2Functions;
    import com.pulumi.aws.ec2.inputs.GetSpotPriceArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            final var example = Ec2Functions.getSpotPrice(GetSpotPriceArgs.builder()
                .instanceType("t3.medium")
                .availabilityZone("us-west-2a")
                .filters(GetSpotPriceFilterArgs.builder()
                    .name("product-description")
                    .values("Linux/UNIX")
                    .build())
                .build());
    
        }
    }
    
    variables:
      example:
        fn::invoke:
          Function: aws:ec2:getSpotPrice
          Arguments:
            instanceType: t3.medium
            availabilityZone: us-west-2a
            filters:
              - name: product-description
                values:
                  - Linux/UNIX
    

    Using getSpotPrice

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getSpotPrice(args: GetSpotPriceArgs, opts?: InvokeOptions): Promise<GetSpotPriceResult>
    function getSpotPriceOutput(args: GetSpotPriceOutputArgs, opts?: InvokeOptions): Output<GetSpotPriceResult>
    def get_spot_price(availability_zone: Optional[str] = None,
                       filters: Optional[Sequence[GetSpotPriceFilter]] = None,
                       instance_type: Optional[str] = None,
                       opts: Optional[InvokeOptions] = None) -> GetSpotPriceResult
    def get_spot_price_output(availability_zone: Optional[pulumi.Input[str]] = None,
                       filters: Optional[pulumi.Input[Sequence[pulumi.Input[GetSpotPriceFilterArgs]]]] = None,
                       instance_type: Optional[pulumi.Input[str]] = None,
                       opts: Optional[InvokeOptions] = None) -> Output[GetSpotPriceResult]
    func GetSpotPrice(ctx *Context, args *GetSpotPriceArgs, opts ...InvokeOption) (*GetSpotPriceResult, error)
    func GetSpotPriceOutput(ctx *Context, args *GetSpotPriceOutputArgs, opts ...InvokeOption) GetSpotPriceResultOutput

    > Note: This function is named GetSpotPrice in the Go SDK.

    public static class GetSpotPrice 
    {
        public static Task<GetSpotPriceResult> InvokeAsync(GetSpotPriceArgs args, InvokeOptions? opts = null)
        public static Output<GetSpotPriceResult> Invoke(GetSpotPriceInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetSpotPriceResult> getSpotPrice(GetSpotPriceArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: aws:ec2/getSpotPrice:getSpotPrice
      arguments:
        # arguments dictionary

    The following arguments are supported:

    AvailabilityZone string
    Availability zone in which to query Spot price information.
    Filters List<GetSpotPriceFilter>
    One or more configuration blocks containing name-values filters. See the EC2 API Reference for supported filters. Detailed below.
    InstanceType string
    Type of instance for which to query Spot Price information.
    AvailabilityZone string
    Availability zone in which to query Spot price information.
    Filters []GetSpotPriceFilter
    One or more configuration blocks containing name-values filters. See the EC2 API Reference for supported filters. Detailed below.
    InstanceType string
    Type of instance for which to query Spot Price information.
    availabilityZone String
    Availability zone in which to query Spot price information.
    filters List<GetSpotPriceFilter>
    One or more configuration blocks containing name-values filters. See the EC2 API Reference for supported filters. Detailed below.
    instanceType String
    Type of instance for which to query Spot Price information.
    availabilityZone string
    Availability zone in which to query Spot price information.
    filters GetSpotPriceFilter[]
    One or more configuration blocks containing name-values filters. See the EC2 API Reference for supported filters. Detailed below.
    instanceType string
    Type of instance for which to query Spot Price information.
    availability_zone str
    Availability zone in which to query Spot price information.
    filters Sequence[GetSpotPriceFilter]
    One or more configuration blocks containing name-values filters. See the EC2 API Reference for supported filters. Detailed below.
    instance_type str
    Type of instance for which to query Spot Price information.
    availabilityZone String
    Availability zone in which to query Spot price information.
    filters List<Property Map>
    One or more configuration blocks containing name-values filters. See the EC2 API Reference for supported filters. Detailed below.
    instanceType String
    Type of instance for which to query Spot Price information.

    getSpotPrice Result

    The following output properties are available:

    Id string
    The provider-assigned unique ID for this managed resource.
    SpotPrice string
    Most recent Spot Price value for the given instance type and AZ.
    SpotPriceTimestamp string
    The timestamp at which the Spot Price value was published.
    AvailabilityZone string
    Filters List<GetSpotPriceFilter>
    InstanceType string
    Id string
    The provider-assigned unique ID for this managed resource.
    SpotPrice string
    Most recent Spot Price value for the given instance type and AZ.
    SpotPriceTimestamp string
    The timestamp at which the Spot Price value was published.
    AvailabilityZone string
    Filters []GetSpotPriceFilter
    InstanceType string
    id String
    The provider-assigned unique ID for this managed resource.
    spotPrice String
    Most recent Spot Price value for the given instance type and AZ.
    spotPriceTimestamp String
    The timestamp at which the Spot Price value was published.
    availabilityZone String
    filters List<GetSpotPriceFilter>
    instanceType String
    id string
    The provider-assigned unique ID for this managed resource.
    spotPrice string
    Most recent Spot Price value for the given instance type and AZ.
    spotPriceTimestamp string
    The timestamp at which the Spot Price value was published.
    availabilityZone string
    filters GetSpotPriceFilter[]
    instanceType string
    id str
    The provider-assigned unique ID for this managed resource.
    spot_price str
    Most recent Spot Price value for the given instance type and AZ.
    spot_price_timestamp str
    The timestamp at which the Spot Price value was published.
    availability_zone str
    filters Sequence[GetSpotPriceFilter]
    instance_type str
    id String
    The provider-assigned unique ID for this managed resource.
    spotPrice String
    Most recent Spot Price value for the given instance type and AZ.
    spotPriceTimestamp String
    The timestamp at which the Spot Price value was published.
    availabilityZone String
    filters List<Property Map>
    instanceType String

    Supporting Types

    GetSpotPriceFilter

    Name string
    Name of the filter.
    Values List<string>
    List of one or more values for the filter.
    Name string
    Name of the filter.
    Values []string
    List of one or more values for the filter.
    name String
    Name of the filter.
    values List<String>
    List of one or more values for the filter.
    name string
    Name of the filter.
    values string[]
    List of one or more values for the filter.
    name str
    Name of the filter.
    values Sequence[str]
    List of one or more values for the filter.
    name String
    Name of the filter.
    values List<String>
    List of one or more values for the filter.

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the aws Terraform Provider.
    aws logo

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.27.0 published on Monday, Mar 18, 2024 by Pulumi