Example #1
0
def test_boto3_describe_regions():
    ec2 = boto3.client('ec2', 'us-east-1')
    resp = ec2.describe_regions()
    resp['Regions'].should.have.length_of(16)
    for rec in resp['Regions']:
        rec['Endpoint'].should.contain(rec['RegionName'])

    test_region = 'us-east-1' 
    resp = ec2.describe_regions(RegionNames=[test_region])
    resp['Regions'].should.have.length_of(1)
    resp['Regions'][0].should.have.key('RegionName').which.should.equal(test_region)
Example #2
0
def test_boto3_describe_regions():
    ec2 = boto3.client("ec2", "us-east-1")
    resp = ec2.describe_regions()
    len(resp["Regions"]).should.be.greater_than(1)
    for rec in resp["Regions"]:
        rec["Endpoint"].should.contain(rec["RegionName"])

    test_region = "us-east-1"
    resp = ec2.describe_regions(RegionNames=[test_region])
    resp["Regions"].should.have.length_of(1)
    resp["Regions"][0].should.have.key("RegionName").which.should.equal(
        test_region)
Example #3
0
def get_running_ips(aws_region):
    ##### Get all regions
    ec2 = boto3.client('ec2', region_name='us-east-1')
    regionList = []
    response = ec2.describe_regions()
    regions = response['Regions']
    for r in regions:
        regionList.append(r['RegionName'])

    ##### Get running IPs for all regions
    running_ips = []
    for region in regionList:
        ec2 = boto3.client('ec2', region_name=region)
        reservations = ec2.describe_instances()['Reservations']
        for reservation in reservations:
            for instance in reservation['Instances']:
                try:
                    if instance['State']['Name'] == 'running':
                        if 'VpcId' in instance:
                            running_ips.append(instance['PrivateIpAddress'])
                        else:
                            running_ips.append(instance['PublicIpAddress'])
                except:
                        pass

    return running_ips
def test_boto3_availability_zones():
    ec2 = boto3.client("ec2", "us-east-1")
    resp = ec2.describe_regions()
    regions = [r["RegionName"] for r in resp["Regions"]]
    for region in regions:
        conn = boto3.client("ec2", region)
        resp = conn.describe_availability_zones()
        for rec in resp["AvailabilityZones"]:
            rec["ZoneName"].should.contain(region)
def test_boto3_availability_zones():
    ec2 = boto3.client('ec2', 'us-east-1')
    resp = ec2.describe_regions()
    regions = [r['RegionName'] for r in resp['Regions']]
    for region in regions:
        conn = boto3.client('ec2', region)
        resp = conn.describe_availability_zones()
        for rec in resp['AvailabilityZones']:
            rec['ZoneName'].should.contain(region)
def test_boto3_describe_regions():
    ec2 = boto3.client('ec2', 'us-east-1')
    resp = ec2.describe_regions()
    resp['Regions'].should.have.length_of(14)
    for rec in resp['Regions']:
        rec['Endpoint'].should.contain(rec['RegionName'])