Skip to content

Commit 69bb5bc

Browse files
committed
unused aws instace and vpcs cleanup
Signed-off-by: shiva kumar <[email protected]>
1 parent 456dc24 commit 69bb5bc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

.github/workflows/awscleanup.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ jobs:
4141
echo "Found instances: $running_instances"
4242
echo "instances=$running_instances" >> $GITHUB_ENV
4343
44-
# Find unused VPCs
44+
# Find vpcs with names ci* running longer than 4 hours
4545
vpcs=$(aws ec2 describe-vpcs \
4646
--filters Name=tag:Name,Values=ci* \
47-
--query "Vpcs[?IsDefault==\`false\` && CreationTimestamp<=\`$(date -u -d '4 hours ago' +%Y-%m-%dT%H:%M:%SZ)\`].VpcId" \
47+
--query "Vpcs[?Tags[?Key=='Name' && Value==`ci*`] && Tags[?Key=='CreationTime' && Value<=`$(date -u -d '4 hours ago' +%Y-%m-%dT%H:%M:%SZ)`]].VpcId" \
4848
--output text | tr -d '\r' | tr '\n' ' ')
4949
5050
echo "Found VPCs: $vpcs"

0 commit comments

Comments
 (0)