Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,31 @@ jobs:
run: |
npm run test

# layer build
buid-js-layer-deps:
timeout-minutes: 15
runs-on: ubuntu-latest
name: Build SLS Layer - Prod
container:
image: "node:14-buster"
steps:
- uses: actions/checkout@v2
- run: |
npm install --production
mkdir nodejs
mv node_modules nodejs
apt update -y && apt install zip -y
zip -r nodejs.zip nodejs/

- uses: actions/upload-artifact@v2
with:
name: nodejsdeps
path: nodejs.zip

deploy-env:
name: Deploy Lambda
runs-on: ubuntu-latest
needs: testing-changes
needs: [testing-changes, buid-js-layer-deps]
steps:
- uses: actions/checkout@v2.0.0

Expand All @@ -37,6 +58,11 @@ jobs:
if: steps.cached-npm-dependencies.outputs.cache-hit != 'true'
run: 'npm install'

- uses: actions/download-artifact@v2
with:
name: nodejsdeps
path: app/

- name: Deploy using sls
run: 'npx sls deploy'
env:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
.dynamodb/
.serverless
venv
venv
nodejs.zip
26 changes: 26 additions & 0 deletions authorizer/handler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const authorize = async (event, context) => {
let date = new Date();
let minutes = date.getMinutes();
let hour = date.getHours();

if (event.authorizationToken === `Bearer ${process.env.SECRET_EGG}-${hour}-${minutes}`) {
return {
principalId: 'anonymous',
policyDocument: {
Version: '2012-10-17',
Statement: [
{
Action: 'execute-api:Invoke',
Effect: 'Allow',
Resource: event.methodArn,
},
],
},
};
}
throw Error('Unauthorized');
}

module.exports = {
authorize
}
Loading