Skip to content

Commit

Permalink
chore: [#188558362] upgrade serverless to v4
Browse files Browse the repository at this point in the history
  • Loading branch information
aadedejifearless committed Jan 10, 2025
1 parent f0c2f6e commit 3f588c2
Show file tree
Hide file tree
Showing 9 changed files with 552 additions and 2,634 deletions.
67 changes: 47 additions & 20 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,18 @@ commands:
- run:
name: Install yarn packages
command: yarn install

validate-serverless-access-key:
steps:
- run:
name: Validate Serverless Access Key
command: |
echo "Validating SERVERLESS_ACCESS_KEY"
if [ -z "${SERVERLESS_ACCESS_KEY}" ]; then
echo "Error: SERVERLESS_ACCESS_KEY is not set"
exit 1
else
echo "SERVERLESS_ACCESS_KEY is set"
fi
install-dynamodb:
steps:
- run:
Expand All @@ -29,10 +40,7 @@ commands:
configure:
steps:
- bootstrap-code
- run:
name: Configure Serverless
command: yarn workspace @businessnjgovnavigator/api serverless config credentials --provider aws --key ${AWS_ACCESS_KEY_ID} --secret ${AWS_SECRET_ACCESS_KEY}

- validate-serverless-access-key
configure-smoke-test:
steps:
- run: sudo apt update
Expand Down Expand Up @@ -162,11 +170,19 @@ commands:
name: Deploy Serverless
command: yarn workspace @businessnjgovnavigator/api serverless deploy --verbose --stage ${STAGE} --region us-east-1

set-shared-stage-env-vars:
steps:
- run:
name: Set Shared Stage Environment Variables
command: |
echo 'export MYNJ_PROFILE_LINK=https://myt1.nj.gov/portal/Desktop' >> $BASH_ENV
set-dev-env-vars:
steps:
- run:
name: Set Development Environment Variables
command: |
echo 'export BIZNJ_SLS_DEPLOYMENT_BUCKET_NAME=$BIZNJ_SLS_DEPLOYMENT_BUCKET_NAME_DEV' >> $BASH_ENV
echo 'export SERVERLESS_ACCESS_KEY=$SERVERLESS_ACCESS_KEY_DEV' >> $BASH_ENV
echo 'export AB_TESTING_EXPERIENCE_B_PERCENTAGE=$AB_TESTING_EXPERIENCE_B_PERCENTAGE_DEV' >> $BASH_ENV
echo 'export ADMIN_PASSWORD=$ADMIN_PASSWORD' >> $BASH_ENV
echo 'export AIRTABLE_USERS_TABLE=$AIRTABLE_USERS_TABLE_DEV' >> $BASH_ENV
Expand Down Expand Up @@ -226,6 +242,8 @@ commands:
- run:
name: Set Cypress Environment Variables
command: |
echo 'export BIZNJ_SLS_DEPLOYMENT_BUCKET_NAME=$BIZNJ_SLS_DEPLOYMENT_BUCKET_NAME_DEV' >> $BASH_ENV
echo 'export SERVERLESS_ACCESS_KEY=$SERVERLESS_ACCESS_KEY_DEV' >> $BASH_ENV
echo 'export API_BASE_URL=http://localhost:5002/local' >> $BASH_ENV
echo 'export USE_FAKE_SELF_REG=true' >> $BASH_ENV
echo 'export REDIRECT_URL=http://localhost:3000/' >> $BASH_ENV
Expand Down Expand Up @@ -268,6 +286,8 @@ commands:
- run:
name: Set Staging Environment Variables
command: |
echo 'export BIZNJ_SLS_DEPLOYMENT_BUCKET_NAME=$BIZNJ_SLS_DEPLOYMENT_BUCKET_NAME_STAGING' >> $BASH_ENV
echo 'export SERVERLESS_ACCESS_KEY=$SERVERLESS_ACCESS_KEY_STAGING' >> $BASH_ENV
echo 'export API_BASE_URL=$API_BASE_URL_AWS_STAGING' >> $BASH_ENV
echo 'export AUTH_DOMAIN=$COGNITO_AUTH_DOMAIN_STAGING' >> $BASH_ENV
echo 'export FEATURE_EXPORT_PDF=$FEATURE_EXPORT_PDF_STAGING' >> $BASH_ENV
Expand Down Expand Up @@ -325,6 +345,8 @@ commands:
- run:
name: Set Production Environment Variables
command: |
echo 'export BIZNJ_SLS_DEPLOYMENT_BUCKET_NAME=$BIZNJ_SLS_DEPLOYMENT_BUCKET_NAME_PROD' >> $BASH_ENV
echo 'export SERVERLESS_ACCESS_KEY=$SERVERLESS_ACCESS_KEY_PROD' >> $BASH_ENV
echo 'export API_BASE_URL=$API_BASE_URL_AWS_PROD' >> $BASH_ENV
echo 'export AUTH_DOMAIN=$COGNITO_AUTH_DOMAIN_PROD' >> $BASH_ENV
echo 'export FEATURE_EXPORT_PDF=$FEATURE_EXPORT_PDF_PROD' >> $BASH_ENV
Expand Down Expand Up @@ -381,6 +403,8 @@ commands:
- run:
name: Set Content Environment Variables
command: |
echo 'export BIZNJ_SLS_DEPLOYMENT_BUCKET_NAME=$BIZNJ_SLS_DEPLOYMENT_BUCKET_NAME_CONTENT' >> $BASH_ENV
echo 'export SERVERLESS_ACCESS_KEY=$SERVERLESS_ACCESS_KEY_CONTENT' >> $BASH_ENV
echo 'export API_BASE_URL=$API_BASE_URL_AWS_CONTENT' >> $BASH_ENV
echo 'export AUTH_DOMAIN=$COGNITO_AUTH_DOMAIN_CONTENT' >> $BASH_ENV
echo 'export MYNJ_ROLE_NAME=$MYNJ_ROLE_NAME_CONTENT' >> $BASH_ENV
Expand All @@ -399,6 +423,8 @@ commands:
- run:
name: Set Accessibility Testing Environment Variables
command: |
echo 'export BIZNJ_SLS_DEPLOYMENT_BUCKET_NAME=$BIZNJ_SLS_DEPLOYMENT_BUCKET_NAME_TESTING' >> $BASH_ENV
echo 'export SERVERLESS_ACCESS_KEY=$SERVERLESS_ACCESS_KEY_TESTING' >> $BASH_ENV
echo 'export API_BASE_URL=$API_BASE_URL_AWS_TESTING' >> $BASH_ENV
echo 'export AUTH_DOMAIN=$COGNITO_AUTH_DOMAIN_TESTING' >> $BASH_ENV
echo 'export MYNJ_ROLE_NAME=$MYNJ_ROLE_NAME_TESTING' >> $BASH_ENV
Expand Down Expand Up @@ -629,79 +655,79 @@ jobs:
- generate-release-notes

deploy-content:
environment:
STAGE: content
docker:
- image: $AWS_ACCOUNT_ID_DEV.dkr.ecr.$AWS_REGION.amazonaws.com/navigator_builder:bfs_navigator_builder-20_18_1
aws_auth:
aws_access_key_id: $AWS_ACCESS_KEY_ID_DEV
aws_secret_access_key: $AWS_SECRET_ACCESS_KEY_DEV
steps:
- set-shared-stage-env-vars
- set-dev-env-vars
- set-content-env-vars
- attach_workspace:
at: .
- deploy-content-env
environment:
STAGE: content
MYNJ_PROFILE_LINK: https://myt1.nj.gov/portal/Desktop

deploy-accessibility-testing:
environment:
STAGE: testing
docker:
- image: $AWS_ACCOUNT_ID_DEV.dkr.ecr.$AWS_REGION.amazonaws.com/navigator_builder:bfs_navigator_builder-20_18_1
aws_auth:
aws_access_key_id: $AWS_ACCESS_KEY_ID_DEV
aws_secret_access_key: $AWS_SECRET_ACCESS_KEY_DEV
steps:
- set-shared-stage-env-vars
- set-dev-env-vars
- set-accessibility-testing-env-vars
- attach_workspace:
at: .
- deploy-accessibility-testing-env
environment:
STAGE: testing
MYNJ_PROFILE_LINK: https://myt1.nj.gov/portal/Desktop

deploy-dev:
environment:
STAGE: dev
docker:
- image: $AWS_ACCOUNT_ID_DEV.dkr.ecr.$AWS_REGION.amazonaws.com/navigator_builder:bfs_navigator_builder-20_18_1
aws_auth:
aws_access_key_id: $AWS_ACCESS_KEY_ID_DEV
aws_secret_access_key: $AWS_SECRET_ACCESS_KEY_DEV
steps:
- set-shared-stage-env-vars
- set-dev-env-vars
- attach_workspace:
at: .
- deploy
- deploy-storybook
- store-deploy-cache
environment:
STAGE: dev
MYNJ_PROFILE_LINK: https://myt1.nj.gov/portal/Desktop

deploy-staging:
environment:
STAGE: staging
docker:
- image: $AWS_ACCOUNT_ID_DEV.dkr.ecr.$AWS_REGION.amazonaws.com/navigator_builder:bfs_navigator_builder-20_18_1
aws_auth:
aws_access_key_id: $AWS_ACCESS_KEY_ID_DEV
aws_secret_access_key: $AWS_SECRET_ACCESS_KEY_DEV
steps:
- set-shared-stage-env-vars
- set-staging-env-vars
- deploy
environment:
STAGE: staging
MYNJ_PROFILE_LINK: https://myt1.nj.gov/portal/Desktop

deploy-production:
environment:
STAGE: prod
docker:
- image: $AWS_ACCOUNT_ID_DEV.dkr.ecr.$AWS_REGION.amazonaws.com/navigator_builder:bfs_navigator_builder-20_18_1
aws_auth:
aws_access_key_id: $AWS_ACCESS_KEY_ID_DEV
aws_secret_access_key: $AWS_SECRET_ACCESS_KEY_DEV
steps:
- set-shared-stage-env-vars
- set-prod-env-vars
- deploy
environment:
STAGE: prod
MYNJ_PROFILE_LINK: https://my.nj.gov/portal/Desktop

integration-tests:
parameters:
Expand Down Expand Up @@ -730,6 +756,7 @@ jobs:
browser: << parameters.browser >>
environment:
CYPRESS_API_BASE_URL: http://localhost:5002/local
SERVERLESS_ACCESS_KEY: ${SERVERLESS_ACCESS_KEY_DEV}

smoke-tests:
parameters:
Expand Down
2 changes: 2 additions & 0 deletions api/.env-template
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ DYNAMICS_ELEVATOR_SAFETY_CLIENT_ID=
DYNAMICS_ELEVATOR_SAFETY_SECRET=
FEATURE_DYNAMICS_PUBLIC_MOVERS=
USE_WIREMOCK_FOR_FORMATION_AND_BUSINESS_SEARCH=
SERVERLESS_ACCESS_KEY=
BIZNJ_SLS_DEPLOYMENT_BUCKET_NAME=
12 changes: 3 additions & 9 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"private": true,
"scripts": {
"build": "sls package",
"clean": "rimraf .serverless .webpack",
"clean": "rimraf .serverless",
"deploy": "sls deploy",
"dev": "yarn wiremock --root-dir ./wiremock --port 9000 & yarn start",
"dependency-check": "yarn depcruise --config .dependency-cruiser.js src",
Expand Down Expand Up @@ -73,11 +73,9 @@
"@types/node": "20.17.10",
"@types/simple-oauth2": "5.0.7",
"@types/supertest": "6.0.2",
"@types/webpack-node-externals": "3.0.4",
"@types/xml2js": "0.4.14",
"@typescript-eslint/eslint-plugin": "7.18.0",
"@typescript-eslint/parser": "7.18.0",
"copy-webpack-plugin": "12.0.2",
"cross-env": "7.0.3",
"dependency-cruiser": "16.8.0",
"eslint": "8.57.1",
Expand All @@ -91,21 +89,17 @@
"prettier": "2.8.8",
"prettier-plugin-organize-imports": "3.2.4",
"rimraf": "5.0.10",
"serverless": "3.40.0",
"serverless": "4.4.18",
"serverless-dynamodb": "0.2.56",
"serverless-offline": "13.9.0",
"serverless-offline": "14.4.0",
"serverless-offline-ssm": "6.2.0",
"serverless-prune-plugin": "2.1.0",
"serverless-webpack": "5.15.0",
"supertest": "6.3.4",
"ts-jest": "29.2.5",
"ts-loader": "9.5.1",
"ts-node": "10.9.2",
"tsconfig-paths": "4.2.0",
"tsconfig-paths-webpack-plugin": "4.2.0",
"typescript": "5.7.2",
"webpack": "5.97.1",
"webpack-node-externals": "3.0.0",
"wiremock": "3.9.2"
}
}
13 changes: 5 additions & 8 deletions api/serverless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@ const healthCheckLambda = `businessnjgov-api-${stage}-healthCheck`;
const healthCheckEventRule = `health_check_lambda_event_rule`;

const documentS3Bucket = `nj-bfs-user-documents-${stage}`;
const serverlessDeploymentS3Bucket = process.env.BIZNJ_SLS_DEPLOYMENT_BUCKET_NAME || "";
const skipSaveDocumentsToS3 = process.env.SKIP_SAVE_DOCUMENTS_TO_S3 || "";

const awsCryptoKey = process.env.AWS_CRYPTO_KEY || "";
const awsCryptoContextStage = process.env.AWS_CRYPTO_CONTEXT_STAGE || "";
const awsCryptoContextPurpose = process.env.AWS_CRYPTO_CONTEXT_PURPOSE || "";
const awsCryptoContextOrigin = process.env.AWS_CRYPTO_CONTEXT_ORIGIN || "";
const serverlessAccessKey = process.env.SERVERLESS_ACCESS_KEY || "";

const dynamicsLicenseStatusTenantId = process.env.DYNAMICS_LICENSE_STATUS_TENANT_ID || "";
const dynamicsLicenseStatusURL = process.env.DYNAMICS_LICENSE_STATUS_URL || "";
Expand Down Expand Up @@ -89,14 +91,8 @@ const useWireMockForFormationAndBusinessSearch =
const serverlessConfiguration: AWS = {
useDotenv: true,
service: "businessnjgov-api",
frameworkVersion: "3",
frameworkVersion: "4",
custom: {
webpack: {
webpackConfig: "./webpack.config.ts",
includeModules: {
nodeModulesRelativeDir: "../",
},
},
"serverless-dynamodb": {
port: dynamoOfflinePort,
start: {
Expand All @@ -121,14 +117,14 @@ const serverlessConfiguration: AWS = {
},
},
plugins: [
"serverless-webpack",
...(isDocker ? [] : ["serverless-dynamodb"]),
"serverless-offline-ssm",
"serverless-offline",
"serverless-prune-plugin",
],
provider: {
name: "aws",
deploymentBucket: serverlessDeploymentS3Bucket,
runtime: "nodejs20.x",
stage: stage,
region: region,
Expand Down Expand Up @@ -245,6 +241,7 @@ const serverlessConfiguration: AWS = {
USERS_TABLE: usersTable,
BUSINESSES_TABLE: businessesTable,
USE_WIREMOCK_FOR_FORMATION_AND_BUSINESS_SEARCH: useWireMockForFormationAndBusinessSearch,
SERVERLESS_ACCESS_KEY: serverlessAccessKey,
} as AwsLambdaEnvironment,
logRetentionInDays: 180,
},
Expand Down
8 changes: 1 addition & 7 deletions api/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,5 @@
"skipLibCheck": true
},
"include": ["src/**/*.ts", "test/**/*.ts", "serverless.ts"],
"exclude": ["node_modules/**/*", ".serverless/**/*", ".webpack/**/*", "_warmup/**/*", ".vscode/**/*"],
"ts-node": {
"require": ["tsconfig-paths/register"],
"moduleTypes": {
"jest.config.ts": "cjs"
}
}
"exclude": ["node_modules/**/*", ".serverless/**/*", "_warmup/**/*", ".vscode/**/*"]
}
62 changes: 0 additions & 62 deletions api/webpack.config.ts

This file was deleted.

Loading

0 comments on commit 3f588c2

Please sign in to comment.