Skip to content

Instantly share code, notes, and snippets.

@alastairhm
Created June 11, 2020 07:45
Show Gist options
  • Save alastairhm/4d4e8750fe9763791881c4c63e93877e to your computer and use it in GitHub Desktop.
Save alastairhm/4d4e8750fe9763791881c4c63e93877e to your computer and use it in GitHub Desktop.
AWS Boto3 get Security Group Rule Limit
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