Skip to content

feat: update image links to s3 - #62

Merged
Perry2004 merged 2 commits into
mainfrom
feat/update-image-links-in-s3)
Nov 1, 2025
Merged

Perry2004 merged 2 commits into
mainfrom
feat/update-image-links-in-s3)

Conversation

@Perry2004

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings November 1, 2025 22:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread scripts/src/lambda-handler.ts Outdated
Comment on lines +34 to +35
const bucketName = "perryz-portfolio-website-usw2dev";
const key = "website/data/rolling-images.json";

Copilot AI Nov 1, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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");
}

Copilot uses AI. Check for mistakes.
import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";
import { getImageLinksPlaywright } from "./main";

const s3Client = new S3Client({ region: "us-west-2" });

Copilot AI Nov 1, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AWS region is hardcoded. Consider using an environment variable like process.env.AWS_REGION to allow region configuration without code changes.

Suggested change
const s3Client = new S3Client({ region: "us-west-2" });
const s3Client = new S3Client({ region: process.env.AWS_REGION || "us-west-2" });

Copilot uses AI. Check for mistakes.
@Perry2004
Perry2004 merged commit 1ff7a5e into main Nov 1, 2025
2 checks passed
@Perry2004
Perry2004 deleted the feat/update-image-links-in-s3) branch November 1, 2025 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants