Repository navigation
feat: update image links to s3 - #62
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds S3 upload functionality to the Lambda handler, enabling it to store fetched image links as JSON in an S3 bucket. The handler now uploads the scraped image data to a designated S3 location after successfully fetching it from Pexels.
- Integrates AWS S3 SDK v3 for uploading JSON data
- Configures S3 client with us-west-2 region
- Implements error handling for S3 upload failures
Reviewed Changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| scripts/src/lambda-handler.ts | Added S3 client initialization, JSON data preparation, and upload logic with error handling; includes S3 location in success response |
| scripts/package.json | Added @aws-sdk/client-s3 dependency (v3.922.0) |
| scripts/package-lock.json | Added lockfile entries for AWS SDK and its transitive dependencies |
Files not reviewed (1)
- scripts/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const bucketName = "perryz-portfolio-website-usw2dev"; | ||
| const key = "website/data/rolling-images.json"; |
There was a problem hiding this comment.
The bucket name and S3 key are hardcoded values that should be externalized to environment variables for better configurability across different environments (dev/staging/prod). Consider using process.env.S3_BUCKET_NAME and process.env.S3_KEY instead.
| const bucketName = "perryz-portfolio-website-usw2dev"; | |
| const key = "website/data/rolling-images.json"; | |
| const bucketName = process.env.S3_BUCKET_NAME; | |
| const key = process.env.S3_KEY; | |
| if (!bucketName || !key) { | |
| throw new Error("Missing required environment variables: S3_BUCKET_NAME and/or S3_KEY"); | |
| } |
| import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; | ||
| import { getImageLinksPlaywright } from "./main"; | ||
|
|
||
| const s3Client = new S3Client({ region: "us-west-2" }); |
There was a problem hiding this comment.
The AWS region is hardcoded. Consider using an environment variable like process.env.AWS_REGION to allow region configuration without code changes.
| const s3Client = new S3Client({ region: "us-west-2" }); | |
| const s3Client = new S3Client({ region: process.env.AWS_REGION || "us-west-2" }); |
No description provided.