Custom application looks for new CSV files in an S3 bucket and uses the OCLC Number data within to look for present OCLC Number for each
Clone this repository
$ git clone {url}
or download directly from GitHub.
Change into the application directory
Download node and npm and use the install
command to read the dependencies JSON file
$ npm install
- Request a WSKey for WorldCat Metadata API - http://platform.worldcat.org/wskey/
- a Sandbox WSKey will work fine for this demo
- Copy example_config.yml to prod_config.yml . Open prod_config.yml and edit to include:
- wskey
- secret
- principalID
- principalIDNS
- institution
- Install AWS Commandline tools
- https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html I reccomend using pip.
- Create an AWS user in IAM console. Give it appropriate permissions. Copy the key and secret for this user to use in the CLI.
- Configure the commandline tools - https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html
- Make sure you add -- key/secret -- region
-
Create a KMS key
-
Encrypt the config file
$ aws kms encrypt --key-id {key-id} --plaintext fileb://prod_config.yml --output text --query CiphertextBlob --output text | base64 -D > prod_config_encrypted.txt
- Use the AWS Console to create a bucket. Note your bucket name!!!
- Add a sample csv file of OCLC Numbers to the bucket.
-
Alter s3_event.json to point to your bucket and your sample csv file.
-
Use serverless to test locally
serverless invoke local --function checkOCLCNumber --path s3_event.json
##Installing in AWS Lambda
- Download and setup the application, see Installing locally
- Edit serverless.yml so it include your key ARN
service:
name: trigger-test
awsKmsKeyArn: arn:aws:kms:us-east-1:XXXXXX:key/some-hash
- Deploy the code using serverless
$ serverless deploy
- Make sure the role for the Lambda has the right permissions
- KMS decrypt
- S3 read
- Setup the trigger on the bucket