-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathefs.py
More file actions
43 lines (34 loc) · 1.42 KB
/
efs.py
File metadata and controls
43 lines (34 loc) · 1.42 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import boto3
def list_aws_regions():
# Initialize the EC2 client with default region
ec2 = boto3.client('ec2')
# Retrieve all regions that work with EC2
response = ec2.describe_regions()
# Extract region names from the response
regions = [region['RegionName'] for region in response['Regions']]
return regions
def list_efs_file_systems(region):
# Create an EFS client for the specified region
efs = boto3.client('efs', region_name=region)
# Initialize a list to hold all file systems
file_systems = []
# Retrieve all EFS file systems
paginator = efs.get_paginator('describe_file_systems')
for page in paginator.paginate():
file_systems.extend(page['FileSystems'])
return file_systems
# Specify the region you are interested in
regions = list_aws_regions()
# Print details about each file system
for region in regions:
print(f"___________For Region: {region} ___________")
# Get the list of EFS file systems
efs_file_systems = list_efs_file_systems(region)
print(efs_file_systems)
# for fs in efs_file_systems:
# print(f"File System ID: {fs['FileSystemId']}")
# print(f"Name: {fs.get('Name', 'No name provided')}")
# print(f"Creation Time: {fs['CreationTime']}")
# print(f"Life Cycle State: {fs['LifeCycleState']}")
# print(f"Number of Mount Targets: {len(fs['MountTargets'])}")
# print() # Print a newline for better readability