unable to create aws spot instance using terraform - Error: "MaxSpotInstanceCountExceeded"

486 Views Asked by At

Friends, I'm facing below error when I'm trying to create a spot instance using terraform.

"Error: Error requesting spot instances: MaxSpotInstanceCountExceeded: Max spot instance count exceeded status code: 400, request id: 19c590fd-c352-4bbd-8915-678ac3e32474"

I have already checked my limit in aws console and its showing 32vcpu(image3) and also currently I don't have any running spot instance template or running instances (image2). My issue here is, I can able to create spot instance directly through aws console but not possible through terraform v0.14.5 (image1). I have attached all the screenshot with this post for better insight. I really dont know how to fix this, even aws support team just asking me to check my limit which I already done. So, any helps on this is case from this community is highly appreciable.

enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here

1

There are 1 best solutions below

0
On

Friends - Finally, I found a way to resolve this issue. The main cause for this error is "block_duration_minutes = 120" which I mentioned in the "createinstance.tf" file. Since, I'm specifying AZ for my instance, its not possible for me to mention "block_duration_minute". hence, I should remove this parameter to make it work. Read more about this https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/spot_instance_request

Thanks for the support.