Skip to content

Commit

Permalink
Merge pull request #175 from nulib/deploy/staging
Browse files Browse the repository at this point in the history
Deploy v2.1.3 to Production
  • Loading branch information
mbklein authored Nov 16, 2023
2 parents 199901c + 86d1b4d commit b80b6b2
Show file tree
Hide file tree
Showing 23 changed files with 14,821 additions and 2,310 deletions.
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
nodejs 16.14.0
java corretto-19.0.1.10.1
aws-sam-cli 1.97.0
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,34 @@ npm run dev

Access the app in a browser at: https://USER_PREFIX.dev.rdc.library.northwestern.edu:3003/

## Running the API locally with state machine + lambdas (needed for AV download route)

```shell
# From the repo root
cd dc-api-v2

# Make sure you've done an `npm install` recently to update any packages in the `lambdas` directory
npm install

# Start the proxy (if needed)
https-proxy start 3002 3000

# Open port 3005 (if needed)
sg open all 3005

# Login as the staging-admin user
export AWS_PROFILE=staging-admin
aws sso login

# Start the API + step function and associated lambdas
bin/start-with-step

# Open a second terminal and create the state machine
aws stepfunctions create-state-machine --endpoint http://localhost:8083 --definition file://state_machines/av_download.json --name "hlsStitcherStepFunction" --role-arn arn:aws:iam::012345678901:role/DummyRole
```



## Deploying the API manually

- Symlink the `*.parameters` file you need from `tfvars/dc-api/` to the application root
Expand Down
6 changes: 6 additions & 0 deletions bin/start-with-step
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

sam local start-lambda --host 0.0.0.0 --port 3005 --env-vars env.json --log-file lambda.log & lambda_pid=$!
sam local start-api --host 0.0.0.0 --log-file dc-api.log & api_pid=$!
docker run --rm -p 8083:8083 -e LAMBDA_ENDPOINT=http://172.17.0.1:3005/ amazon/aws-stepfunctions-local
kill $api_pid $lambda_pid
25 changes: 25 additions & 0 deletions docs/docs/spec/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,31 @@ paths:
description: "The resource is authorized"
403:
description: "The resource is not authorized"
/file-sets/{id}/download:
get:
operationId: getFileSetDownload
tags:
- FileSet
parameters:
- name: id
description: Id of the file set
in: path
required: true
schema:
type: string
- name: email
description: Email to send the download link to
in: query
required: true
schema:
type: string
responses:
200:
description: "The download is being created"
400:
description: "Bad Request"
405:
description: "Method Not allowed for work type, file set role combo"
/works/{id}:
get:
operationId: getWorkById
Expand Down
22 changes: 22 additions & 0 deletions lambdas/get-download-link.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* istanbul ignore file */
const { getSignedUrl } = require("@aws-sdk/s3-request-presigner");
const { S3Client, GetObjectCommand } = require("@aws-sdk/client-s3");

module.exports.handler = async (event) => {
const clientParams = {}

const getObjectParams = {
Bucket: event.bucket,
Key: event.key,
ResponseContentDisposition: `attachment; filename=${event.disposition}`,
};

const client = new S3Client(clientParams);
const command = new GetObjectCommand(getObjectParams);
const url = await getSignedUrl(client, command, { expiresIn: 3600 * 24 * 3 }); // 3 days

return {downloadLink: url}

};


Loading

0 comments on commit b80b6b2

Please sign in to comment.