#!/bin/bash # Check if AWS CLI is installed if ! command -v aws &> /dev/null then echo "AWS CLI not found. Please install and configure the AWS CLI." exit 1 fi BUCKET_NAME=$S3_BUCKET_NAME # Function to delete all objects in the S3 bucket delete_objects() { local bucket_name=$1 echo "Deleting all objects in S3 bucket '$bucket_name'..." aws s3 rm "s3://$bucket_name" --recursive if [ $? -ne 0 ]; then echo "Failed to delete objects in S3 bucket '$bucket_name'." exit 1 fi } # Delete all objects in the bucket delete_objects "$BUCKET_NAME" echo "S3 bucket '$BUCKET_NAME' objects have been deleted successfully."