Created
June 11, 2020 07:45
-
-
Save alastairhm/4d4e8750fe9763791881c4c63e93877e to your computer and use it in GitHub Desktop.
AWS Boto3 get Security Group Rule Limit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
def get_limit_value(service_code, quota_name): | |
client = boto3.client('service-quotas') | |
paginator = client.get_paginator('list_service_quotas') | |
page_iterator = paginator.paginate(ServiceCode=service_code) | |
for page in page_iterator: | |
for quota in page['Quotas']: | |
if quota['QuotaName'] == quota_name: | |
return int(quota['Value']) | |
rules_per_sg = get_limit_value('vpc', 'Inbound or outbound rules per security group') | |
print(rules_per_sg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment