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.
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
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.
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:
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.