def lambda_handler()

in workshops/eda-workshop-lsf/scripts/delete.ebs.vols.py [0:0]


def lambda_handler(event, context):
    for vol in ec2.volumes.all():
        print (vol)
        if  vol.state=='available':
            if vol.tags is None:
                print ("No tag. Skipping " +vol.id)
                continue
            for tag in vol.tags:
                if tag['Key'] == '$mykey':
                    value=tag['Value']
                    if value == '$myvalue' and vol.state=='available':
                        vid=vol.id
                        v=ec2.Volume(vol.id)
                        print ("Deleting", vid, "based on tag", value, ".")