brennerm / aws-quota-checker

Keep an eye on your AWS quotas before you hit their limits
https://pypi.org/project/aws-quota-checker/
MIT License
84 stars 36 forks source link

ec2_on_demand_standard_count check is incorrect? #15

Open pglass opened 3 years ago

pglass commented 3 years ago

This seems to be checking the current number of instances, when it should be checking the number of vCPUs:

$ aws-quota-checker check 'ec2_on_demand_standard_count'
AWS profile: default | AWS region: us-east-2 | Active checks: ec2_on_demand_standard_count
Running On-Demand Standard (A, C, D, H, I, M, R, T, Z) EC2 instances [************]: 178/980 ✓

This shows 178/980, which does not match Trusted Advisor:

Screen Shot 2021-04-27 at 1 34 03 PM

And does not match Service Quotas:

Screen Shot 2021-04-27 at 1 32 02 PM

brennerm commented 3 years ago

Hey @pglass, thanks for reporting this issue.

Can you please clone the repo, switch to this branch and see if the issue is fixed?

pglass commented 3 years ago

No, still seeing the same:

$ git clone https://github.com/brennerm/aws-quota-checker.git
Cloning into 'aws-quota-checker'...
remote: Enumerating objects: 205, done.
remote: Counting objects: 100% (205/205), done.
remote: Compressing objects: 100% (127/127), done.
remote: Total 205 (delta 117), reused 145 (delta 67), pack-reused 0
Receiving objects: 100% (205/205), 477.96 KiB | 1.36 MiB/s, done.
Resolving deltas: 100% (117/117), done.
$ virtualenv .venv
created virtual environment CPython3.6.8.final.0-64 in 236ms
  creator CPython3Posix(dest=/Users/pglass/cvm-453/.venv, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/Users/pglass/Library/Application Support/virtualenv)
    added seed packages: pip==21.0.1, setuptools==56.0.0, wheel==0.36.2
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
$ . .venv/bin/activate
(.venv) $ pip install ./aws-quota-checker/
Looking in indexes: https://nexus.corp.indeed.com/repository/pypi/simple
Processing ./aws-quota-checker
^CERROR: Operation cancelled by user
WARNING: You are using pip version 21.0.1; however, version 21.1 is available.
You should consider upgrading via the '/Users/pglass/cvm-453/.venv/bin/python -m pip install --upgrade pip' command.
(.venv) $ cd aws-quota-checker/
(.venv) IT-USA-30004:aws-quota-checker pglass$ git checkout increase-max-results-ec2
Branch 'increase-max-results-ec2' set up to track remote branch 'increase-max-results-ec2' from 'origin'.
Switched to a new branch 'increase-max-results-ec2'
(.venv) IT-USA-30004:aws-quota-checker pglass$ git show
commit baec59a2affdcf6c46a7629057d696dd3dbbe793 (HEAD -> increase-max-results-ec2, origin/increase-max-results-ec2)
Author: Max Brenner <xamrennerb@gmail.com>
Date:   Tue Apr 27 20:51:38 2021 +0200

    set max results for describing EC2 instances to 1000

diff --git a/aws_quota/check/ec2.py b/aws_quota/check/ec2.py
index fec8135..b5fb577 100644
--- a/aws_quota/check/ec2.py
+++ b/aws_quota/check/ec2.py
@@ -12,7 +12,8 @@ def get_all_running_ec2_instances(session: boto3.Session):
                     'Name': 'instance-state-name',
                     'Values': ['running']
                 }
-            ]
+            ],
+            MaxResults=1000
             )['Reservations'] for instance in reservations['Instances']]

(.venv) IT-USA-30004:aws-quota-checker pglass$ cd ..
(.venv) $ pip install ./aws-quota-checker/
Looking in indexes: https://nexus.corp.indeed.com/repository/pypi/simple
Processing ./aws-quota-checker
Collecting boto3
  Using cached https://nexus.corp.indeed.com/repository/pypi/packages/boto3/1.17.59/boto3-1.17.59-py2.py3-none-any.whl (131 kB)
Collecting click
  Using cached https://nexus.corp.indeed.com/repository/pypi/packages/click/7.1.2/click-7.1.2-py2.py3-none-any.whl (82 kB)
Collecting tabulate
  Using cached https://nexus.corp.indeed.com/repository/pypi/packages/tabulate/0.8.9/tabulate-0.8.9-py3-none-any.whl (25 kB)
Collecting cachetools
  Using cached https://nexus.corp.indeed.com/repository/pypi/packages/cachetools/4.2.1/cachetools-4.2.1-py3-none-any.whl (12 kB)
Collecting jmespath<1.0.0,>=0.7.1
  Using cached https://nexus.corp.indeed.com/repository/pypi/packages/jmespath/0.10.0/jmespath-0.10.0-py2.py3-none-any.whl (24 kB)
Collecting s3transfer<0.5.0,>=0.4.0
  Using cached https://nexus.corp.indeed.com/repository/pypi/packages/s3transfer/0.4.2/s3transfer-0.4.2-py2.py3-none-any.whl (79 kB)
Collecting botocore<1.21.0,>=1.20.59
  Using cached https://nexus.corp.indeed.com/repository/pypi/packages/botocore/1.20.59/botocore-1.20.59-py2.py3-none-any.whl (7.4 MB)
Collecting urllib3<1.27,>=1.25.4
  Using cached https://nexus.corp.indeed.com/repository/pypi/packages/urllib3/1.26.4/urllib3-1.26.4-py2.py3-none-any.whl (153 kB)
Collecting python-dateutil<3.0.0,>=2.1
  Using cached https://nexus.corp.indeed.com/repository/pypi/packages/python-dateutil/2.8.1/python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
Collecting six>=1.5
  Using cached https://nexus.corp.indeed.com/repository/pypi/packages/six/1.15.0/six-1.15.0-py2.py3-none-any.whl (10 kB)
Building wheels for collected packages: aws-quota-checker
  Building wheel for aws-quota-checker (setup.py) ... done
  Created wheel for aws-quota-checker: filename=aws_quota_checker-1.5.0-py3-none-any.whl size=24201 sha256=07cebeeee04d4ecc764a823dd30c5f8c538c2f3a0ef5ecfaeb87d4948dc5b41e
  Stored in directory: /Users/pglass/Library/Caches/pip/wheels/e8/51/26/571afbb20c1c854d10f520325969bbe9cd28529115137a5ade
Successfully built aws-quota-checker
Installing collected packages: six, urllib3, python-dateutil, jmespath, botocore, s3transfer, tabulate, click, cachetools, boto3, aws-quota-checker
Successfully installed aws-quota-checker-1.5.0 boto3-1.17.59 botocore-1.20.59 cachetools-4.2.1 click-7.1.2 jmespath-0.10.0 python-dateutil-2.8.1 s3transfer-0.4.2 six-1.15.0 tabulate-0.8.9 urllib3-1.26.4
WARNING: You are using pip version 21.0.1; however, version 21.1 is available.
You should consider upgrading via the '/Users/pglass/cvm-453/.venv/bin/python -m pip install --upgrade pip' command.
(.venv) $ aws-quota-checker check 'ec2_on_demand_standard_count'
AWS profile: default | AWS region: us-east-2 | Active checks: ec2_on_demand_standard_count
Running On-Demand Standard (A, C, D, H, I, M, R, T, Z) EC2 instances [243295163524]: 179/980 ✓
brennerm commented 3 years ago

Mmh strange, let me investigate a bit further.

Razgoldenberg1 commented 1 year ago

hey, the problem is that the limit is based on the vCPUs and the current that you get is the number of running instances. I have the same problem I hope that they will find a way to change it.