Ebs volumes by its state where it is ‘available’ or ‘in-use’ using boto3 filter method by tag.
Here we can learn:
How to crate a resource object for any resource ex: ec2
How to write a filter method to fetch volumes state.
How to apply filter method fetch volume ids using their tags
By State:
import boto3
ec2 = boto3.resource(‘ec2’)
fil_vol={“Name”:”status”,”Values”:[‘in-use’]}
for each_vol in ec2.volumes.filter(Filters=[fil_tag]):
print (each_vol.id)
By Tag Values:
import boto3
ec2 = boto3.resource(‘ec2’)
fil_tag={‘Name’: ‘tag:Backup’, ‘Values’: [‘Yes’]}
for each_vol in ec2.volumes.filter(Filters=[fil_tag]):
print (each_vol.id)
List and filter your different AWS resources available
boto3 list all ebs volumes
python boto ec2 example
boto3 terminate instance
start and stop ec2 instance using python
boto3 ec2 tags
boto3 filters
boto3 list ec2 instances
ec2.instance attributes boto3
list ebs volumes boto3
list ebs volumes aws cli
list ebs volumes linux
list ebs volumes aws
list all ebs volumes
ec2 list ebs volumes
powershell list ebs volumes
list all ebs volumes boto3
aws ec2 ebs volumes
boto3 get all ebs volumes
boto get all volumes
tag ebs volumes
source
Thanks so much!!!
what is the difference between client and resource ? I have seen sometimes we take client and sometimes resource ?