From d524e23783291f77553224f682581dca24e220c5 Mon Sep 17 00:00:00 2001 From: Pete Stenger Date: Mon, 19 Aug 2024 11:03:49 -0500 Subject: [PATCH 1/2] add setup docs --- .env.sample | 1 + README.md | 31 +++++++++++++++++++++++++++++-- src/routes/events.ts | 2 ++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 .env.sample diff --git a/.env.sample b/.env.sample new file mode 100644 index 00000000..b88216ae --- /dev/null +++ b/.env.sample @@ -0,0 +1 @@ +EVENTS_API_CLIENT_SECRET=XXX \ No newline at end of file diff --git a/README.md b/README.md index d0c86e33..b5a1411f 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,40 @@ ## Run Locally 1. `yarn -D` -2. `make local` +2. `make check_account_dev` - If this fails make sure that AWS is configured. +3. `make local` ## Build for AWS Lambda 1. `make clean` 2. `make build` ## Deploy to AWS env + 1. Get AWS credentials with `aws configure sso` 2. Ensure AWS profile is set to the right account (DEV or PROD). -3. Run `make deploy_dev` or `make deploy_prod`. \ No newline at end of file +3. Run `make deploy_dev` or `make deploy_prod`. + +## Generating JWT token + +Create a `.env` file containing your `CLIENT_SECRET`. + +```bash +node --env-file=.env get_msft_jwt.js +``` + +## Configuring AWS + +``` +aws configure sso +``` + +Go to AWS Access Portal > "acmdev" > Access keys and copy the values for +"AWS start URL" and "AWS Region" + +Add your profile to your `.zshrc` / `.bashrc`. + +```bash +export AWS_PROFILE=ABC-DEV +``` + +and then `source ~/.zshrc` / `source ~/.bashrc`. diff --git a/src/routes/events.ts b/src/routes/events.ts index 2225b438..0eae9d03 100644 --- a/src/routes/events.ts +++ b/src/routes/events.ts @@ -158,6 +158,8 @@ const eventsPlugin: FastifyPluginAsync = async (fastify, _options) => { } catch (e: unknown) { if (e instanceof Error) { request.log.error("Failed to get from DynamoDB: " + e.toString()); + } else { + request.log.error(`Failed to get from DynamoDB. ${e}`); } throw new DatabaseFetchError({ message: "Failed to get events from Dynamo table.", From 05cb360cf0a28e4d6a913f017a939458a38c69ec Mon Sep 17 00:00:00 2001 From: Dev Singh Date: Thu, 22 Aug 2024 13:37:20 -0500 Subject: [PATCH 2/2] Update README.md --- README.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/README.md b/README.md index b5a1411f..9a421851 100644 --- a/README.md +++ b/README.md @@ -29,13 +29,8 @@ node --env-file=.env get_msft_jwt.js aws configure sso ``` -Go to AWS Access Portal > "acmdev" > Access keys and copy the values for -"AWS start URL" and "AWS Region" - -Add your profile to your `.zshrc` / `.bashrc`. +Log in with SSO. Then, export the `AWS_PROFILE` that the above command outputted. ```bash export AWS_PROFILE=ABC-DEV ``` - -and then `source ~/.zshrc` / `source ~/.bashrc`.