1

Currently we’re creating a localstack container using a docker-compose file, specifically for the purpose of using the S3 service.

We’ve added this line to the environment which creates an S3 bucket - AMAZONPROPERTIES.BUCKETNAME=bucketname

We’ve then created any additional buckets needed using a utility within our Java code.

However, it would be preferable to create all buckets needed automatically at the outset using our docker-compose file. Is it possible to do this?

FionaE
  • 43
  • 1
  • 5
  • 1
    See [here](https://stackoverflow.com/a/58490732/8705804) for creating initialization scripts to run natively when localstack is started. – feature_not_bug Dec 23 '19 at 19:11

1 Answers1

0

Not sure if it's the best way, but it works.

We're now running the docker-compose.yml in a bash script, waiting a short while to ensure that the service is running and then call a curl command within the docker container to create another S3 bucket.

#!/bin/bash
docker-compose -f docker-compose.yml up -d --build
echo "Waiting for Services to be ready"
sleep 20
docker exec -it general-files_general-files_1 curl -X POST 
https://localhost:7777/createBucket -F bucketName=bucketname2 --insecure
echo
echo "S3 buckets available are: "
docker exec -it general-files_general-files_1 curl -X GET 
https://localhost:7777/listBuckets --insecure
echo
echo "Services are ready for use" 
FionaE
  • 43
  • 1
  • 5