User Tools

Site Tools


aws:ebsvolumes

EBS Volumes

Elastic Block Storage (EBS) volumes are block storage (as opposed to object stores such as S3) and are typically attached to EC2 instances.

Show encryption status of EBS

Best practice is for EBS volumes to be encrypted. This script will show the volume status for each volume in the account and what it is attached to (if any). It is possible to have a volume attached to multiple ec2 instances but EBS does not handle file locking etc, so this is unusual.

#!/usr/bin/python3
 
import boto3
ec2_client = boto3.client('ec2')
 
response = ec2_client.describe_volumes()
 
for vol in range(len(response['Volumes'])):
    if len(response['Volumes'][vol]['Attachments']) == 0:
        # print("Zero length list") 
        print(response['Volumes'][vol]['VolumeId'], "is", \
        response['Volumes'][vol]['State'], "Encryption Status is", \
        response['Volumes'][vol]['Encrypted'])
        continue
    else:
        print(response['Volumes'][vol]['VolumeId'], "is", \
        response['Volumes'][vol]['State'], "attached to", \
        response['Volumes'][vol]['Attachments'][0]['InstanceId'], \
        "Encryption Status is", response['Volumes'][vol]['Encrypted'])
aws/ebsvolumes.txt · Last modified: by andrew

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki