From a030bf8c7d0dab649755430a420d95f941841697 Mon Sep 17 00:00:00 2001 From: Agam More Date: Mon, 25 Sep 2023 13:35:56 +0400 Subject: [PATCH] Add download script --- .gitignore | 1 - script/download | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100755 script/download diff --git a/.gitignore b/.gitignore index e29716e..2485be8 100644 --- a/.gitignore +++ b/.gitignore @@ -46,4 +46,3 @@ output.txt output/ *.csv -script/download diff --git a/script/download b/script/download new file mode 100755 index 0000000..8402a8c --- /dev/null +++ b/script/download @@ -0,0 +1,19 @@ +#!/bin/bash +WORKSPACE=$(pwd) + +# Get the S3 bucket ARN from the Terraform outputs +cd "$WORKSPACE/tf/" +BUCKET_ARN=$(terraform output -raw s3_bucket_arn) +echo "Received bucket ARN: $BUCKET_ARN" +BUCKET_NAME=$(echo $BUCKET_ARN | cut -d':' -f6) + +# List the contents of the bucket +OBJECTS=$(aws s3 ls s3://$BUCKET_NAME/ --recursive | wc -l) +echo "Object count: $OBJECTS" + +# Download the contents of the bucket +mkdir -p "$WORKSPACE/output/" +aws s3 sync s3://$BUCKET_NAME/ "$WORKSPACE/output/" + +OBJECT_COUNT=$(ls -la $WORKSPACE/output/ | wc -l) +echo "Downloaded: $OBJECT_COUNT files." \ No newline at end of file