From b28c63390802eeeaa92653a87842bde8010dbbb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20JANIN?= Date: Thu, 8 Feb 2024 12:27:54 -0500 Subject: [PATCH] chore: create env file that gets automatically loaded when we start the infra in Localstack (#592) --- .env.example | 2 ++ .gitignore | 2 +- README.md | 6 ++++++ localstack_services.sh | 21 +++++++++++++++------ 4 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 000000000..2b099a4dc --- /dev/null +++ b/.env.example @@ -0,0 +1,2 @@ +APP_ENV="local" +NOTIFY_API_KEY="" \ No newline at end of file diff --git a/.gitignore b/.gitignore index 7b6a51b74..ab880e528 100644 --- a/.gitignore +++ b/.gitignore @@ -52,4 +52,4 @@ tf.plan .devcontainer/data # Local environment variables -.env* \ No newline at end of file +.env \ No newline at end of file diff --git a/README.md b/README.md index e7c595496..f0215aa93 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,12 @@ RELIABILITY_FILE_STORAGE=forms-local-reliability-file-storage LOCAL_AWS_ENDPOINT=http://127.0.0.1:4566 ``` +#### Set your environment variables (optional) + +Copy the `.env.example` file and rename it to `.env`. Some of the variables require values that can be found in the 1Password shared secrets note. + +#### Launch the infrastructure and the application + Everytime you want to run localstack and lambdas locally 1. In one terminal run `docker-compose up` diff --git a/localstack_services.sh b/localstack_services.sh index 437dca185..e76c51982 100755 --- a/localstack_services.sh +++ b/localstack_services.sh @@ -1,14 +1,23 @@ #!/bin/bash -export APP_ENV="local" - -# Exit on any error -set -e - # Text colors color='\033[1;95m' reset='\033[0m' # No Color +if test -f .env +then + set -o allexport + source .env + set +o allexport + printf "${color}=> Environment variables loaded from .env${reset}\n" +else + # In case developers have not set up their .env file (can be removed in the future) + export APP_ENV="local" +fi + +# Exit on any error +set -e + # Set proper terraform and terragrunt versions tgswitch 0.54.8 @@ -65,4 +74,4 @@ printf "${color}...Creating lambdas${reset}\n" cd $basedir/env/cloud/lambdas terragrunt apply --terragrunt-non-interactive -auto-approve --terragrunt-log-level warn -printf "${color}All infratructure initialized: Ready for requests${reset}\n" +printf "${color}All infratructure initialized: Ready for requests${reset}\n" \ No newline at end of file