File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
src/github_actions/common/providers/aws_provider Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -131,6 +131,20 @@ def print_orphaned_volumes(self):
131131 f"| { vol ['Name' ]} | { vol ['State' ]} | { vol ['VolumeType' ]} | { vol ['SizeGiB' ]} "
132132 )
133133
134+ def delete_orphaned_volumes (self ):
135+ volumes = self .list_orphaned_volumes ()
136+ if not volumes :
137+ return
138+
139+ print (f"Found { len (volumes )} orphaned volumes. Deleting..." )
140+ for vol in volumes :
141+ vol_id = vol ["VolumeId" ]
142+ try :
143+ self .ec2_client .delete_volume (VolumeId = vol_id )
144+ print (f"Deleted volume { vol_id } " )
145+ except (ClientError , BotoCoreError ) as err :
146+ raise ValueError (f"failed to delete volume { vol_id } : { err } " )
147+
134148
135149class S3BucketManager (AWSSessionManager ):
136150 def __init__ (self , region_name : str ):
You can’t perform that action at this time.
0 commit comments