This sample demonstrates how to run LocalStack for Snowflake and LocalStack for AWS in separate Docker containers with proper networking configuration.
- A valid LocalStack for Snowflake license with access to the Snowflake Next preview. Your license provides a
LOCALSTACK_AUTH_TOKEN. - Docker with Docker Compose
- AWS CLI, Snowflake CLI (
snow) andjq, to runmake test
docker-compose.yml runs two containers on a Docker bridge network named localstack:
localstack-snowflake: the Snowflake emulator (localstack/snowflake-next), on port 4567localstack-aws: the AWS emulator (localstack/localstack), on port 4566
Both ports are published on 127.0.0.1 only.
The Snowflake emulator listens on 4566 and 443 by default. GATEWAY_LISTEN=0.0.0.0:4567 moves it to 4567, so it does not clash with the AWS container. Every port serves both HTTPS and plain HTTP.
SF_HOSTNAMES lists the hostnames the Snowflake emulator answers to:
SF_HOSTNAMES=snowflake.localhost.localstack.cloud,localstack-snowflakesnowflake.localhost.localstack.cloudis the default hostname, used by clients on your machine. As the first entry it is also the API host the emulator advertises.localstack-snowflakeis the container name, used by the AWS container inside the Docker network.
The list replaces the built-in one. A request whose Host matches no entry gets a 404, so add localhost if your clients use it.
The image has bash but no curl or python3, so the health check reads /_localstack/health over bash's /dev/tcp.
-
Set your LocalStack auth token:
export LOCALSTACK_AUTH_TOKEN=your-token-here -
Start the containers and wait until both are healthy:
make start
-
Run the test:
make test
To check that the AWS container reaches the Snowflake emulator by container name, log in from inside it. The localstack/localstack image has no curl, so the request is sent with Python:
docker exec localstack-aws python3 -c "
import json, urllib.request
body = json.dumps({'data': {'LOGIN_NAME': 'test', 'PASSWORD': 'test', 'ACCOUNT_NAME': 'test'}}).encode()
req = urllib.request.Request('http://localstack-snowflake:4567/session/v1/login-request', data=body,
headers={'Content-Type': 'application/json'})
print(json.load(urllib.request.urlopen(req))['success'])
"It prints True. This confirms that:
- The Docker network is configured
SF_HOSTNAMESroutes the container name to the Snowflake emulator- The Snowflake emulator accepts logins
If the login fails, check:
-
Both containers are running and healthy:
docker compose ps
-
The containers are on the same network:
docker network inspect localstack
-
SF_HOSTNAMESincludes the container name -
The container logs:
make logs
Loading data from an S3 bucket in localstack-aws into a table in localstack-snowflake needs the Snowflake emulator to know how to reach the AWS emulator. docker-compose.yml sets this up:
environment:
- SF_S3_ENDPOINT=http://localstack-aws:4566SF_S3_ENDPOINT is the S3 endpoint the Snowflake emulator calls to read external s3:// stages (COPY INTO, LIST, Snowpipe auto-ingest). It is never advertised to clients.
Internal stages (PUT/GET) are served by the Snowflake emulator itself, on the port the client connected on, so they need no setting here.
With this configuration, you can:
- Create an S3 bucket and upload data in LocalStack AWS
- Create a Snowflake stage pointing to the S3 bucket
- Use
COPY INTOcommands to load data from S3 into Snowflake tables
make test runs both checks: the session request from the AWS container, and a CSV loaded from an S3 bucket into a Snowflake table through a stage.
For detailed instructions on S3 integration and other cross-service capabilities, see the references below.
Stop and remove containers:
make stopRemove volumes:
docker compose down -v
rm -rf ./volumelocalstack/snowflake-nexton Docker Hub: configuration options of the Snowflake Next emulator, includingSF_HOSTNAMES,SF_S3_ENDPOINTandGATEWAY_LISTEN- LocalStack for Snowflake Configuration: configuration of the generally available emulator
- LocalStack Multi-Service Networking: network troubleshooting and configuration for multi-container setups