Using Python boto3 library, I am not able to fetch ec2 instance(irrespective of Linux or windows OS) usage of "ebs volume". I am not able to authorize to install any agents on all ec2 instance as it is owned by different product team. How to get this information without login to EC2 instance? If it is not possible then please suggest better way to fetch this information in automated way.
I have tried using boto3 library using python to fetch details, but unable to find out the way to get used space of ebs volume attached on EC2 instance.
import boto3
if __name__ == '__main__':
session = boto3.session.Session(profile_name="default")
ec2 = session.resource(service_name='ec2', region_name='us-east-2')
instance = ec2.Instance('-----------')
volumes = instance.volumes.all()
for v in volumes:
print(v.id, v.size, v.state, v.kms_key_id, v.availability_zone, v.volume_type, v.encrypted, v.iops, v.snapshot_id, v.create_time)
Please help me to find out to get ec2 instance metric report of ebs volume usage on automation way, as I have task to get ebs volume size of ec2 instance and compare threshold, after compare then i need to fire event such as email notification, increase of size etc.