localstackコンテナのdocker-entrypoint-initaws.dの挙動について

以下の設定をしたlocalstackコンテナを立ち上げても、.shが実行されないことがある現象に出くわした.

    volumes:
      - ./localstack:/docker-entrypoint-initaws.d

調べた結果initaws.dで実行したsh内でエラーがあるとそれ以降の処理が継続されないというものだった.
上記機能でコンテナ立ち上げ時にバケットを作成する処理を入れていたのだが、既にバケットが作成済みの場合にalready exitstsと言われてエラーになるため2度目の起動以降バケット作成処理が走らないという感じである.
ということで以下のようにして同名バケット作成済みの場合はなにもしないようにした.

make_buckets.sh

target_buckets=("bucket1"
                "bucket2")

current_buckets=$(aws s3 ls --endpoint-url=http://localhost:4566)

for bucket in "${target_buckets[@]}"; do
  if [ -z "`echo $current_buckets | grep $bucket`" ]; then
    aws s3 mb s3://${bucket} --region ap-northeast-1 --endpoint-url http://localhost:4566
    echo "s3://${bucket} created."
  fi
done