API for checking EC2 instance limit

0 votes

I use extensively EC2 instances for testing distributed system. Unfortunately, sometimes I hit the limit of running instances which cause the whole deployment to fail. I catch the appropriate exception, but I would prefer to avoid the whole deployment rather than failing after launching several instances. To avoid that kind of situation I would like to have a preflight check:

number_of_running_instances + number_of_required_instances <= instance_limit

I could easily check number_of_running_instances and number_of_required_instances, but I couldn't find an API for checking instance_limit. Moreover, I would prefer not to assume that the limit is default because some of the AWS accounts at our company applied for the higher limit.

Is there any workaround to solve that issue?

Sep 24, 2018 in AWS by datageek
• 2,530 points
395 views

1 answer to this question.

0 votes

No, there is no way to do this. But there really isn't a need to do it because catching the exception (and gracefully handling it) is a better design. When launching an entire fleet any number of issues can arise: API calls mysteriously disappear in the void, AWS doesn't have the capacity to launch a certain instance type in the requested AZ, instances and EBS volumes can get stuck during creation, etc.

With the amount of unknown problems that can crop up when deploying AWS resources, you should plan on problems happening rather regularly. Your code needs to anticipate that and workaround it.

It's worth noting that you're using a CloudFormation template to do your provisioning, much of the pain associated with this is mitigated. Rollbacks of all resources are automatically executed on error.

answered Sep 24, 2018 by Archana
• 4,170 points

Related Questions In AWS

0 votes
3 answers
+1 vote
1 answer

What AWS EC2 instance is more suitable for Chat Application?

I would recommend starting with a T2.micro ...READ MORE

answered Jul 10, 2018 in AWS by Priyaj
• 58,090 points
662 views
0 votes
1 answer

IP allotment for EC2 Instance in AWS

No, you don't need an Elastic IP address for ...READ MORE

answered Jan 24, 2019 in AWS by ritwik
613 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Create Amazon EC2 instance with API

If you are looking for a method ...READ MORE

answered Jul 20, 2018 in AWS by Archana
• 4,170 points
886 views
0 votes
1 answer

How to set up a SPF(Sender Policy Framework) for AWS EC2 instance?

Setting up a SPF record is pretty ...READ MORE

answered Aug 16, 2018 in AWS by Archana
• 4,170 points
1,382 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP