While debugging a support case about serverless-python-requirements, I stumbled upon an issue regarding Serverless own internal Custom Resources: they would spin up a lambda to update the notification configuration of an existing S3 bucket. However, they would try to access it using virtual host addressing, leading to the lambda failing and the bucket not getting the right configuration. You can reproduce it using this kind of function events:
The deployment would not fail, but the S3 bucket would not trigger the lambda.
This PR introduces a mechanism to hook into package:compileEvents which is triggered when building resources to manage events. We're checking for the presence of the custom-resources.zip file, which would be created if Serverless was going to package its internal custom-resources to create its lambdas.
We then get the utils.js file which is imported by all lambdas, and set the SDK config there to use S3forcePathStyle=true.
As there are nothing in the node standard library to unzip file, I had to introduce a new dependency, adm-zip.
While debugging a support case about
serverless-python-requirements
, I stumbled upon an issue regarding Serverless own internal Custom Resources: they would spin up a lambda to update the notification configuration of an existing S3 bucket. However, they would try to access it using virtual host addressing, leading to the lambda failing and the bucket not getting the right configuration. You can reproduce it using this kind of function events:The deployment would not fail, but the S3 bucket would not trigger the lambda.
This PR introduces a mechanism to hook into
package:compileEvents
which is triggered when building resources to manageevents
. We're checking for the presence of thecustom-resources.zip
file, which would be created if Serverless was going to package its internal custom-resources to create its lambdas. We then get theutils.js
file which is imported by all lambdas, and set the SDK config there to useS3forcePathStyle=true
. As there are nothing in the node standard library to unzip file, I had to introduce a new dependency,adm-zip
.Relevant documentation: