aws_ec2_instance_type_offerings does not return the list of Locations matching the Filters #19812
Labels
enhancement
Requests to existing resources that expand the functionality or scope.
service/ec2
Issues and PRs that pertain to the ec2 service.
Community Note
Terraform CLI and Terraform AWS Provider Version
Terraform v0.14.8
Affected Resource(s)
Data Source: aws_ec2_instance_type_offerings
Terraform Configuration Files
On us-east-1 one of the AZs (use1-az3 - us-east-1e in this particular account) does not support some EC2 instance types, so parts of our code that used to work on other regions with more homogeneous AZs fail in us-east-1 because by sheer luck our 1st subnet id in this list
subnet_id = local.private_subnet_ids_list[0]
happens to be the one in the AZ that does not support the instance types that we want to use for some single instances. So deployment fails.Expected Behavior
Either data.aws_ec2_instance_type_offerings.mq-type or data.aws_ec2_instance_type_offerings.mq-azs, hopefully both, should contain a result being the union of both Filters, the List of AZs, and the list of instance types.
The problem I'm trying to solve is to correctly handle an ancient AZ in us-east-1 that doesn't have the "modern" instance types, so, for example for Amazon MQ the error is:
Error: BadRequestException: Availability Zone [us-east-1e] of requested subnet [subnet-XXXX] does not support broker instance type [mq.m5.xlarge]. Specify a subnet in a different Availability Zone.
And I would like to filter all the subnets (ideally) or azs (if nothing else) to fill the parameter subnet_ids with 2 subnets that do support the host_instance_type I selected for MQ. Something like:
Other place I have trouble with that is directly launching EC2 instances:
Error: Error launching source instance: Unsupported: Your requested instance type (t3a.xlarge) is not supported in your requested Availability Zone (us-east-1e). Please retry your request by not specifying an Availability Zone or choosing us-east-1a, us-east-1b, us-east-1c, us-east-1d, us-east-1f.
But that could be solved with the same approach I guess.
Please see this full TF file with two attempts and the terraform console output after each data source, as well as the AWS CLI output too, note the differing outputs between terraform and AWS CLI (this breaks the Principle of least astonishment):
Note that I'm still not sure how to "handle" or expose the output of a filter like:
aws --region us-east-1 ec2 describe-instance-type-offerings --filters "Name=instance-type,Values=m5.xlarge,m4.xlarge" "Name=location,Values=us-east-1a,us-east-1b,us-east-1c,us-east-1d,us-east-1e,us-east-1f" --location-type availability-zone
Where the output of AWS CLI is the cartesian product of all filter conditions (2 different instance types in this case) but that match the conditions (still excluding m5.xlarge us-east-1e).
References
The text was updated successfully, but these errors were encountered: