Skip to content

Lambda Functions

Brian Riley edited this page Jul 20, 2024 · 2 revisions

<- Home

AWS Serverless Application Model (SAM)

The DMPTool uses AWS Lambda functions in three different ways:

  1. API Lambdas - act as endpoints for the REST API. They serves as an interface for interacting with the JSON for DMP records stored in DynamoDB
  2. Lambdas triggered by events - these functions listen for messages posted to the AWS EventBus by the API Lambdas. They provide a way to perform tasks in an async manner
  3. Scheduled events - these functions are kicked off by scheduled rules in the AWS EventBus

There are 2 main categories of

API Lambda Functions

  • ValidateDmp

  • GetDmps

  • PostDmps

  • GetDmp

  • PutDmp

  • DeleteDmp

  • PostNarratives

  • PostCitations

  • GetAwardsCrossref

  • GetAwardsNih

  • GetAwardsNsf

Building and Deploying

Triggered Lambda Functions

Please note that these Lambdas don't return a response. If a fatal error occurs, the email address defined in the /uc3/dmp/hub/[env]/AdminEmail SSM parameter is sent a message with the error details. The admin can then check the logs for more information.

  • DmpIndexer
  • DataCiteHarvester

EZID Publisher

The publisher function manages interaction with the EZID system which we use to register our DMP IDs (aka DOIs). The DMPHub preassigns its own DMP ID values using the shoulder stored in the SSM parameter store (e.g. shoulder: '10.12345' and a randomly generated id like 'ABC123z9' would result in a DMP ID of https://doi.org/10.12345/ABC123z9).

Triggered when: detail-type == 'EZID update' && source == 'example.com:lambda:event_publisher' && SK == 'VERSION#latest'

See the separate wiki page for information on how to pause communications with EZID.

Here is an example event used to trigger this Lambda:

{
  "version": "0",
  "id": "5c9a3747-293c-59d7-dcee-a2210ac034fc",
  "detail-type": "EZID update",
  "source": "example.com:lambda:event_publisher",
  "account": "1234567890",
  "time": "2023-02-14T16:42:06Z",
  "region": "us-west-2",
  "resources": [],
  "detail": {
    "PK": "DMP#doi.org/10.12345/ABC123z9",
    "SK": "VERSION#latest",
    "dmphub_provenance_id": "PROVENANCE#example",
    "dmproadmap_links": {
      "download": "https://example.com/api/dmps/12345.pdf",
    },
    "dmphub_updater_is_provenance": false
  }
}

Citer

The Citer function will ONLY work with DOIs. It makes a application/x-bibtex request to the DOI. It then transforms the BibTex content using the Citeproc gem into a Chicago-author-date style citation.

Triggered when: detail-type == 'Citation fetch' && source == 'example.com:lambda:event_publisher' && the record's SK == 'VERSION#latest'

Here is an example event used to trigger this Lambda:

{
  "version": "0",
  "id": "5c9a3747-293c-59d7-dcee-a2210ac034fc",
  "detail-type": "DMP change",
  "source": "example.com:lambda:event_publisher",
  "account": "1234567890",
  "time": "2023-02-14T16:42:06Z",
  "region": "us-west-2",
  "resources": [],
  "detail": {
    "PK": "DMP#doi.org/10.12345/ABC123z9",
    "SK": "VERSION#latest",
    "dmproadmap_related_identifier": {
      "work_type": "article",
      "descriptor": "references",
      "type": "doi",
      "identifier": "https://dx.doi.org/10.12345/ABCD1234"
    }
  }
}

Building and Deploying

Scheduled Lambda Functions

  • HavestableDmps

Building and Deploying

Lambda Layers

  • Lambda Layer for API
  • Lambda Layer for Standalones

Building and Deploying

Ruby Gems

  • uc3-api-core
  • uc3-api-citation
  • uc3-api-cloudwatch
  • uc3-api-cognito
  • uc3-api-dynamo
  • uc3-api-event-bridge
  • uc3-api-external-api
  • uc3-api-id
  • uc3-api-provenance
  • uc3-api-s3

Building and Deploying