Monitoring your AWS Service Limits

It’s all too easy to go past your AWS Service Limits if you’re dealing with big accounts.

E.g. the default for m4.largeper Region is 20. We’re currently running 65 in our smallest Region.

https://console.aws.amazon.com/trustedadvisor/

 

Attempt 1: using AWS’ solution

This unfortunately uses Cloudformation. Moving on…

Attempt 2: using awslimitchecker

See http://awslimitchecker.readthedocs.io/ comes to the rescue. You can write your AWS Lambda scripts with it and you’d be good to go.

E.g. List Limits for a Region

awslimitchecker -r eu-west-2 -S EC2 -l

Note that these are defined manually in ./limitchecker/lib/python2.7/site-packages/awslimitchecker/services/ec2.py

and are from https://aws.amazon.com/ec2/faqs/

However, if you have an account that’s already in use these limits may differ. And may also differ per Region.

As I said, it doesn’t query TrustedAdvisor dynamically. Moving on…

Attempt 3: getting the Service Limit data by CLI

Generic TA Check ID:

aws support describe-trusted-advisor-check-result --check-id eW7HH0l7J9 --region us-east-1

and the EC2 On-Demand Check ID:

aws support describe-trusted-advisor-check-result –language en –check-id 0Xc6LMYG8P –query ‘result.sort_by(flaggedResources[?status!=ok],&metadata[2])[].metadata’ –output table

https://docs.aws.amazon.com/cli/latest/reference/support/describe-trusted-advisor-check-result.html

For Check IDs per Service see: https://aws.amazon.com/premiumsupport/ta-iam/#Information_That_Trusted_Advisor_Displays

 

Note that this only seems to work for us-east-1 so you’ll need to make sure this is your default profile (or specify a profile that uses it).

E.g. for other endpoints I got:

Could not connect to the endpoint URL: “https://support.eu-west-2.amazonaws.com/”

and

Could not connect to the endpoint URL: “https://support.us-west-2.amazonaws.com/”

This seems to imply there are no Support endpoints other than us-east-1.

UPDATE: I was right:

AWS Support has a single endpoint: support.us-east-1.amazonaws.com (HTTPS).

https://docs.aws.amazon.com/general/latest/gr/rande.html#awssupport_region

 

More info: https://aws.amazon.com/premiumsupport/ta-faqs/

 

Note 2: if you don’t have Business or Enterprise support this CLI won’t work and you’ll get something like usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters].

You can use some Python like this for running EC2 instances:

so let’s just adapt it to:

 

 

AWS Lambda Triggers

The GUI has changed recently and it’s not as easy to find them.

They’re now in Lambda > Functions > Configuration in the Designer pane.

Assuming you’ve added a Trigger from the list on the left, then, to Enable, click on the Trigger and change it to Enabled.

http://www.snowcrash.eu/wp-content/uploads/2018/07/Screen-Shot-2018-07-20-at-09.56.31-300x192.png 300w, http://www.snowcrash.eu/wp-content/uploads/2018/07/Screen-Shot-2018-07-20-at-09.56.31-768x493.png 768w, http://www.snowcrash.eu/wp-content/uploads/2018/07/Screen-Shot-2018-07-20-at-09.56.31-588x377.png 588w, http://www.snowcrash.eu/wp-content/uploads/2018/07/Screen-Shot-2018-07-20-at-09.56.31.png 1143w" sizes="(max-width: 474px) 100vw, 474px" />

https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-edge-add-triggers-lam-console.html

AWS Lambda Handler

The Handler function for an AWS Lambda is specified by using the filename then function name. E.g. if the file is main.py and the handler function is entry.py then you’d use:

main.entry

Note, the defaults, if using the AWS console are lambda_function.lambda_handler.