Add AttachDate tag to EBS volume and add script to find/delete inactive EBS volumes (#380)

Add AttachDate tag to EBS volume and add script to find/delete inactive EBS volumes
This commit is contained in:
Shirang Jia
2021-04-28 12:11:15 -07:00
committed by GitHub
parent 9f9b8f70b4
commit e0f8066a97
2 changed files with 107 additions and 1 deletions
@@ -303,7 +303,14 @@ def attach_volume(volume, volume_id, instance_id, timeout=DEFAULT_TIMEOUT):
if (time.clock() - timeout_init) > timeout:
print 'ERROR: Timeout reached trying to mount EBS'
exit(1)
volume.create_tags(
Tags=[
{
'Key': 'AttachDate',
'Value': str(datetime.datetime.today().date())
},
]
)
print 'Volume {} has been attached to instance {}'.format(volume_id, instance_id)