Receiving ‘TypeError: functionArn.split is not a function’ error when performing ‘serverless deploy’ when using import of arn value from Stack One in Stack Two for an authorizer arn value.
Using serverless version 2.72.3
I have two stacks. One that declares the lambda that handles the authorization logic, and another stack that wants to make use of the lambda as an authorizer.
Stack One:
...
...
functions:
authorizer-with-user-data:
handler: authorizer-with-user-data/index.authorize
environment:
...
...
...
Outputs:
AuthorizerWithUserDataARN:
Value:
Fn::GetAtt:
- AuthorizerDashwithDashuserDashdataLambdaFunction
- Arn
Export:
Name: ${self:provider.stage}-AuthorizerWithUserDataArn
Stack Two (works):
custom:
...
authorizerWithUserDataArn: arn:aws:lambda:us-east-1:${self:custom.accountId.${self:provider.stage}}:function:auth-${self:provider.stage}-authorizer-with-user-data
functions:
get:
handler: get/index.get
events:
- http:
path: /
method: get
authorizer:
name: authorizer
arn: ${self:custom.authorizerWithUserDataArn}
resultTtlInSeconds: 0
identitySource: ''
type: request
This version of Stack Two works as the custom variable is set as a string within the stack. When the authorizerWithUserDataArn variable is set referencing the output variable AuthorizerWithUserDataARN from Stack One, then this doesn’t work and the following error is provided from serverless cli.
Stack Two (does not work):
custom:
...
authorizerWithUserDataArn:
'Fn::ImportValue': "${self:provider.stage}-AuthorizerWithUserDataArn"
functions:
get:
handler: get/index.get
events:
- http:
path: /
method: get
authorizer:
name: authorizer
arn: ${self:custom.authorizerWithUserDataArn}
resultTtlInSeconds: 0
identitySource: ''
type: request
Error Received when performing ‘serverless deploy’
...
...
...
Serverless: Packaging service...
Serverless: Generating custom CloudFormation resources...
Type Error ----------------------------------------------
TypeError: functionArn.split is not a function
at Object.extractAuthorizerNameFromArn (/Users/psaha/Code/fleetoperate-businessportal-services/carriers-api/carrier-companies/node_modules/serverless/lib/plugins/aws/lib/naming.js:140:34)
...
For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: [removed link due to serverless forum 2 link max limit]
Issues: forum.serverless.com
Your Environment Information ---------------------------
Operating System: darwin
Node Version: 14.19.1
Framework Version: 2.72.3 (local)
Plugin Version: 5.5.4
SDK Version: 4.3.2
Components Version: 3.18.2
...
...
...