Skip to content
Ryan Lacy edited this page Apr 17, 2024 · 2 revisions

Vault Developer Toolbox

Architecture

Toolbox Architecture

  • 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.

Development

AWS Infrastructure

The Vault Developer Toolbox backend runs on AWS, which Veeva hosts for the public Chrome extension. Instructions for replicating the AWS infrastructure are below.

Create IAM Role

  1. In the AWS IAM console, click Roles in the menu on the left hand side of the page
  2. Click Create role
  3. Select Lambda as the use case, then click Next
  4. Add the following AWS managed permission policies:
    • AWSLambdaBasicExecutionRole
    • AWSLambdaRole
  5. Click Next, enter a role name (e.g. vault-developer-toolbox-role), then click Create role

Create Lambda Function

  1. In the AWS Lambda console, click Create function
  2. 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.
  3. Click Create function
  4. In the Runtime settings section, set the Handler to com.veeva.vault.handlers.LambdaHandler::handleRequest
  5. 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)
  6. On the Configuration tab in the General configuration section, set the Timeout to 15 minutes.
  7. On the Configuration tab in the Environment variables section, set the following:
    • Key: LOG_LEVEL, Value: INFO

Create API Gateway

  1. In the AWS API Gateway console, click Create API
  2. Select the HTTP API option and click Build
  3. Click Add integration, choose Lambda from the drop-down, then choose the Lambda function you created in the steps above.
  4. Enter an API name (e.g. vault-developer-toolbox-api-gateway), then click Review and create, then Create
  5. 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: *
  6. 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.

Frontend Development

The frontend is a React application packaged inside a Chrome extension. To extend or modify the frontend code, developers can:

  1. Clone the repository
  2. Navigate to the frontend folder in a terminal
  3. Run npm install
  4. In the frontend/.env file, change the value of the DEVELOPER_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})
  5. Open the frontend folder in your preferred code editor and modify the code as desired
  6. Run npm run build, which will compile and package the updated extension into the frontend/dist folder
  7. Load the updated dist folder locally into Chrome to test your changes (see: Load an unpacked extension)

Backend Development

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:

  1. Clone the repository
  2. Download and install Maven, if not already installed
  3. Load the backend folder in your preferred code editor
  4. Modify the code as desired
  5. Run the maven package goal, which will compile the updates to the vault-developer-toolbox-{current_version}.jar file within the backend/target folder
  6. In AWS, upload the new JAR as the source code for your Lambda function