-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Error message not clear when the instance_type is not available on region #8868
Comments
Hi @kdefives 👋 Thanks for writing this in! That error message is certainly vague. This particular error messaging is coming from the EC2 API itself:
And unfortunately, the Terraform AWS Provider
As you can imagine though, even this might not be particularly helpful for operators since it cannot provide too much insight either. We will not know whether it was an instance type to region mismatch or some other condition that the EC2 API decided to trigger this message. I am not sure that we would want to accept the maintenance burden of implementing this additional messaging should it potentially be incorrect (e.g. leading operators down the wrong troubleshooting paths), missing troubleshooting paths, or if future updates to the EC2 API error break our handling for catching this scenario. Your best bet to getting this error messaging within the EC2 API improved is to reach out with a feature request in an AWS Support Case or your AWS account managers if you have any. 👍 Since this likely falls under a case where we will not want to do anything to increase the code complexity here, I'm going to proactively close this issue, but please do write back if you would like to further discuss this! |
As a related followup point, I have been wondering if we might want to support a data source that allows verifying whether AWS Regions/Availability Zones do support a certain instance type or more in particular, which Availability Zones an instance can be launched in. With the recent launch of the Our particular pain point maintaining this project is surrounding the following integration testing setup (the # This example is for illustrative purposes only in Terraform 0.12 syntax and omits other implementation details
resource "aws_vpc" "example" {}
# Without specifying availability_zone, the AZ is automatically selected (potentially us-west-2d)
resource "aws_subnet" "example" {
vpc_id = aws_vpc.example.id
}
# Since the subnet availability zone was predetermined previously
# we cannot do anything to prevent the instance type error here.
resource "aws_instance" "example" {
subnet_id = aws_subnet.example.id
} Now theoretically in our acceptance testing could just depend on the default VPC and its subnets existing to remove To partially alleviate this issue, a few releases ago we added blacklisting support to the # This example is for illustrative purposes only in Terraform 0.12 syntax and omits other implementation details
data "aws_availability_zones" "example" {
blacklisted_zone_ids = ["usw2-az4"]
state = "available"
}
resource "aws_vpc" "example" {}
# Now we are ensuring that us-west-2d is not included :)
resource "aws_subnet" "example" {
availability_zone = data.aws_availability_zones.example.names[0]
vpc_id = aws_vpc.example.id
}
resource "aws_instance" "example" {
subnet_id = aws_subnet.example.id
} But since its manual process, its slow to implement and likely to become incorrect over time as instance type support is updated. The data source idea here would leverage EC2's dry run abilities and provide a list of supported availability zones or completely error if none are found. # Rough design sketch with placeholder naming and usage which is tailored for our particular problem.
# This example is for illustrative purposes only in Terraform 0.12 syntax and omits other implementation details.
# This would error if instance type is not found in region
data "aws_ec2_instance_type" "example" {
instance_type = "m4.large"
# Optional arguments below:
availability_zone = "..." # limit search to single AZ
}
resource "aws_vpc" "example" {}
# We are ensuring that us-west-2d is not included for now,
# but it will get automatically included when the instance type is added in the future :)
resource "aws_subnet" "example" {
availability_zone = data.aws_ec2_instance_type.example.availability_zones[0]
vpc_id = aws_vpc.example.id
}
resource "aws_instance" "example" {
subnet_id = aws_subnet.example.id
} I'm not sure of its utility in the real world though so it may never be implemented, but figured I would throw this out there as a potential idea as well since it seemed related. |
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! |
Community Note
Description
Hello,
I tried to pop an AWS instance on AWS China (Beijing region) with an instance_type which is not available in this region, for instance : m5.4xlarge
When i do the terraform apply, i would like to suggest to improve the error message displayed. I know is it not urgent but i think it could be useful to debug and analyze what is the error.
Bellow the current error message :
FEATURE REQUEST: What do you think to improve the error log message by something like this : "instance type not available on the current zone"?
New or Affected Resource(s)
Potential Terraform Configuration
Code example available here : https://github.com/kdefives/issue-aws_instance-error_message_not_clear_with_bad_instance_type
References
The text was updated successfully, but these errors were encountered: