Skip to content

AWS Lambda function to transfer documents from S3 using the Document Transfer Service.

License

Notifications You must be signed in to change notification settings

codeforamerica/document-transfer-lambda

Repository files navigation

Document Transfer Lambda

This Lambda function is used to transfer documents uploaded to S3 to another location, through the Document Transfer Service. It uses EventBridge to trigger the Lambda function when a new document is uploaded to the S3 bucket.

Configuration

The lambda function accepts the following environment variables:

Name Description Default Required
CREDENTIALS_ARN The ARN of the secret containing service credentials. n/a yes
TRANSFER_URL The URL of the Document Transfer Service. yes
LOG_LEVEL The log level for the lambda function. "info" no
ONEDRIVE_FOLDER Name of the folder in OneDrive that documents will be transferred to. nil no

The secret containing the service credentials should be a JSON object with the following keys:

{
  "id": "cosumer-id",
  "token": "auth-token"
}

Deployment

The lambda function is managed using AWS' Serverless Application Model. Before you begin, you will need to install the SAM CLI. Make sure you are logged into your AWS account and have the appropriate AWS_PROFILE set.

To ease configuration, a sample.env file is provided with necessary environment variables. Copy this is .env and fill in the necessary values. The .env file is ignored by git, so it will not be committed to the repository. Unless you have a shell extension that automatically loads the .env file, you will need to source it by running source .env.

To deploy to staging, run the following:

sam deploy --config-file samconfig.yaml --config-env staging

For production:

sam deploy --config-file samconfig.yaml --config-env prood

Configuration

Deployment configuration is managed in two places:

  1. template.yaml: This is the SAM template that defines the lambda function, permissions, event trigger, and any other resources needed to execute the function.

  2. samconfig.yaml: This is the SAM CLI configuration file that contains the environment-specific configuration options for the deployment. This includes the bucket name(s), service URL, networking configuration, etc.

    Note: We use the YAML format for the configuration rather than the default TOML for consistency with our other configuration files.

About

AWS Lambda function to transfer documents from S3 using the Document Transfer Service.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages