hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.61k stars 9k forks source link

[Bug]: Spot resources creation hang instead of failing with 'InsufficientInstanceCapacity' when none is available #38133

Open tanguylefloch-veesion opened 1 week ago

tanguylefloch-veesion commented 1 week ago

Terraform Core Version

1.8.3

AWS Provider Version

5.55.0

Affected Resource(s)

Expected Behavior

When no spot ec2 is available, I expect terraform to fail with something like:

Error: creating EC2 Instance: InsufficientInstanceCapacity: We currently do not have sufficient g5.xlarge capacity in zones with support for 'gp3' volumes. Our system will be working on provisioning additional capacity.
│   status code: 500, request id: ---

Which allowed me in the past to retry under certain conditions in 5.53.0.

Actual Behavior

Under the new releases this is no longer possible as terraforms keeps going forever when there is an insufficient resource capacity.

module.triton.aws_instance.this[0]: Still creating... [49m0s elapsed]
module.triton.aws_instance.this[0]: Still creating... [49m10s elapsed]
module.triton.aws_instance.this[0]: Still creating... [49m20s elapsed]
module.triton.aws_instance.this[0]: Still creating... [49m30s elapsed]
module.triton.aws_instance.this[0]: Still creating... [49m40s elapsed]
module.triton.aws_instance.this[0]: Still creating... [49m50s elapsed]
module.triton.aws_instance.this[0]: Still creating... [50m0s elapsed]
module.triton.aws_instance.this[0]: Still creating... [50m10s elapsed]
module.triton.aws_instance.this[0]: Still creating... [50m20s elapsed]
module.triton.aws_instance.this[0]: Still creating... [50m30s elapsed]
module.triton.aws_instance.this[0]: Still creating... [50m40s elapsed]

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

provider "aws" {
  region = "eu-west-1"
}

resource "aws_instance" "test" {
  ami                                  = "ami-08ba52a61087f1bd6"
  instance_type                        = "g5.12xlarge"
  subnet_id                            = "subnet-0e320a174f9c22fe9"

  instance_market_options {
      market_type = "spot"
  }
}

Steps to Reproduce

  1. Change the subnet id to an existing one in your infra
  2. Make sure you use an instance type that is unavailable right now (the g5.12xlarge is often unavailable in eu-west-1)
  3. terraform init
  4. terraform apply

To reproduce expected behaviour, you can add:

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "5.53.0"
    }
  }
}

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 1 week ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue