From d306460d188ddf096ce049422a363eeea7cb91f7 Mon Sep 17 00:00:00 2001 From: shiva kumar Date: Fri, 20 Dec 2024 13:29:56 +0530 Subject: [PATCH] Add script to clean-up unused AWS EC2 Instances and VPCs Signed-off-by: shiva kumar --- scripts/awscleanup.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/awscleanup.sh b/scripts/awscleanup.sh index 3e0b3bcb..a7a66bb8 100755 --- a/scripts/awscleanup.sh +++ b/scripts/awscleanup.sh @@ -8,6 +8,10 @@ fi export vpcid=$1 get_tag_value(){ + if [[ $# -ne 2 ]]; then + echo " vpcid and key required to get tag value" + exit 1 + fi local vpc=$1 local key=$2 aws ec2 describe-tags --filters "Name=resource-id,Values=$vpcid" "Name=key,Values=$key" \ @@ -19,7 +23,7 @@ delete_vpc_resources() { echo " vpcid required for deletion" exit 1 fi - export vpcid=$1 + local vpcid=$1 echo "Start cleanup of resources in VPC: $vpcid"