-
Notifications
You must be signed in to change notification settings - Fork 5
fix: Lambda RMU on LocalStack with DynamoDB Streams #783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
49d176c
feat(lambda): add Lambda RMU build/deploy scripts and handler
j5ik2o 5847b7c
fix(e2e): configure LocalStack for Lambda execution and update E2E flow
j5ik2o f62eacb
fix(rmu): handle LocalStack raw JSON payload and add rhel-openssl-1.0…
j5ik2o 47d5239
fix(build): set main to dist/index.js and add Lambda build/deploy scr…
j5ik2o 8170dc7
fix(graphql): add explicit type functions to @Arg() decorators
j5ik2o 6c5055f
fix(infra): add aws-cli to CI, gitignore common.env, integrate Lambda…
j5ik2o b539b76
docs: document Lambda RMU on LocalStack and mark feature complete
j5ik2o 1c730c8
Merge branch 'main' into fix/lambda-rmu-on-localstack
j5ik2o 0174481
fix(lambda): isolate Docker build to prevent host node_modules corrup…
j5ik2o 8452498
fix: add common.env.default to repository
j5ik2o File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -19,3 +19,6 @@ yarn-error.log | |
| .turbo/ | ||
| .turbo/* | ||
|
|
||
| # Local developer overrides (see common.env.default) | ||
| common.env | ||
|
|
||
This file contains hidden or 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,3 @@ | ||
| [submodule "references/okite-ai"] | ||
| path = references/okite-ai | ||
| url = git@github.com:j5ik2o/okite-ai.git | ||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,29 @@ | ||
| # Copy to common.env and adjust. common.env is gitignored. | ||
| # Host-side AWS CLI uses this URL (Compose maps LocalStack to host port 34566). | ||
| LOCALSTACK_ENDPOINT_URL=http://localhost:34566 | ||
|
|
||
| AWS_REGION=ap-northeast-1 | ||
| AWS_DEFAULT_REGION=ap-northeast-1 | ||
| AWS_ACCESS_KEY_ID=x | ||
| AWS_SECRET_ACCESS_KEY=x | ||
|
|
||
| STREAM_JOURNAL_TABLE_NAME=journal | ||
| STREAM_MAX_ITEM_COUNT=32 | ||
|
|
||
| # Lambda container reaches MySQL on the Compose network (see docker-compose-databases.yml). | ||
| DATABASE_URL_LAMBDA=mysql://ceer:ceer@mysql-local:3306/ceer | ||
|
|
||
| FUNCTION_NAME=read-model-updater-rmu | ||
| # LocalStack 2.x では nodejs20.x が無い場合があるため既定は nodejs18.x | ||
| LAMBDA_RUNTIME=nodejs18.x | ||
| COMPOSE_PROJECT=cqrs-es-example-js | ||
|
|
||
| # 1 = after deploy, stop container read-model-updater-1 to avoid double stream processing | ||
| STOP_LOCAL_RMU_AFTER_LAMBDA_DEPLOY=1 | ||
|
|
||
| # docker-compose-up.sh: build/deploy Lambda zip when non-zero | ||
| DOCKER_COMPOSE_UP_BUILD_LAMBDA=1 | ||
| DOCKER_COMPOSE_UP_DEPLOY_LAMBDA=1 | ||
|
|
||
| # Override if your compose project name differs (affects LAMBDA_DOCKER_NETWORK default in compose). | ||
| # LAMBDA_DOCKER_NETWORK=cqrs-es-example-js_default |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,5 @@ | ||
| [tools] | ||
| node = "20" | ||
| python = "3" | ||
| "npm:@fission-ai/openspec" = "1.2.0" | ||
| "npm:happy-coder" = "0.13.0" |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,29 @@ | ||
| import { PrismaClient } from "@prisma/client"; | ||
| import type { DynamoDBStreamEvent, Handler } from "aws-lambda"; | ||
| import { GroupChatDao, ReadModelUpdater } from "cqrs-es-example-js-rmu"; | ||
|
|
||
| let prisma: PrismaClient | undefined; | ||
| let readModelUpdater: ReadModelUpdater | undefined; | ||
|
|
||
| function getReadModelUpdater(): ReadModelUpdater { | ||
| if (readModelUpdater) { | ||
| return readModelUpdater; | ||
| } | ||
| const databaseUrl = process.env.DATABASE_URL; | ||
| if (!databaseUrl) { | ||
| throw new Error("DATABASE_URL is not set"); | ||
| } | ||
| prisma = new PrismaClient({ | ||
| datasources: { | ||
| db: { | ||
| url: databaseUrl, | ||
| }, | ||
| }, | ||
| }); | ||
| readModelUpdater = ReadModelUpdater.of(GroupChatDao.of(prisma)); | ||
| return readModelUpdater; | ||
| } | ||
|
|
||
| export const handler: Handler<DynamoDBStreamEvent, void> = async (event) => { | ||
| await getReadModelUpdater().updateReadModel(event); | ||
| }; |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated private git submodule accidentally committed
Medium Severity
A
.gitmodulesfile referencingreferences/okite-aivia a private SSH URL (git@github.com:j5ik2o/okite-ai.git) is included in this PR but is entirely unrelated to the Lambda RMU / DynamoDB Streams changes. This will causegit clone --recursive(orgit submodule update --init) to fail for anyone without SSH access to that private repository, breaking CI or onboarding flows.