javascriptv3/example_code/cross-services/photo-asset-manager/README.md
This example shows you how to use the AWS SDK for JavaScript (v3) to create a photo asset management application using AWS services and a serverless architecture.
The Photo Asset Management (PAM) example app uses Amazon Rekognition to categorize images, which are stored with Amazon Simple Storage Service (Amazon S3) Intelligent-Tiering for cost savings. Users can upload new images. Those images are analyzed with label detection and the labels are stored in an Amazon DynamoDB table. Users can later request a bundle of images matching those labels. When images are requested, they are retrieved from Amazon S3, zipped, and the user is sent a link to the zip.
The PAM example has both shared resources and language-specific AWS Lambda functions. The CDK files let you deploy the shared resources and choose which set of functions to deploy to Lambda. This README is for the JavaScript Lambda functions.
Follow the instructions in the README for the Photo Asset Manager application to use the AWS Cloud Development Kit (AWS CDK) or AWS Command Line Interface (AWS CLI) to create and manage the resources used in this example. You must be running Docker in order to complete the steps for this CDK.
The Lambda handlers are written in ESM and deployed as ESM with the added step of being bundled into one file.
This bundling happens automatically when you deploy the <PAM_NAME>-<PAM_LANG>-PAM stack. The CDK bundling step will run npm run build and then deploy the output to Lambda. The CDK step is declared here.
Follow the steps in the README for the Photo Asset Manager front-end.
To avoid charges, delete all the resources that you created for this tutorial. Follow the steps in README for the Photo Asset Manager CDK to clean up the resources for the CDK stacks.
Congratulations! You have created and deployed a photo asset management application.
Vitest is being used as the test runner, but Vite is made for browser development. It uses Rollup under the hood for bundling libraries, but configuration is simpler when Rollup is used independently.
When bundling with Vite, it bundles for the browser, so any NodeJS natives without polyfills will cause an error to be thrown. Turning on Vite's server-side rendering feature gets around this, but it makes it less clear what we're trying to do. The configuration got to a point where it seemed more opaque than helpful. Falling back to pure Rollup clarified things.
Have more questions? Create an issue.