Localstack in docker : healthcheck specific s3 started

Viewed 1838

I Started a localstack container that works perfectly well but I need to wait for the s3 bucket created from the script located in /docker-entrypoint-initaws.d to be fully functionnal before launching my other container.

I know there is a possibility to wait for localstack to be fully prepared with :

healthcheck:
   test: ["CMD", "curl", "http://localhost:4566/health?reload"]

But is there a way that allows to check health for a specific s3 bucket ?

2 Answers

I figured it out :

healthcheck:
      test: [ "CMD", "awslocal", "s3api", "wait", "bucket-exists", "--bucket", "<name_of_your_bucket>" ]

Best way is to use AWS client (awslocal), but URL for specific bucket should be:

http://my-bucket-name.s3.localhost.localstack.cloud:4566/

a GET on this should return something like:

<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Name>my-bucket-name</Name>
<MaxKeys>1000</MaxKeys>
<IsTruncated>false</IsTruncated>
</ListBucketResult>
Related