Skip to content

Commit

Permalink
feat: adding environments for better validator
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonNotJson committed Dec 13, 2023
1 parent 4768bce commit 2fd16c7
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ env:
DEV_VITE_GA_ID: ${{secrets.DEV_VITE_GA_ID}}
UID: ${{secrets.UID}}
OPENAI_API_KEY: ${{secrets.OPENAI_API_KEY}}
TEST_USER: ${{secrets.TEST_USER}}
STAGE: dev

jobs:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ env:
DEV_VITE_GA_ID: ${{secrets.DEV_VITE_GA_ID}}
UID: ${{secrets.UID}}
OPENAI_API_KEY: ${{secrets.OPENAI_API_KEY}}
TEST_USER: ${{secrets.TEST_USER}}
STAGE: dev

jobs:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ env:
MASTER_VITE_GA_ID: ${{secrets.VITE_GA_ID}}
DEV_VITE_GA_ID: ${{secrets.DEV_VITE_GA_ID}}
OPENAI_API_KEY: ${{secrets.OPENAI_API_KEY}}
TEST_USER: ${{secrets.TEST_USER}}
STAGE: dev

jobs:
Expand Down
2 changes: 2 additions & 0 deletions lib/configs/lambda/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ export const SLACK_WEBHOOK_URL = process.env.SLACK_WEBHOOK_URL!;
export const AWS_USER_POOL_ID = process.env.AWS_USER_POOL_ID!;

export const OPENAI_API_KEY = process.env.OPENAI_API_KEY!;

export const TEST_USER = process.env.TEST_USER!;
3 changes: 2 additions & 1 deletion lib/constructs/common/lambda-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
SLACK_WEBHOOK_URL,
AWS_USER_POOL_ID,
OPENAI_API_KEY,
TEST_USER,
} from '../../configs/lambda/environment';

interface FunctionsProps {
Expand Down Expand Up @@ -227,7 +228,7 @@ export class PreSignupWasedaMailValidator extends Construct {
memorySize: 128,
runtime: lambda.Runtime.PYTHON_3_9,
timeout: Duration.seconds(3),
});
}).addEnvironment('TEST_USER', TEST_USER);
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/lambda/signup-validator/index.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from utils import test_user


def handler(event, context):
email = event["request"]["userAttributes"]["email"]
domain = email.split('@')[1]

# Check for the specific test email address
if email == "[email protected]":
if email == test_user:
event["response"]["autoConfirmUser"] = True
return event

Expand Down
3 changes: 3 additions & 0 deletions src/lambda/signup-validator/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import os

test_user = os.getenv('TEST_USER')

0 comments on commit 2fd16c7

Please sign in to comment.