Skip to content

Commit

Permalink
Added support for LOCALSTACK_AUTH_TOKEN
Browse files Browse the repository at this point in the history
Added example for shared DNS on docker network.
  • Loading branch information
cabeaulac committed Oct 12, 2023
1 parent 2f8afe9 commit 98c9944
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .env-gdc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ if [[ "$USE_CDK" = "yes" && -z "$NODE_VERSION" ]]; then
fi


if [ -n "$LOCALSTACK_API_KEY" ]; then
if [ -n "$LOCALSTACK_API_KEY" ] || [ -n "$LOCALSTACK_AUTH_TOKEN" ]; then
export LS_IMAGE=${LS_IMAGE:="localstack/localstack-pro"} # use pro image if API key is provided
else
export LS_IMAGE=${LS_IMAGE:="localstack/localstack"} # can override with custom image location. Still uses LS_VERSION to create final image location.
Expand Down
1 change: 1 addition & 0 deletions dc-ls-host.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ services:
environment:
# needed for LS Pro
- LOCALSTACK_API_KEY=${LOCALSTACK_API_KEY-}
- LOCALSTACK_AUTH_TOKEN=${LOCALSTACK_AUTH_TOKEN-}
- EXTRA_CORS_ALLOWED_ORIGINS=http://host.docker.internal:4566
- DISABLE_CORS_CHECKS=1
- PROVIDER_OVERRIDE_S3=v3 # new LS native s3
Expand Down
2 changes: 2 additions & 0 deletions dc-ls.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ services:
- KINESIS_ERROR_PROBABILITY=${KINESIS_ERROR_PROBABILITY-}
- DOCKER_HOST=unix:///var/run/docker.sock
- LOCALSTACK_API_KEY=${LOCALSTACK_API_KEY-}
- LOCALSTACK_AUTH_TOKEN=${LOCALSTACK_AUTH_TOKEN-}

- MAIN_CONTAINER_NAME=${LS_MAIN_CONTAINER_NAME-localstack}
# - USE_SSL=false
# - DNS_ADDRESS=127.0.0.11
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ services:
- LS_VERSION # starts up localstack with specified version >= 1.x.x.
- LS_MAIN_CONTAINER_NAME # used by localstack
- LOCALSTACK_API_KEY # required if you want to use localstack pro
- LOCALSTACK_AUTH_TOKEN # future LocalStack Auth token support
- LOCALSTACK_HOST_DNS_PORT # forward this port from host to localstack for DNS
- LOCALSTACK_STATIC_IP # set static container ip for LS. Useful for DNS
- PERSIST_BITWARDEN_SESSION # persist unlocked vault creds between container sessions
Expand Down
28 changes: 27 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,31 @@ run the script `run-dev-container.sh` in the root of this repository.

Running with no arguments or `-h` as first arguments will display help.

## Example Project Configuration
This configuration enables shared DNS between LocalStack and the Dev Container.
The DevContainer will use LocalStack's DNS service.

Create a file called `.env-gdc` in the root of your project direct. Put the followign in it:
```shell
export AWS_REGION=us-east-1
export GDC_NAME=lappc
export LS_VERSION=latest
export LS_IMAGE=localstack/localstack-pro # use localstack/localstack if you are using LocalStack Community
export USE_LOCALSTACK=yes
export USE_LOCALSTACK_HOST=yes
export USE_LOCALSTACK_PERSISTENCE=no
export USE_LOCALSTACK_DNS=yes
export LOCALSTACK_HOST_DNS_PORT="" # this makes LocalStack not map port 53 the host
export USE_PRECOMMIT=no
```
If you're using LocalStack Pro, create a file called `.env-gdc-local` and put your LOCALSTACK_API_KEY or LOCALSTACK_AUTH_TOKEN in it.
```shell
# Either Key
export LOCALSTACK_API_KEY="<your real key>"
# or
export LOCALSTACK_AUTH_TOKEN="<your real token>"
```

`run-dev-container.sh [STACK_NAME] [GDC_RUN_MODE | PORT_FWD | GDC_ENTRYPOINT]`
* your current working directory will be mounted in container on `/workspace`
* STACK_NAME if not set via GDC_NAME env var or as first arg will be generated based on current folder. It's used to name the stack in case you want to run more than one.
Expand Down Expand Up @@ -123,8 +148,9 @@ These options control what packages / functionality are built into the container
* USE_LOCALSTACK_PERSISTENCE=no - toggle persistent storage for LS defaults to persistence disabled.
* LOCALSTACK_VOLUME_DIR=$HOST_PROJECT_PATH/ls_volume.
* LOCALSTACK_API_KEY=<not set> # only needed for local stack pro.
* LOCALSTACK_AUTH_TOKEN=<not set> # (future) only needed for local stack pro.
* LS_MAIN_CONTAINER_NAME=localstack_PROJECT_NAME - used by localstack to name main container. Can also be accessed via this name inside containers.
* LS_IMAGE=localstack/localstack - if LOCALSTACK_API_KEY is specified then defaults to localstack/localstack-pro. Can override with custom image location. Still uses LS_VERSION to create final image location.
* LS_IMAGE=localstack/localstack - if LOCALSTACK_API_KEY or LOCALSTACK_AUTH_TOKEN is specified then defaults to localstack/localstack-pro. Can override with custom image location. Still uses LS_VERSION to create final image location.
* LS_VERSION=<not set> - starts a localstack container running specified version.
* USE_LOCALSTACK_HOST=yes - forwards localstack ports to host if LS_VERSION is set.
* USE_LOCALSTACK_SHARED=no - mount gdc shared volume in LS container under /shared.
Expand Down

0 comments on commit 98c9944

Please sign in to comment.