Amazon EC2 makes it easier for customers to discover and compare EC2 instance types.
Customers can programmatically access instance type specifications using new APIs: DescribeInstanceTypes and DescribeInstanceTypeOfferings.
aws_instance_typesaws_instance_typedata "aws_instance_types" "nitro" {
filter {
name = "hypervisor"
values = ["nitro"]
}
}
Announcement.
User guide.
API references:
Requires AWS SDK v1.25.41:
Submitted new data sources for EC2 Instance Type Offerings: https://github.com/terraform-providers/terraform-provider-aws/pull/12139
Two new data sources:
aws_ec2_instance_type_offeringaws_ec2_instance_type_offeringsHave been merged and will release with version 2.52.0 of the Terraform AWS Provider, Thursday this week. Leaving this open for aws_ec2_instance_type/aws_ec2_instance_types implementations.
I noticed in #12139 that the return values are mostly focused on instance_types and does not provide the location and location_type that https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instance-type-offerings.html offers. Was there a particular reason?
It is useful seeing what AZs are available for a given instance type within a region:
M4.xlarge in us-east-1
aws --region us-east-1 ec2 describe-instance-type-offerings --filters "Name=instance-type,Values=m4.xlarge" --location-type availability-zone returns us-east-1a, us-east-1b, us-east-1c, us-east-1d, and us-east-1e
where as M5.xlarge
aws --region us-east-1 ec2 describe-instance-type-offerings --filters "Name=instance-type,Values=m5.xlarge" --location-type availability-zone correctly excludes us-east-1e where it is not available.
One could imagine, through some hop jumping, you can get all AZs in a region, fetch the AZs for your instance type and then find the delta and pass into the blacklist for aws_availability_zones (with any additional filtering you need).
I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.
If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!
Most helpful comment
I noticed in #12139 that the return values are mostly focused on
instance_typesand does not provide thelocationandlocation_typethat https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instance-type-offerings.html offers. Was there a particular reason?It is useful seeing what AZs are available for a given instance type within a region:
M4.xlarge in us-east-1
aws --region us-east-1 ec2 describe-instance-type-offerings --filters "Name=instance-type,Values=m4.xlarge" --location-type availability-zonereturns us-east-1a, us-east-1b, us-east-1c, us-east-1d, and us-east-1ewhere as M5.xlarge
aws --region us-east-1 ec2 describe-instance-type-offerings --filters "Name=instance-type,Values=m5.xlarge" --location-type availability-zonecorrectly excludes us-east-1e where it is not available.One could imagine, through some hop jumping, you can get all AZs in a region, fetch the AZs for your instance type and then find the delta and pass into the blacklist for
aws_availability_zones(with any additional filtering you need).