localstack / serverless-localstack

⚡ Serverless plugin for running against LocalStack
511 stars 82 forks source link

Plugin issue with serverless 3.39.0 #252

Closed grzes-94 closed 2 days ago

grzes-94 commented 1 week ago

custom-resources lambda is not being updated properly after updating to serveless 3.39.0 which changed lambda runtime to node18

Plugin searches for AWS.config.logger = console; here which was recently removed from serverless code.

In a result AWS.config.s3ForcePathStyle = true; is added at the end of the utils.js file

module.exports = {
  logger,
  response,
  getEnvironment,
  getLambdaArn,
  handlerWrapper,
  wait,
  MAX_AWS_REQUEST_TRY,
};AWS.config.s3ForcePathStyle = true;

Running lambda fails with exception as node18 lambdas uses AWS SDK v3

2024-06-18T09:45:55.149Z    undefined   ERROR   Uncaught Exception  
{
    "errorType": "ReferenceError",
    "errorMessage": "AWS is not defined",
    "stack": [
        "ReferenceError: AWS is not defined",
        "    at Object.<anonymous> (/var/task/utils.js:107:3)",
        "    at Module._compile (node:internal/modules/cjs/loader:1364:14)",
        "    at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)",
        "    at Module.load (node:internal/modules/cjs/loader:1203:32)",
        "    at Module._load (node:internal/modules/cjs/loader:1019:12)",
        "    at Module.require (node:internal/modules/cjs/loader:1231:19)",
        "    at require (node:internal/modules/helpers:177:18)",
        "    at Object.<anonymous> (/var/task/api-gateway-cloud-watch-role/handler.js:3:39)",
        "    at Module._compile (node:internal/modules/cjs/loader:1364:14)",
        "    at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)"
    ]
}
dfangl commented 1 week ago

Thank you for the detailed report and investigation! We will work on a patch to make serverless-localstack compatible with the latest serverless version again, and update you here on the progress.

dfangl commented 1 week ago

This issue should now be fixed with #254. A new version of the plugin was released minutes ago. Can you confirm your issues are fixed?

Thank you for reporting this bug!

grzes-94 commented 2 days ago

Its working as expected now, thanks!