From ff184aa48447de1b3f2b4f2f1c5788d14b586b7c Mon Sep 17 00:00:00 2001 From: CHIKAMATSU Naohiro Date: Fri, 29 Dec 2023 23:11:17 +0900 Subject: [PATCH] add: script for copying file to s3 --- script/.gitkeep | 0 script/create_s3objects.sh | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+) delete mode 100644 script/.gitkeep create mode 100755 script/create_s3objects.sh diff --git a/script/.gitkeep b/script/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/script/create_s3objects.sh b/script/create_s3objects.sh new file mode 100755 index 0000000..e3b020c --- /dev/null +++ b/script/create_s3objects.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -oeu pipefail + +ROOT_DIR=$(git rev-parse --show-toplevel) +SCRIPT_DIR="${ROOT_DIR}/script" +THIS_SCRIPT="${SCRIPT_DIR}/create_s3objects.sh" + +export AWS_PROFILE="localstack" + +echo "creating 'test-bucket-on-localstack'(s3 bucket)" +aws s3 mb s3://test-bucket-on-localstack --endpoint-url=http://localhost:4566 + +echo "copying 10000 files to 'test-bucket-on-localstack'(s3 bucket)" +for i in {1..10000}; do + aws s3 cp "${THIS_SCRIPT}" "s3://test-bucket-on-localstack/object${i}.txt" --endpoint-url=http://localhost:4566 --quiet + + if [ $((i % 100)) -eq 0 ]; then + echo "Processed $i objects" + fi +done + +echo "done"