1
0
Fork 0
mirror of https://github.com/docker/awesome-compose.git synced 2025-04-19 15:28:06 +02:00

Update localstack configuration

Signed-off-by: ulises-jeremias <ulisescf.24@gmail.com>
This commit is contained in:
ulises-jeremias 2024-01-19 00:02:23 -03:00
parent 199c896dee
commit 3c4739d174
4 changed files with 19 additions and 56 deletions

View file

@ -6,9 +6,10 @@ Project structure:
```text
.
├── init.d/
│ └── init.sh
├── compose.yaml
├── README.md
└── setup-resources.sh
└── README.md
```
[_compose.yaml_](compose.yaml)
@ -21,11 +22,6 @@ services:
- "4566:4566" # LocalStack Gateway
- "4510-4559:4510-4559" # external services port range
...
setup-resources:
image: mesosphere/aws-cli:1.14.5
volumes:
- ./:/project
...
```
## Deploy with docker compose
@ -34,7 +30,7 @@ services:
docker compose up -d
```
It will execute the script `setup-resources.sh` to setup the resources.
It will execute the scripts located in the `init.d/` folder to bootstrap the resources.
## Resources

View file

@ -19,24 +19,4 @@ services:
volumes:
- "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack"
- "/var/run/docker.sock:/var/run/docker.sock"
networks:
- localstack-net
setup-resources:
image: mesosphere/aws-cli:1.14.5
volumes:
- ./:/project
environment:
- AWS_ACCESS_KEY_ID=dummyaccess
- AWS_SECRET_ACCESS_KEY=dummysecret
- AWS_DEFAULT_REGION=us-east-1
entrypoint: /bin/sh -c
command: /project/setup-resources.sh
networks:
- localstack-net
depends_on:
- localstack
networks:
localstack-net:
driver: bridge
- "./init.d:/etc/localstack/init/ready.d"

14
localstack/init.d/init.sh Executable file
View file

@ -0,0 +1,14 @@
#!/bin/sh
awslocal kinesis create-stream --stream-name my_stream --shard-count 1
awslocal s3 mb s3://example-bucket
awslocal sqs create-queue --queue-name my_queue
awslocal dynamodb create-table --table-name my_table \
--attribute-definitions AttributeName=key,AttributeType=S \
--key-schema AttributeName=key,KeyType=HASH \
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
# you can go on and put initial items in tables...

View file

@ -1,27 +0,0 @@
#!/bin/sh
# Lets check if localstack is available. If we can't reach to localstack
# in 60 seconds we error out
counter=0
until nc -z localstack 4566; do
if [ ${counter} -eq 60 ]; then
echo "Timeout: Failed to reach localstack."
exit 1
fi
counter=$((counter + 1))
printf '.'
sleep 1
done
aws dynamodb create-table --endpoint-url=http://localstack:4566 --table-name my_table \
--attribute-definitions AttributeName=key,AttributeType=S \
--key-schema AttributeName=key,KeyType=HASH \
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
aws kinesis create-stream --endpoint-url=http://localstack:4566 --stream-name my_stream --shard-count 1
aws s3 mb s3://example-bucket --endpoint-url=http://localstack:4566
aws sqs create-queue --endpoint-url=http://localstack:4566 --queue-name my_queue
# you can go on and put initial items in tables...