0

I am trying to create a spot instance in Terraform and the terraform code appears to be fine but I keep getting an error back saying MaxSpotInstanceCountExceeded.

NOTE: Right now this is just a test hence I am not including security groups, IPs, etc etc.

Steps I have taken:

  1. Checked that I have 0 spot instance requests created in console.
  2. Tried logging in to the console and creating a spot instance request. It works just fine.
  3. Cancelled the spot instance request to ensure that I now have 0 spot instance requests.
  4. Now I try and create virtually the same spot instance with the terraform script below, but I get the error: MaxSpotInstanceCountExceeded

Does anyone know why Terraform (or maybe AWS?) is not allowing me to create the spot instance using the terraform script, but it works just fine from the console?

Thanks!

provider "aws" {
profile = "terraform_enterprise_user"
region = "us-east-2"
}

resource "aws_spot_instance_request" "MySpotInstance" {

# Spot Request Settings
wait_for_fulfillment = "true"
spot_type = "persistent"
instance_interruption_behaviour = "stop"


# Instance Settings
ami = "ami-0520e698dd500b1d1"
instance_type = "c4.large"
associate_public_ip_address = "1"

root_block_device {
    volume_size = "10"
    volume_type = "standard"
}

ebs_block_device {
    device_name = "/dev/sdb"
    volume_size = "50"
    volume_type = "standard"
    delete_on_termination = "true"
}

tags = {
    Name = "MySpotInstance"
    Application = "MyApp"
    Environment = "TEST"
}
}
  • Does this answer your question? [AWS Spot Instance Limit](https://stackoverflow.com/questions/43217134/aws-spot-instance-limit) – Ben Whaley Feb 21 '20 at 05:26
  • Sometimes, an AZ may run out of specific EC2 instance class, and the error message from Terraform may not be reflecting it. Does the issue happen consistently after taking a few hours? – mon Feb 21 '20 at 12:23
  • Does it happen with other instance type other than c4.large? – mon Feb 21 '20 at 12:25
  • Run the script and worked having created RHEL-8.0.0_HVM-20190618-x86_64-1-Hourly2-GP2 (ami-0520e698dd500b1d1) in AZ-a in Ohio region. So code is not the issue. Please try creating the same spot instance from console? – mon Feb 21 '20 at 12:30
  • https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-spot-limits.html – mon Feb 21 '20 at 12:35
  • Yeah it looks like it is one of the service limits in Amazon. In this case the error is self explanatory but I have seen other Terraform error messages that are not directly indicative of the issue at hand, hence I decided to ask the question in this forum. I have reached out to AWS to have them increase the service limit so hopefully that fixes it. Thanks for all the answers! :) – Sim7Data Feb 22 '20 at 19:26

0 Answers0