Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

bucket-request

  • Lambda trigger: S3 event (fires when a user uploads a file to the request bucket)
  • Dependencies: None

Overview

This Lambda function creates S3 buckets with prefab configuration based on a list of bucket names provided in a plain text file.

Example buckets.txt

manuscripts
newspapers
rare-books

The workflow is:

  1. A text file containing bucket names is uploaded to the S3 bucket named ${stack}-request
  2. The Lambda function is triggered by the upload event
  3. The file is downloaded and processed — either locally (for development/testing) or inside Lambda (for remote execution)
  4. Buckets are created according to the prefab configuration if they don’t already exist

CLI Testing

Use mise run bucket-request to process a file locally without uploading to S3:

mise run bucket-request --file files/buckets-list.txt --stack digipres-dev1 --profile default
  • --file — path to a local file containing bucket names
  • --stack — the stack name (used as a prefix for created buckets)
  • --profile — the AWS profile to use

You can also create a single bucket by name without a file, using the cargo CLI directly.

Important

Before testing, export your aws profile prior to using the cargo CLI.

cargo run -p dcp -- bucket-request --stack=digipres-dev1 --name=rare-books

This is useful for one-off bucket creation or quick iteration without maintaining a file.

Remote Testing

Use mise run upload to upload a file to S3 and trigger the Lambda function as it would run in production:

mise run upload --bucket digipres-dev1-request --dir buckets --file files/buckets.txt --profile default
  • --bucket — the name of the S3 request bucket (typically ${stack}-request)
  • --dir — the S3 directory (path) to upload into (must be buckets)
  • --file — path to the local file containing bucket names
  • --profile — the AWS profile to use

Output

Given the example file files/buckets.txt, two buckets should be created (assuming they do not already exist):

  • digipres-dev1-private — private S3 bucket
  • digipres-dev1-private-repl — private S3 bucket used as the replication destination for the above

You can verify the buckets were created using:

mise run bucket list --profile default
# Filter results by stack name using grep
mise run bucket list --profile default | grep digipres-dev1

QA testing

Aside from the happy path, here are variations to try:

  • File too large
  • File invalid (rename some other file buckets.txt i.e a jpg)
  • Bucket names are too long or has invalid characters
  • Too many bucket names (5 max, additionals are discarded)
  • Bucket names are duplicates, the buckets already exist
  • Errors should be uploaded to a file in the managed bucket feedback path