Repository navigation
feat: add AppSync DynamoDB example, bring S3 upload example to the standard - #837
Merged
Merged
Conversation
…andard Add aws-node-appsync-dynamodb: an AppSync GraphQL API from the built-in appSync block, with API key auth and two APPSYNC_JS resolvers (createPost, getPost) on a DynamoDB table, and a live test that creates a post and reads it back. Rework aws-node-upload-to-s3-and-postprocess: an upload under uploads/ triggers a Node.js 24 function that reads the object and writes a summary under processed/. The bucket name carries the stage and account ID, the s3 event uses a prefix rule, the function role is limited to the two prefixes, and a live test uploads a file and checks the summary. The HTML form and its signing script, which needed AWS keys in a local file, are removed.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What this changes
aws-node-upload-to-s3-and-postprocess(upgraded to the example standard)Lesson: an upload to S3 invokes a function, through the Framework's
s3event, and the function processes the new object.uploads/invokespostprocess(nodejs24.x, arm64, ES module, AWS SDK v3 from the runtime), which reads the object and writes a JSON summary (bytes, lines, words, SHA-256) toprocessed/<name>.json.s3event has aprefix: uploads/rule; results go toprocessed/, so the function's own writes don't invoke it.upload-postprocess-${sls:stage}-${aws:accountId}; its name is a stack output,UploadBucketName.s3:GetObjectonuploads/*ands3:PutObjectonprocessed/*only (wass3:*on*).serviceis nows3-postprocess(14 characters), so the Lambda role name stays under 64 characters in every Region with a test stage.example.jsonwith ascriptcheck (test/smoke.mjs), a README in the fixed sections, and the catalogue entries regenerated withnpm run docs. Title, author and priority are kept; the description now matches what the example does.Left out: the HTML upload form and
generate-form.js(it needed AWS access keys in a local file to sign a POST policy, plus thecrypto-jsdependency), image-specific processing such as thumbnails (needs a native dependency), a second bucket for results, and dead-letter handling.aws-node-appsync-dynamodb(new)Lesson: the built-in v4
appSyncblock deploys a GraphQL API with no plugin: API key auth, a DynamoDB data source and twoAPPSYNC_JSunit resolvers (createPost,getPost).GraphQlApiUrlandGraphQlApiKeyfrom${appsync:url}and${appsync:apiKey.defaultKey}, for the test script and tools that read outputs.@aws-appsync/utilsto the AppSync runtime.Left out: Cognito or IAM auth, pipeline resolvers, Lambda resolvers, subscriptions, caching, custom domains.
Test plan
AWS
us-east-1, Serverless Framework 4.47.0.Static:
npm test(323 pass, 0 fail),npm run validate(0 errors),npm run check-docs(clean),node scripts/check-examples.mjs <dir> --packagefor both (0 errors). Nopackage.jsondependencies in either example, so nothing fornpm audit.words: 12)exkf4spamr2FAIL neg-s3 4.47.0 109satcheck:expected words 12; got 11exkhjygbsy3PASS aws-node-upload-to-s3-and-postprocess 4.47.0 106sexknh1ckikqFAIL neg-appsync 4.47.0 99satcheck:getPost(...)title mismatchexkpoack8j4PASS aws-node-appsync-dynamodb 4.47.0 98sPassing check lines:
Both READMEs were followed literally from a clean copy, each command as the page shows it plus a unique
--stage: the deploy output,serverless info, thecurlrequests (create, read back, unknown IDnull, no key401), the S3 upload, the summary JSON,serverless logsand the cleanup commands all matched the page, with no step needing a guess. After the runs,describe-stacksreportsdoes not existfor every stack, and nos3-postprocesslog group,upload-postprocess-*bucket,appsync-dynamodb-*API or table is left.Generated by Claude Code