Terraform-provider-aws: EC2 instance type discovery

Created on 23 Nov 2019  ·  4Comments  ·  Source: hashicorp/terraform-provider-aws

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

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.

New or Affected Resource(s)

  • aws_instance_types
  • aws_instance_type

Potential Terraform Configuration

data "aws_instance_types" "nitro" {
  filter {
    name   = "hypervisor"
    values = ["nitro"]
  }
}

References

Announcement.
User guide.
API references:

Requires AWS SDK v1.25.41:

new-data-source servicec2

Most helpful comment

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).

All 4 comments

Submitted new data sources for EC2 Instance Type Offerings: https://github.com/terraform-providers/terraform-provider-aws/pull/12139

Two new data sources:

  • New Data Source: aws_ec2_instance_type_offering
  • New Data Source: aws_ec2_instance_type_offerings

Have 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!

Was this page helpful?
0 / 5 - 0 ratings