Create a Docker-Compose configuration:
version: "3.8"
services:
localstack:
container_name: "${LOCALSTACK_DOCKER_NAME-localstack_main}"
image: localstack/localstack
ports:
- "127.0.0.1:4566:4566"
environment:
- DEBUG=1
- DOCKER_HOST=unix:///var/run/docker.sock
volumes:
- "${PWD}/init-aws.sh:/etc/localstack/init/ready.d/init-aws.sh" # ready hook
- "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack"
- "/var/run/docker.sock:/var/run/docker.sock"
Ensure that your init-aws.sh
file is in the same directory as the Compose configuration.
Create a init-aws.sh
file with the following content:
#!/bin/bash
awslocal kinesis create-stream --stream-name samplestream --shard-count 1
Make the script executable: chmod +x init-aws.sh
.
Start the Docker Compose: docker-compose up
.
You will find the following in your logs:
localstack_main | 2023-04-26T03:04:14.890 INFO --- [ asgi_gw_0] l.s.k.kinesis_mock_server : Creating kinesis backend for account 000000000000
localstack_main | 2023-04-26T03:04:18.935 INFO --- [-functhread7] l.s.k.kinesis_mock_server : [io-compute-blocker-2] INFO 2023-04-26 03:04:18,933 k.m.KinesisMockService contextId=09267c32-e3df-11ed-a039-bb213401b87c, cacheConfig={"awsAccountId":"000000000000","awsRegion":"us-east-1","createStreamDuration":{"length":500,"unit":"MILLISECONDS"},"deleteStreamDuration":{"length":500,"unit":"MILLISECONDS"},"deregisterStreamConsumerDuration":{"length":500,"unit":"MILLISECONDS"},"initializeStreams":null,"mergeShardsDuration":{"length":500,"unit":"MILLISECONDS"},"onDemandStreamCountLimit":10,"persistConfig":{"fileName":"000000000000.json","interval":{"length":5,"unit":"SECONDS"},"loadIfExists":true,"path":"/var/lib/localstack/tmp/state/kinesis","shouldPersist":true},"registerStreamConsumerDuration":{"length":500,"unit":"MILLISECONDS"},"shardLimit":100,"splitShardDuration":{"length":500,"unit":"MILLISECONDS"},"startStreamEncryptionDuration":{"length":500,"unit":"MILLISECONDS"},"stopStreamEncryptionDuration":{"length":500,"unit":"MILLISECONDS"},"updateShardCountDuration":{"length":500,"unit":"MILLISECONDS"}} - Logging Cache Config
localstack_main | 2023-04-26T03:04:20.856 INFO --- [-functhread7] l.s.k.kinesis_mock_server : [io-compute-blocker-6] INFO 2023-04-26 03:04:20,855 k.m.KinesisMockService - Starting Kinesis TLS Mock Service on port 50733
localstack_main | 2023-04-26T03:04:20.856 INFO --- [-functhread7] l.s.k.kinesis_mock_server : [io-compute-blocker-6] INFO 2023-04-26 03:04:20,856 k.m.KinesisMockService - Starting Kinesis Plain Mock Service on port 54499
localstack_main | 2023-04-26T03:04:20.863 INFO --- [-functhread7] l.s.k.kinesis_mock_server : [io-compute-3] INFO 2023-04-26 03:04:20,863 k.m.KinesisMockService contextId=0a4fe103-e3df-11ed-a039-bb213401b87c - Starting persist data loop
localstack_main | 2023-04-26T03:04:22.177 INFO --- [ asgi_gw_0] localstack.request.aws : AWS kinesis.CreateStream => 200
Check your Kinesis streams:
awslocal kinesis list-streams
I hope this helps!