-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
daaf182
commit 3b99c90
Showing
10 changed files
with
674 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
FROM node:16-alpine as build | ||
|
||
WORKDIR /usr/src/app | ||
|
||
# Copy package files and install all dependencies | ||
COPY ./package*.json ./ | ||
COPY ./agent-core/package*.json ./agent-core/ | ||
COPY ./rotators/mysql/package*.json ./rotators/mysql/ | ||
COPY ./utils/aws/package*.json ./utils/aws/ | ||
COPY ./apps/aws-mysql-rotator/package*.json ./apps/aws-mysql-rotator/ | ||
RUN npm install --workspace apps/aws-mysql-rotator | ||
|
||
# Copy sources | ||
COPY ./tsconfig* ./ | ||
COPY ./agent-core ./agent-core | ||
COPY ./rotators/mysql ./rotators/mysql | ||
COPY ./utils/aws ./utils/aws | ||
COPY ./apps/aws-mysql-rotator ./apps/aws-mysql-rotator | ||
|
||
# Build dependencies and app | ||
RUN npm --prefix ./agent-core run build | ||
RUN npm --prefix ./rotators/mysql run build | ||
RUN npm --prefix ./utils/aws run build | ||
RUN npm --prefix ./apps/aws-mysql-rotator run build | ||
|
||
# Remove node_modules to be reinstalled later | ||
RUN rm -r node_modules | ||
|
||
FROM public.ecr.aws/lambda/nodejs:16 | ||
|
||
WORKDIR ${LAMBDA_TASK_ROOT} | ||
|
||
COPY --from=build /usr/src/app . | ||
|
||
# Only install production dependencies | ||
RUN npm clean-install --production | ||
|
||
CMD [ "apps/aws-mysql-rotator/dist/app.handler" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { JWKSOption, processRequest } from "agent-core"; | ||
import mysqlHandler from "mysql-rotator"; | ||
import { fetchS3KeySet } from "aws-utils"; | ||
|
||
export async function handler(event: { body: string }) { | ||
let keySetOption: JWKSOption; | ||
if (process.env.OVERRIDE_KEY_SET) { | ||
keySetOption = { type: "local", keySet: JSON.parse(process.env.OVERRIDE_KEY_SET) }; | ||
} else { | ||
keySetOption = { type: "local", keySet: await fetchS3KeySet(process.env.OVERRIDE_KEY_SET_S3_BUCKET) }; | ||
} | ||
return await processRequest(event.body, mysqlHandler, { overrideKeySet: keySetOption }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "aws-mysql-rotator", | ||
"version": "1.0.0", | ||
"type": "module", | ||
"description": "", | ||
"main": "dist/app.js", | ||
"types": "dist/app.d.ts", | ||
"engines": { | ||
"node": "16.x" | ||
}, | ||
"scripts": { | ||
"build": "tsc", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "", | ||
"license": "Apache-2.0", | ||
"devDependencies": { | ||
"typescript": "^4.6.4" | ||
}, | ||
"dependencies": { | ||
"agent-core": "*", | ||
"mysql-rotator": "*", | ||
"aws-utils": "*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "dist" | ||
}, | ||
"references": [{ "path": "../../agent-core" }, { "path": "../../rotators/mysql" }, { "path": "../../utils/aws" }] | ||
} |
Oops, something went wrong.