Skip to content

Commit

Permalink
Check if local aws is ready before creating mocked data
Browse files Browse the repository at this point in the history
Signed-off-by: Oleksandr Solodovnikov <[email protected]>
  • Loading branch information
osolodovn-here committed Dec 10, 2024
1 parent a18b658 commit 89e70af
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,25 @@
# License-Filename: LICENSE
#

awslocal s3api create-bucket --bucket test-bucket --create-bucket-configuration LocationConstraint=eu-west-1
check_localstack_health() {
local RETRIES=10
local RETRY_DELAY=5
local SERVICE="healthy"

for ((i=0; i < RETRIES; i++)); do
if awslocal s3api list-buckets >/dev/null 2>&1; then
echo "LocalStack S3 service is ready."
return 0
else
echo "Waiting for LocalStack S3 service to be ready... (attempt $((i+1))/${RETRIES})"
sleep $RETRY_DELAY
fi
done

echo "LocalStack S3 service is not ready after ${RETRIES} attempts. Exiting..."
exit 1
}

check_localstack_health

awslocal s3api create-bucket --bucket test-bucket --create-bucket-configuration LocationConstraint=eu-west-1

0 comments on commit 89e70af

Please sign in to comment.