github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/ec2/getSpotPrice.go (about)

     1  // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
     2  // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
     3  
     4  package ec2
     5  
     6  import (
     7  	"context"
     8  	"reflect"
     9  
    10  	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
    11  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    12  )
    13  
    14  // Information about most recent Spot Price for a given EC2 instance.
    15  //
    16  // ## Example Usage
    17  //
    18  // <!--Start PulumiCodeChooser -->
    19  // ```go
    20  // package main
    21  //
    22  // import (
    23  //
    24  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
    25  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    26  //
    27  // )
    28  //
    29  //	func main() {
    30  //		pulumi.Run(func(ctx *pulumi.Context) error {
    31  //			_, err := ec2.GetSpotPrice(ctx, &ec2.GetSpotPriceArgs{
    32  //				InstanceType:     pulumi.StringRef("t3.medium"),
    33  //				AvailabilityZone: pulumi.StringRef("us-west-2a"),
    34  //				Filters: []ec2.GetSpotPriceFilter{
    35  //					{
    36  //						Name: "product-description",
    37  //						Values: []string{
    38  //							"Linux/UNIX",
    39  //						},
    40  //					},
    41  //				},
    42  //			}, nil)
    43  //			if err != nil {
    44  //				return err
    45  //			}
    46  //			return nil
    47  //		})
    48  //	}
    49  //
    50  // ```
    51  // <!--End PulumiCodeChooser -->
    52  func GetSpotPrice(ctx *pulumi.Context, args *GetSpotPriceArgs, opts ...pulumi.InvokeOption) (*GetSpotPriceResult, error) {
    53  	opts = internal.PkgInvokeDefaultOpts(opts)
    54  	var rv GetSpotPriceResult
    55  	err := ctx.Invoke("aws:ec2/getSpotPrice:getSpotPrice", args, &rv, opts...)
    56  	if err != nil {
    57  		return nil, err
    58  	}
    59  	return &rv, nil
    60  }
    61  
    62  // A collection of arguments for invoking getSpotPrice.
    63  type GetSpotPriceArgs struct {
    64  	// Availability zone in which to query Spot price information.
    65  	AvailabilityZone *string `pulumi:"availabilityZone"`
    66  	// One or more configuration blocks containing name-values filters. See the [EC2 API Reference](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeSpotPriceHistory.html) for supported filters. Detailed below.
    67  	Filters []GetSpotPriceFilter `pulumi:"filters"`
    68  	// Type of instance for which to query Spot Price information.
    69  	InstanceType *string `pulumi:"instanceType"`
    70  }
    71  
    72  // A collection of values returned by getSpotPrice.
    73  type GetSpotPriceResult struct {
    74  	AvailabilityZone *string              `pulumi:"availabilityZone"`
    75  	Filters          []GetSpotPriceFilter `pulumi:"filters"`
    76  	// The provider-assigned unique ID for this managed resource.
    77  	Id           string  `pulumi:"id"`
    78  	InstanceType *string `pulumi:"instanceType"`
    79  	// Most recent Spot Price value for the given instance type and AZ.
    80  	SpotPrice string `pulumi:"spotPrice"`
    81  	// The timestamp at which the Spot Price value was published.
    82  	SpotPriceTimestamp string `pulumi:"spotPriceTimestamp"`
    83  }
    84  
    85  func GetSpotPriceOutput(ctx *pulumi.Context, args GetSpotPriceOutputArgs, opts ...pulumi.InvokeOption) GetSpotPriceResultOutput {
    86  	return pulumi.ToOutputWithContext(context.Background(), args).
    87  		ApplyT(func(v interface{}) (GetSpotPriceResult, error) {
    88  			args := v.(GetSpotPriceArgs)
    89  			r, err := GetSpotPrice(ctx, &args, opts...)
    90  			var s GetSpotPriceResult
    91  			if r != nil {
    92  				s = *r
    93  			}
    94  			return s, err
    95  		}).(GetSpotPriceResultOutput)
    96  }
    97  
    98  // A collection of arguments for invoking getSpotPrice.
    99  type GetSpotPriceOutputArgs struct {
   100  	// Availability zone in which to query Spot price information.
   101  	AvailabilityZone pulumi.StringPtrInput `pulumi:"availabilityZone"`
   102  	// One or more configuration blocks containing name-values filters. See the [EC2 API Reference](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeSpotPriceHistory.html) for supported filters. Detailed below.
   103  	Filters GetSpotPriceFilterArrayInput `pulumi:"filters"`
   104  	// Type of instance for which to query Spot Price information.
   105  	InstanceType pulumi.StringPtrInput `pulumi:"instanceType"`
   106  }
   107  
   108  func (GetSpotPriceOutputArgs) ElementType() reflect.Type {
   109  	return reflect.TypeOf((*GetSpotPriceArgs)(nil)).Elem()
   110  }
   111  
   112  // A collection of values returned by getSpotPrice.
   113  type GetSpotPriceResultOutput struct{ *pulumi.OutputState }
   114  
   115  func (GetSpotPriceResultOutput) ElementType() reflect.Type {
   116  	return reflect.TypeOf((*GetSpotPriceResult)(nil)).Elem()
   117  }
   118  
   119  func (o GetSpotPriceResultOutput) ToGetSpotPriceResultOutput() GetSpotPriceResultOutput {
   120  	return o
   121  }
   122  
   123  func (o GetSpotPriceResultOutput) ToGetSpotPriceResultOutputWithContext(ctx context.Context) GetSpotPriceResultOutput {
   124  	return o
   125  }
   126  
   127  func (o GetSpotPriceResultOutput) AvailabilityZone() pulumi.StringPtrOutput {
   128  	return o.ApplyT(func(v GetSpotPriceResult) *string { return v.AvailabilityZone }).(pulumi.StringPtrOutput)
   129  }
   130  
   131  func (o GetSpotPriceResultOutput) Filters() GetSpotPriceFilterArrayOutput {
   132  	return o.ApplyT(func(v GetSpotPriceResult) []GetSpotPriceFilter { return v.Filters }).(GetSpotPriceFilterArrayOutput)
   133  }
   134  
   135  // The provider-assigned unique ID for this managed resource.
   136  func (o GetSpotPriceResultOutput) Id() pulumi.StringOutput {
   137  	return o.ApplyT(func(v GetSpotPriceResult) string { return v.Id }).(pulumi.StringOutput)
   138  }
   139  
   140  func (o GetSpotPriceResultOutput) InstanceType() pulumi.StringPtrOutput {
   141  	return o.ApplyT(func(v GetSpotPriceResult) *string { return v.InstanceType }).(pulumi.StringPtrOutput)
   142  }
   143  
   144  // Most recent Spot Price value for the given instance type and AZ.
   145  func (o GetSpotPriceResultOutput) SpotPrice() pulumi.StringOutput {
   146  	return o.ApplyT(func(v GetSpotPriceResult) string { return v.SpotPrice }).(pulumi.StringOutput)
   147  }
   148  
   149  // The timestamp at which the Spot Price value was published.
   150  func (o GetSpotPriceResultOutput) SpotPriceTimestamp() pulumi.StringOutput {
   151  	return o.ApplyT(func(v GetSpotPriceResult) string { return v.SpotPriceTimestamp }).(pulumi.StringOutput)
   152  }
   153  
   154  func init() {
   155  	pulumi.RegisterOutputType(GetSpotPriceResultOutput{})
   156  }