import boto3
from botocore.exceptions import ClientError
ec2 = boto3.client('ec2')
ips = 'x.x.x.x/32'
def sg_check():
response = ec2.describe_security_groups()['SecurityGroups']
for i in response:
sgid = i['GroupId']
for j in i['IpPermissions']:
for x in j['IpRanges']:
if x['CidrIp'] == ips:
print(sgid,x['CidrIp'],x['Description'])
if __name__ == "__main__":
sg_check()
'AWS Infra' 카테고리의 다른 글
[ AWS ] Python Boto3를 이용한 CloudFront Invalidation (무효화) (0) | 2023.01.13 |
---|---|
[ AWS ] S3 특정 확장자 파일만 업로드 하는 버킷정책 (0) | 2023.01.13 |
[ AWS ] Python boto3를 이용한 S3 파일 업로드 / 다운로드 (0) | 2022.12.28 |
[ AWS ] Amazon Linux nginx Install (0) | 2022.10.11 |
[ AWS ] RDS mysql Slow Query Monitoring ( Cloudwatch ) (0) | 2022.06.29 |
[ AWS ] EventBridge cron expressions (0) | 2022.03.21 |
[ AWS ] EC2 인스턴스 Type 변경후 재시작 (0) | 2022.03.16 |
[ AWS CLI ] describe-subnets (0) | 2022.03.14 |