Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. import boto3
  2.  
  3. region_list = ['us-west-1', 'us-west-2']
  4.  
  5. for region in region_list:
  6. print 'REGION:', region
  7. ec2 = boto3.resource('ec2', region)
  8. for instance in ec2.instances.all():
  9. print ' instance:', instance
  10. ec2tags = instance.tags
  11. print ' tags:', ec2tags
  12. for volume in instance.volumes.all():
  13. print ' volume:', volume
  14. # Create tags on volume if they don't match the instance
  15. if volume.tags != ec2tags:
  16. print '\033[93m' + 'Tags don\'t match, updating'
  17. volume.create_tags(DryRun=False, Tags=ec2tags)
  18. print ' tags:', volume.tags
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement