-
Notifications
You must be signed in to change notification settings - Fork 2
Home
Ryan Lacy edited this page Apr 17, 2024
·
2 revisions
- The Chrome extension consists of a React application built using Webpack.
- The AWS Lambda backend consists of a Java program containing our open-source Vault Data Tools project.
- Long-running jobs (e.g. Vault Data Tools "Count" or "Delete" actions) are run asynchronously via the AWS Lambda function. All other Vault REST API calls are made directly from the browser.
The Vault Developer Toolbox backend runs on AWS, which Veeva hosts for the public Chrome extension. Instructions for replicating the AWS infrastructure are below.
- In the AWS IAM console, click Roles in the menu on the left hand side of the page
- Click Create role
- Select Lambda as the use case, then click Next
- Add the following AWS managed permission policies:
- AWSLambdaBasicExecutionRole
- AWSLambdaRole
- Click Next, enter a role name (e.g. vault-developer-toolbox-role), then click Create role
- In the AWS Lambda console, click Create function
- Set the following:
- Enter a function name (e.g. vault-developer-toolbox-lambda)
- For Runtime, enter Java 11
- Under the Change default execution role dropdown, select Use an existing role and select the IAM role you created above.
- Click Create function
- In the Runtime settings section, set the Handler to
com.veeva.vault.handlers.LambdaHandler::handleRequest
- In the Code source section, click Upload from .zip or .jar file, then select the current JAR in the
backend folder of this repo (e.g.
backend/vault-developer-toolbox-23.3.0.jar
) - On the Configuration tab in the General configuration section, set the Timeout to 15 minutes.
- On the Configuration tab in the Environment variables section, set the following:
-
Key:
LOG_LEVEL
, Value:INFO
-
Key:
- In the AWS API Gateway console, click Create API
- Select the HTTP API option and click Build
- Click Add integration, choose Lambda from the drop-down, then choose the Lambda function you created in the steps above.
- Enter an API name (e.g. vault-developer-toolbox-api-gateway), then click Review and create, then Create
- Within the API Gateway, navigate to the Develop section, click the CORS sub-section, then set the following:
-
Access-Control-Allow-Origin:
*
-
Access-Control-Allow-Headers:
accept
,authorization
,content-type
,access-control-allow-origin
-
Access-Control-Allow-Methods:
*
-
Access-Control-Allow-Origin:
- Within AWS, navigate back to the Lambda function you created above, go to the Triggers section of the
Configuration tab, and record the API endpoint value for the API Gateway you just created (e.g.
https://{API_ID}.execute-api.{AWS_Region}.amazonaws.com/{ROUTE}
). This is needed for the Frontend Development section below.
The frontend is a React application packaged inside a Chrome extension. To extend or modify the frontend code, developers can:
- Clone the repository
- Navigate to the
frontend
folder in a terminal - Run
npm install
- In the
frontend/.env
file, change the value of theDEVELOPER_TOOLBOX_LAMBDA_URL
variable to the API Gateway endpoint you created in the above infrastructure steps (e.g.https://{API_ID}.execute-api.{AWS_Region}.amazonaws.com/{ROUTE}
) - Open the frontend folder in your preferred code editor and modify the code as desired
- Run
npm run build
, which will compile and package the updated extension into thefrontend/dist
folder - Load the updated
dist
folder locally into Chrome to test your changes (see: Load an unpacked extension)
To self-host the current backend without making any code changes, developers can simply upload the public repository's JAR as the code for the AWS Lambda function created in the Infrastructure section above (step #5 in "Create Lambda Function").
To extend or modify the backend code, developers can:
- Clone the repository
- Download and install Maven, if not already installed
- Load the
backend
folder in your preferred code editor - Modify the code as desired
- Run the
maven package
goal, which will compile the updates to thevault-developer-toolbox-{current_version}.jar
file within thebackend/target
folder - In AWS, upload the new JAR as the source code for your Lambda function