serverless: 'name.replace is not a function' while serverless deploy
#This is a (Bug Report)
Description
When I run serverless deploy in a n AWS Lambda project that has python library (Pillow - for image processing) dependencies, I get the following deployment error.
For bug reports:
- What went wrong?
serverless deploydidnt work. - What did you expect should have happened? The deployment should have been successful and the lambda function should have worked.
- What stacktrace or error message from your provider did you see?
Additional Data
- Serverless Framework Version you’re using: 1.21.0
- Operating System: Mac 10.12.6 Sierra
- Stack Trace:
> serverless deploy -v
Serverless: Parsing Python requirements.txt
Serverless: Installing required Python packages for runtime python2.7...
Serverless: Docker Image: lambci/lambda:build-python2.7
Serverless: Linking required Python packages...
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Unlinking required Python packages...
Type Error ---------------------------------------------
name.replace is not a function
For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
Stack Trace --------------------------------------------
TypeError: name.replace is not a function
at Object.normalizeNameToAlphaNumericOnly (/Users/vkumar/.nvm/versions/node/v8.1.3/lib/node_modules/serverless/lib/plugins/aws/lib/naming.js:32:36)
at Object.normalizeBucketName (/Users/vkumar/.nvm/versions/node/v8.1.3/lib/node_modules/serverless/lib/plugins/aws/lib/naming.js:200:17)
at Object.getLambdaS3PermissionLogicalId (/Users/vkumar/.nvm/versions/node/v8.1.3/lib/node_modules/serverless/lib/plugins/aws/lib/naming.js:263:8)
at s3EnabledFunctions.forEach.s3EnabledFunction (/Users/vkumar/.nvm/versions/node/v8.1.3/lib/node_modules/serverless/lib/plugins/aws/package/compile/events/s3/index.js:189:10)
at Array.forEach (<anonymous>)
at AwsCompileS3Events.compileS3Events (/Users/vkumar/.nvm/versions/node/v8.1.3/lib/node_modules/serverless/lib/plugins/aws/package/compile/events/s3/index.js:167:24)
at BbPromise.reduce (/Users/vkumar/.nvm/versions/node/v8.1.3/lib/node_modules/serverless/lib/classes/PluginManager.js:242:55)
From previous event:
at PluginManager.invoke (/Users/vkumar/.nvm/versions/node/v8.1.3/lib/node_modules/serverless/lib/classes/PluginManager.js:242:22)
at PluginManager.spawn (/Users/vkumar/.nvm/versions/node/v8.1.3/lib/node_modules/serverless/lib/classes/PluginManager.js:254:17)
at Deploy.BbPromise.bind.then.then (/Users/vkumar/.nvm/versions/node/v8.1.3/lib/node_modules/serverless/lib/plugins/deploy/deploy.js:101:50)
From previous event:
at Object.before:deploy:deploy [as hook] (/Users/vkumar/.nvm/versions/node/v8.1.3/lib/node_modules/serverless/lib/plugins/deploy/deploy.js:99:10)
at BbPromise.reduce (/Users/vkumar/.nvm/versions/node/v8.1.3/lib/node_modules/serverless/lib/classes/PluginManager.js:242:55)
From previous event:
at PluginManager.invoke (/Users/vkumar/.nvm/versions/node/v8.1.3/lib/node_modules/serverless/lib/classes/PluginManager.js:242:22)
at PluginManager.run (/Users/vkumar/.nvm/versions/node/v8.1.3/lib/node_modules/serverless/lib/classes/PluginManager.js:261:17)
at variables.populateService.then (/Users/vkumar/.nvm/versions/node/v8.1.3/lib/node_modules/serverless/lib/Serverless.js:99:33)
at runCallback (timers.js:781:20)
at tryOnImmediate (timers.js:743:5)
at processImmediate [as _immediateCallback] (timers.js:714:5)
From previous event:
at Serverless.run (/Users/vkumar/.nvm/versions/node/v8.1.3/lib/node_modules/serverless/lib/Serverless.js:86:74)
at serverless.init.then (/Users/vkumar/.nvm/versions/node/v8.1.3/lib/node_modules/serverless/bin/serverless:39:50)
at <anonymous>
Your Environment Information -----------------------------
OS: darwin
Node Version: 8.3.0
Serverless Version: 1.21.0
- Provider Error messages: ‘name.replace is not a function’
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 3
- Comments: 24 (4 by maintainers)
I had same issue. I don’t suppose serverless.yml supports “Ref” in events[].s3.bucket.
@JonChristensen Thanks, but that library leads to corrupted deployments as its need to be done in two steps 😞
Anyway, I solved it by completely ignoring the
serverlessfeatures and instead of usingevents.s3in function definition, we are defining the function ARN in bucket’s template:I have the same issue. It looks like it is because we are trying to make reference to the
ServerlessDeploymentBucket. Is there a better way to reference this bucket arn predictably?I am trying to set up a Lambda event triggered by s3 whenever there is a deploy from serverless. I need to create RDS tables via Lambda whenever a user deploys a new instance.
I’m running into this same issue.
Not sure if others are still grappling with this, but it looks as thought serverless has a flag to allow for pre-existing buckets:
I also ran into the same issue. any update on this?
But what if you are making a bucket while trying to reference it in one of your functions? When I use the existing flag it always fails to delete due to a race condition.