github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/pricing/getProduct.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 pricing 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 // Use this data source to get the pricing information of all products in AWS. 15 // This data source is only available in a us-east-1 or ap-south-1 provider. 16 // 17 // ## Example Usage 18 // 19 // <!--Start PulumiCodeChooser --> 20 // ```go 21 // package main 22 // 23 // import ( 24 // 25 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/pricing" 26 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 27 // 28 // ) 29 // 30 // func main() { 31 // pulumi.Run(func(ctx *pulumi.Context) error { 32 // _, err := pricing.GetProduct(ctx, &pricing.GetProductArgs{ 33 // ServiceCode: "AmazonEC2", 34 // Filters: []pricing.GetProductFilter{ 35 // { 36 // Field: "instanceType", 37 // Value: "c5.xlarge", 38 // }, 39 // { 40 // Field: "operatingSystem", 41 // Value: "Linux", 42 // }, 43 // { 44 // Field: "location", 45 // Value: "US East (N. Virginia)", 46 // }, 47 // { 48 // Field: "preInstalledSw", 49 // Value: "NA", 50 // }, 51 // { 52 // Field: "licenseModel", 53 // Value: "No License required", 54 // }, 55 // { 56 // Field: "tenancy", 57 // Value: "Shared", 58 // }, 59 // { 60 // Field: "capacitystatus", 61 // Value: "Used", 62 // }, 63 // }, 64 // }, nil) 65 // if err != nil { 66 // return err 67 // } 68 // return nil 69 // }) 70 // } 71 // 72 // ``` 73 // <!--End PulumiCodeChooser --> 74 // 75 // <!--Start PulumiCodeChooser --> 76 // ```go 77 // package main 78 // 79 // import ( 80 // 81 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/pricing" 82 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 83 // 84 // ) 85 // 86 // func main() { 87 // pulumi.Run(func(ctx *pulumi.Context) error { 88 // _, err := pricing.GetProduct(ctx, &pricing.GetProductArgs{ 89 // ServiceCode: "AmazonRedshift", 90 // Filters: []pricing.GetProductFilter{ 91 // { 92 // Field: "instanceType", 93 // Value: "ds1.xlarge", 94 // }, 95 // { 96 // Field: "location", 97 // Value: "US East (N. Virginia)", 98 // }, 99 // }, 100 // }, nil) 101 // if err != nil { 102 // return err 103 // } 104 // return nil 105 // }) 106 // } 107 // 108 // ``` 109 // <!--End PulumiCodeChooser --> 110 func GetProduct(ctx *pulumi.Context, args *GetProductArgs, opts ...pulumi.InvokeOption) (*GetProductResult, error) { 111 opts = internal.PkgInvokeDefaultOpts(opts) 112 var rv GetProductResult 113 err := ctx.Invoke("aws:pricing/getProduct:getProduct", args, &rv, opts...) 114 if err != nil { 115 return nil, err 116 } 117 return &rv, nil 118 } 119 120 // A collection of arguments for invoking getProduct. 121 type GetProductArgs struct { 122 // List of filters. Passed directly to the API (see GetProducts API reference). These filters must describe a single product, this resource will fail if more than one product is returned by the API. 123 Filters []GetProductFilter `pulumi:"filters"` 124 // Code of the service. Available service codes can be fetched using the DescribeServices pricing API call. 125 ServiceCode string `pulumi:"serviceCode"` 126 } 127 128 // A collection of values returned by getProduct. 129 type GetProductResult struct { 130 Filters []GetProductFilter `pulumi:"filters"` 131 // The provider-assigned unique ID for this managed resource. 132 Id string `pulumi:"id"` 133 // Set to the product returned from the API. 134 Result string `pulumi:"result"` 135 ServiceCode string `pulumi:"serviceCode"` 136 } 137 138 func GetProductOutput(ctx *pulumi.Context, args GetProductOutputArgs, opts ...pulumi.InvokeOption) GetProductResultOutput { 139 return pulumi.ToOutputWithContext(context.Background(), args). 140 ApplyT(func(v interface{}) (GetProductResult, error) { 141 args := v.(GetProductArgs) 142 r, err := GetProduct(ctx, &args, opts...) 143 var s GetProductResult 144 if r != nil { 145 s = *r 146 } 147 return s, err 148 }).(GetProductResultOutput) 149 } 150 151 // A collection of arguments for invoking getProduct. 152 type GetProductOutputArgs struct { 153 // List of filters. Passed directly to the API (see GetProducts API reference). These filters must describe a single product, this resource will fail if more than one product is returned by the API. 154 Filters GetProductFilterArrayInput `pulumi:"filters"` 155 // Code of the service. Available service codes can be fetched using the DescribeServices pricing API call. 156 ServiceCode pulumi.StringInput `pulumi:"serviceCode"` 157 } 158 159 func (GetProductOutputArgs) ElementType() reflect.Type { 160 return reflect.TypeOf((*GetProductArgs)(nil)).Elem() 161 } 162 163 // A collection of values returned by getProduct. 164 type GetProductResultOutput struct{ *pulumi.OutputState } 165 166 func (GetProductResultOutput) ElementType() reflect.Type { 167 return reflect.TypeOf((*GetProductResult)(nil)).Elem() 168 } 169 170 func (o GetProductResultOutput) ToGetProductResultOutput() GetProductResultOutput { 171 return o 172 } 173 174 func (o GetProductResultOutput) ToGetProductResultOutputWithContext(ctx context.Context) GetProductResultOutput { 175 return o 176 } 177 178 func (o GetProductResultOutput) Filters() GetProductFilterArrayOutput { 179 return o.ApplyT(func(v GetProductResult) []GetProductFilter { return v.Filters }).(GetProductFilterArrayOutput) 180 } 181 182 // The provider-assigned unique ID for this managed resource. 183 func (o GetProductResultOutput) Id() pulumi.StringOutput { 184 return o.ApplyT(func(v GetProductResult) string { return v.Id }).(pulumi.StringOutput) 185 } 186 187 // Set to the product returned from the API. 188 func (o GetProductResultOutput) Result() pulumi.StringOutput { 189 return o.ApplyT(func(v GetProductResult) string { return v.Result }).(pulumi.StringOutput) 190 } 191 192 func (o GetProductResultOutput) ServiceCode() pulumi.StringOutput { 193 return o.ApplyT(func(v GetProductResult) string { return v.ServiceCode }).(pulumi.StringOutput) 194 } 195 196 func init() { 197 pulumi.RegisterOutputType(GetProductResultOutput{}) 198 }