This file contains 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
#!/usr/bin/python | |
import boto3 | |
ec2 = boto3.resource('ec2', region_name='ap-southeast-2') | |
sgs = ec2.security_groups.all() | |
security_groups = [sg.id for sg in sgs] | |
for security_group in security_groups: | |
sg = ec2.SecurityGroup(security_group) | |
for i in range(len(sg.ip_permissions)): | |
for j in range(len(sg.ip_permissions[i]['IpRanges'])): | |
if "0.0.0.0/0" in sg.ip_permissions[i]['IpRanges'][j]['CidrIp']: |
This file contains 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 | |
import subprocess | |
import re | |
def lambda_handler(event, context): | |
elb = boto3.client('elb') | |
buk = boto3.resource('s3') | |
elbs = elb.describe_load_balancers() # Getting all load balancers | |
f1 = open('/tmp/elbs.html', 'w') # Making file empty for reuse | |
f1.close() | |
with open('/tmp/elbs.html', 'ab') as f: |
This file contains 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 #Calling Boto3 library | |
ec2 = boto3.resource('ec2', region_name='us-west-2') | |
sgs = ec2.security_groups.all() # Fetching all security groups in AWS account | |
all_sgs = set([sg.group_name for sg in sgs]) # Creating a list of only security group names | |
instances = ec2.instances.all() # Getting all instances in AWS account |