Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws_ec2_instance_type_offerings should have an attribute for location_types and locations #15272

Closed
robomon1 opened this issue Sep 22, 2020 · 3 comments
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/ec2 Issues and PRs that pertain to the ec2 service.

Comments

@robomon1
Copy link

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 other comments that do not add relevant new information or questions, 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

Terraform CLI and Terraform AWS Provider Version

Terraform v0.13.3

  • provider registry.terraform.io/-/aws v3.7.0
  • provider registry.terraform.io/hashicorp/aws v3.7.0

Affected Resource(s)

aws_ec2_instance_type_offerings

Terraform Configuration Files

terraform {
  required_version = "~> 0.13.3"
}

provider "aws" {
  region = "us-west-2"
}

# Get all available availability zones
data "aws_availability_zones" "available" {
  state = "available"
}

output "zone_names" {
  value = data.aws_availability_zones.available.names
}
output "zone_ids" {
  value = data.aws_availability_zones.available.zone_ids
}

# We want only the availability zones where t2.micro is supported
data "aws_ec2_instance_type_offerings" "az" {
  filter {
    name   = "instance-type"
    values = ["t2.micro"]
  }

  location_type = "availability-zone"
}

# We can get instance_types attribute
output "location_types" {
  value = data.aws_ec2_instance_type_offerings.az.instance_types
}

# But what we really want is a locations attribute which gives me
# just the locations supported by the instance types as shown by the
# aws cli for describe-instance-type-offerings.  There are 4 availability
# zones but ony 3 of them support t2.micro

# aws ec2 describe-instance-type-offerings --location-type availability-zone \
#            --filters Name=instance-type,Values=t2.micro \
#            --region us-west-2
# {
#     "InstanceTypeOfferings": [
#         {
#             "InstanceType": "t2.micro",
#             "LocationType": "availability-zone",
#             "Location": "us-west-2b"
#         },
#         {
#             "InstanceType": "t2.micro",
#             "LocationType": "availability-zone",
#             "Location": "us-west-2a"
#         },
#         {
#             "InstanceType": "t2.micro",
#             "LocationType": "availability-zone",
#             "Location": "us-west-2c"
#         }
#     ]
# }

Debug Output

Panic Output

Expected Behavior

I expect to get all the attributes including LocationTypes and Locations from the datasource

Actual Behavior

There is no way to get to the LocationTypes and Locations data returned by an aws_ec2_instance_type_offering datasource.

Steps to Reproduce

  1. terraform init
  2. terraform apply

Important Factoids

I'm using us-west-2 because the t2.micro is only supported in us-west-2a, us-west-2b, and us-west-2c but there is also a us-west-2d az

@ghost ghost added the service/ec2 Issues and PRs that pertain to the ec2 service. label Sep 22, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Sep 22, 2020
@gdavison gdavison added enhancement Requests to existing resources that expand the functionality or scope. and removed needs-triage Waiting for first response or review from a maintainer. labels Sep 22, 2020
mjulianotq added a commit to TopQuadrant-DevOps/terraform-provider-aws that referenced this issue Feb 24, 2021
@mjulianotq
Copy link
Contributor

I've submitted PR #17794 which adds these fields to the data. Please go give it a thumbs up if you want this feature.

I have need of the feature to dynamically choose which availability zones are used in a cluster based on the instance type chosen for the cluster. Right now, I'm just crossing my fingers that the first 2 randomly chosen AZs support my chosen instance type, and if they don't, deleting and trying again. The instance type I've been testing with is supported in all but one of the AZs in us-east-1, which has been fine for testing, but I'm nearing production on my module, so I need this badly enough to do it myself.

@ewbankkit ewbankkit changed the title aws_ec2_instance_type_offering should have an attribute for location_types and locations aws_ec2_instance_type_offerings should have an attribute for location_types and locations Jul 23, 2021
@ewbankkit
Copy link
Contributor

ewbankkit commented Jul 23, 2021

Closed via #16704.

@github-actions
Copy link

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
4 participants