Skip to content

Navigation Menu

Sign in
Sign up

fix: correct institiation of S3Client - #296

Open
kevin-sucasa wants to merge 1 commit into
localstack:master from
kevin-sucasa:fix/correct-instiation
Open

fix: correct institiation of S3Client #296
kevin-sucasa wants to merge 1 commit into
localstack:master from
kevin-sucasa:fix/correct-instiation

Conversation

@kevin-sucasa

@kevin-sucasa kevin-sucasa commented Apr 16, 2026
edited
Loading

Copy link
Copy Markdown

I ran into this issue and am currently doing a patch in my rpeo.
Just thought you guys might also want this fix as well. Happy to address any problems!

Problem

The patchCustomResourceLambdaS3ForcePathStyle method fails to inject forcePathStyle: true into the Serverless Framework's custom-resources Lambda. This causes Custom::S3 CloudFormation resources
to fail during LocalStack deployments with:

getaddrinfo ENOTFOUND .

The root cause is a mismatch between the string pattern the plugin searches for and the actual code in s3/lib/bucket.js inside custom-resources.zip:

Pattern
Plugin searches for S3Client({ maxAttempts: MAX_AWS_REQUEST_TRY });
Actual code new S3Client({ maxAttempts: MAX_AWS_REQUEST_TRY })

Two differences: missing new keyword, and a trailing semicolon that doesn't exist. Because String.replace() fails silently when there's no match, the zip is written back unmodified and the
S3Client never gets forcePathStyle: true.

Impact

Without forcePathStyle, the AWS SDK uses virtual-hosted-style S3 addressing (bucket.hostname:port), which requires DNS resolution for each bucket name. Inside Docker/LocalStack, these hostnames
don't resolve — causing all Custom::S3 resources (e.g. S3 event notifications) to fail during stack creation.

Fix

Updated the search and replacement strings to match the actual S3Client instantiation code, including the new keyword and removing the incorrect semicolon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /