Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import boto3
- region_list = ['us-west-1', 'us-west-2']
- for region in region_list:
- print 'REGION:', region
- ec2 = boto3.resource('ec2', region)
- for instance in ec2.instances.all():
- print ' instance:', instance
- ec2tags = instance.tags
- print ' tags:', ec2tags
- for volume in instance.volumes.all():
- print ' volume:', volume
- # Create tags on volume if they don't match the instance
- if volume.tags != ec2tags:
- print '\033[93m' + 'Tags don\'t match, updating'
- volume.create_tags(DryRun=False, Tags=ec2tags)
- print ' tags:', volume.tags
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement