From 445e3a604ea6591bc0465b6d51311ca7e74633fe Mon Sep 17 00:00:00 2001 From: Bob Hemphill Date: Tue, 15 Oct 2024 17:04:59 -0600 Subject: [PATCH] feat: prd / test / dev serverless config --- .../functions/config/serverless-env.dev.yml | 4 +++ .../functions/config/serverless-env.prd.yml | 4 +++ .../functions/config/serverless-env.test.yml | 4 +++ apps/jira/functions/package.json | 2 +- apps/jira/functions/serverless.yml | 26 +++++++------------ 5 files changed, 23 insertions(+), 17 deletions(-) create mode 100644 apps/jira/functions/config/serverless-env.dev.yml create mode 100644 apps/jira/functions/config/serverless-env.prd.yml create mode 100644 apps/jira/functions/config/serverless-env.test.yml diff --git a/apps/jira/functions/config/serverless-env.dev.yml b/apps/jira/functions/config/serverless-env.dev.yml new file mode 100644 index 0000000000..429e16ec16 --- /dev/null +++ b/apps/jira/functions/config/serverless-env.dev.yml @@ -0,0 +1,4 @@ +frontendUrl: https://app.jira-test.ctfapps.net +oauthRedirectUri: https://api.jira-test.ctfapps.net/auth +baseUrl: https://api.jira-test.ctfapps.net +domainName: api.jira-test.ctfapps.net \ No newline at end of file diff --git a/apps/jira/functions/config/serverless-env.prd.yml b/apps/jira/functions/config/serverless-env.prd.yml new file mode 100644 index 0000000000..6a4f15e66f --- /dev/null +++ b/apps/jira/functions/config/serverless-env.prd.yml @@ -0,0 +1,4 @@ +frontendUrl: https://app.jira.ctfapps.net +oauthRedirectUri: https://api.jira.ctfapps.net/auth +baseUrl: https://api.jira.ctfapps.net +domainName: api.jira.ctfapps.net \ No newline at end of file diff --git a/apps/jira/functions/config/serverless-env.test.yml b/apps/jira/functions/config/serverless-env.test.yml new file mode 100644 index 0000000000..429e16ec16 --- /dev/null +++ b/apps/jira/functions/config/serverless-env.test.yml @@ -0,0 +1,4 @@ +frontendUrl: https://app.jira-test.ctfapps.net +oauthRedirectUri: https://api.jira-test.ctfapps.net/auth +baseUrl: https://api.jira-test.ctfapps.net +domainName: api.jira-test.ctfapps.net \ No newline at end of file diff --git a/apps/jira/functions/package.json b/apps/jira/functions/package.json index f6d8ea5ecb..f566bb52c3 100644 --- a/apps/jira/functions/package.json +++ b/apps/jira/functions/package.json @@ -10,7 +10,7 @@ "test": "ts-mocha '**/*.spec.ts'", "test:ci": "npm run test", "deploy": "sls deploy --stage $STAGE", - "deploy:test": "npm run deploy", + "deploy:test": "NODE_ENV=test sls deploy --stage test", "start": "npm run build && serverless offline --httpPort 3000" }, "dependencies": { diff --git a/apps/jira/functions/serverless.yml b/apps/jira/functions/serverless.yml index d2864bcd5f..098512e12f 100644 --- a/apps/jira/functions/serverless.yml +++ b/apps/jira/functions/serverless.yml @@ -8,18 +8,12 @@ plugins: custom: myStage: ${opt:stage, self:provider.stage} myEnvironment: - FRONTEND_URL: - prd: 'https://app.jira.ctfapps.net' - test: 'http://localhost:1234' - OAUTH_REDIRECT_URI: - prd: 'https://api.jira.ctfapps.net/auth' - test: '${env:NGROK_URL}/dev/auth' - BASE_URL: - prd: 'https://api.jira.ctfapps.net' - test: '${env:NGROK_URL}/dev' + FRONTEND_URL: ${file(./config/serverless-env.${self:custom.myStage}.yml):frontendUrl} + OAUTH_REDIRECT_URI: ${file(./config/serverless-env.${self:custom.myStage}.yml):oauthRedirectUri} + BASE_URL: ${file(./config/serverless-env.${self:custom.myStage}.yml):baseUrl} customDomain: - domainName: api.jira.ctfapps.net - stage: prd + domainName: ${file(./config/serverless-env.${self:custom.myStage}.yml):domainName} + stage: ${self:custom.myStage} createRoute53Record: true endpointType: 'edge' securityPolicy: tls_1_2 @@ -27,7 +21,7 @@ custom: provider: name: aws runtime: nodejs16.x - stage: ${opt:stage, 'test'} + stage: ${opt:stage, 'dev'} region: 'us-east-1' deploymentBucket: name: cf-apps-serverless-deployment @@ -46,9 +40,9 @@ functions: description: OAuth backend for Atlassian role: arn:aws:iam::${env:AWS_ACCOUNT_ID}:role/atlassian_oauth_lambda environment: - OAUTH_CREDENTIALS_SECRET_ID: apps/jira/${opt:stage, 'test'}/oauth-credentials - OAUTH_REDIRECT_URI: ${self:custom.myEnvironment.OAUTH_REDIRECT_URI.${self:custom.myStage}} - FRONTEND_URL: ${self:custom.myEnvironment.FRONTEND_URL.${self:custom.myStage}} + OAUTH_CREDENTIALS_SECRET_ID: apps/jira/${self:custom.myStage}/oauth-credentials + OAUTH_REDIRECT_URI: ${self:custom.myEnvironment.OAUTH_REDIRECT_URI} + FRONTEND_URL: ${self:custom.myEnvironment.FRONTEND_URL} OAUTH_TOKEN_EXCHANGE_ENDPOINT: https://auth.atlassian.com/oauth/token events: - http: @@ -61,7 +55,7 @@ functions: description: connect.json for JIRA role: arn:aws:iam::${env:AWS_ACCOUNT_ID}:role/jira_connect_lambda environment: - BASE_URL: ${self:custom.myEnvironment.BASE_URL.${self:custom.myStage}} + BASE_URL: ${self:custom.myEnvironment.BASE_URL} events: - http: path: connect.json