-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalb.py
More file actions
27 lines (21 loc) · 862 Bytes
/
alb.py
File metadata and controls
27 lines (21 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import boto3
def list_albs(region):
# Initialize an ELBv2 client for the specified region
elbv2 = boto3.client('elbv2', region_name=region)
# List all Load Balancers in the region
response = elbv2.describe_load_balancers()
# Filter ALBs from the response
albs = [lb for lb in response['LoadBalancers'] if lb['Type'] == 'application']
return albs
# Call the function to list ALBs in a specific AWS region
region = 'us-west-2' # Change to your desired region
albs = list_albs(region)
print("Application Load Balancers:")
for alb in albs:
print(f"Name: {alb['LoadBalancerName']}")
print(f"DNS Name: {alb['DNSName']}")
print(f"VPC ID: {alb['VpcId']}")
print(f"Availability Zones: {', '.join(alb['AvailabilityZones'])}")
print(f"Type: {alb['Type']}")
print(f"Date created: {alb['CreatedTime']}")
print()