terraform-aws-ec2-spot-price icon indicating copy to clipboard operation
terraform-aws-ec2-spot-price copied to clipboard

Error when instance type isn't available in region / AZ

Open chrispicht opened this issue 3 years ago • 1 comments

╷ │ Error: no EC2 Spot Price History found matching criteria; try different search │ │ with module.ec2_spot_price.data.aws_ec2_spot_price.this["ca-central-1d/r5a.xlarge"], │ on .terraform.067342976165-ca-central-1/modules/ec2_spot_price/main.tf line 6, in data "aws_ec2_spot_price" "this": │ 6: data "aws_ec2_spot_price" "this" { │ ╵

chrispicht avatar Mar 10 '22 15:03 chrispicht

this happens when there is no selected instance type in the selected region or az https://github.com/hashicorp/terraform-provider-aws/issues/17446

in provider version 4.0+ this behavior could be fixed I saw a lot of work related to similar issues inside another data sources https://github.com/hashicorp/terraform-provider-aws/blob/main/CHANGELOG.md#400-february-10-2022

the solution for now:

  • pass only the first 3 AZ (1a,1b,1c) to the module and take the price based on them
  • pass another type of instance that is close or often close in price, but greater, for example, r5.xlarge in that case

cageyv avatar Mar 10 '22 16:03 cageyv