Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: [#188558362] upgrade serverless to v4 #9241

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 45 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}

aadedejifearless marked this conversation as resolved.
Show resolved Hide resolved
- validate-serverless-access-key
aadedejifearless marked this conversation as resolved.
Show resolved Hide resolved
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,7 @@ commands:
- run:
name: Set Cypress Environment Variables
command: |
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 +285,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 +344,9 @@ 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 MYNJ_PROFILE_LINK=https://my.nj.gov/portal/Desktop' >> $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,68 +655,70 @@ 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:
Expand All @@ -699,9 +727,6 @@ jobs:
steps:
- set-prod-env-vars
- deploy
environment:
STAGE: prod
MYNJ_PROFILE_LINK: https://my.nj.gov/portal/Desktop
aadedejifearless marked this conversation as resolved.
Show resolved Hide resolved

integration-tests:
parameters:
Expand Down
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"
}
}
11 changes: 3 additions & 8 deletions api/serverless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ 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 || "default-bucket";
const skipSaveDocumentsToS3 = process.env.SKIP_SAVE_DOCUMENTS_TO_S3 || "";

const awsCryptoKey = process.env.AWS_CRYPTO_KEY || "";
Expand Down Expand Up @@ -89,14 +90,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 +116,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
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/**/*"]
aadedejifearless marked this conversation as resolved.
Show resolved Hide resolved
}
62 changes: 0 additions & 62 deletions api/webpack.config.ts

This file was deleted.

8 changes: 2 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
"remark-rehype": "10.1.0",
"remove-markdown": "0.5.5",
"serverless-http": "3.2.0",
"serverless-offline": "13.9.0",
"simple-oauth2": "5.0.1",
"slick-carousel": "1.8.1",
"swr": "1.3.0",
Expand Down Expand Up @@ -161,7 +160,6 @@
"@types/supertest": "6.0.2",
"@types/testing-library__jest-dom": "5.14.9",
"@types/uuid": "9.0.8",
"@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",
Expand Down Expand Up @@ -211,22 +209,20 @@
"sass": "1.83.0",
"sass-loader": "14.2.1",
"semantic-release": "19.0.5",
"serverless": "3.40.0",
"serverless": "4.4.18",
"serverless-dynamodb": "0.2.56",
"serverless-offline": "14.4.0",
aadedejifearless marked this conversation as resolved.
Show resolved Hide resolved
"serverless-offline-ssm": "6.2.0",
"serverless-prune-plugin": "2.1.0",
"serverless-webpack": "5.15.0",
"storybook": "7.6.20",
"style-loader": "3.3.4",
"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",
"yarn-workspace-sync-deps": "0.3.3"
},
Expand Down
Loading