From 98c99442b16e1bec7c2b2953d62c28df74d51772 Mon Sep 17 00:00:00 2001 From: Chad Beaulac Date: Thu, 12 Oct 2023 13:47:40 -0700 Subject: [PATCH] Added support for LOCALSTACK_AUTH_TOKEN Added example for shared DNS on docker network. --- .env-gdc | 2 +- dc-ls-host.yml | 1 + dc-ls.yml | 2 ++ docker-compose.yml | 1 + readme.md | 28 +++++++++++++++++++++++++++- 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/.env-gdc b/.env-gdc index 01a6081..01371c9 100644 --- a/.env-gdc +++ b/.env-gdc @@ -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. diff --git a/dc-ls-host.yml b/dc-ls-host.yml index 1974823..0da118d 100644 --- a/dc-ls-host.yml +++ b/dc-ls-host.yml @@ -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 diff --git a/dc-ls.yml b/dc-ls.yml index cabd888..aafb475 100644 --- a/dc-ls.yml +++ b/dc-ls.yml @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index 005acd7..269b663 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 diff --git a/readme.md b/readme.md index 2a9a674..426dfff 100644 --- a/readme.md +++ b/readme.md @@ -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="" +# or +export LOCALSTACK_AUTH_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. @@ -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= # only needed for local stack pro. +* LOCALSTACK_AUTH_TOKEN= # (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= - 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.