目前正在学习无服务器和状态机。当我尝试进行部署时,我得到了错误:TypeError: Cannot read property ‘startsWith’ of undefined。
在下面你可以找到我正在尝试部署的serverless.yml定义。我找不到我犯的错误。
我想要的状态机是非常简单的。我想从decision开始,它将直接指向正确的lambda,取决于输入(本手册中的所有内容,目前都是半手册)。在lambda完成之后(不管是哪一个)将会结束。
service: state-machine
plugins:
- serverless-python-requirements
- serverless-iam-roles-per-function
- serverless-step-functions
- serverless-pseudo-parameters
custom:
pythonRequirements:
dockerizePip: non-linux
slim: true
zip: true
provider:
name: aws
runtime: python3.8
region: eu-central-1
stage: ${opt:stage, 'testing'}
timeout: 30
iamRoleStatements:
- Effect: Allow
Action:
- lambda:InvokeFunction
- lambda:InvokeAsync
Resource: "*"
package:
individually: true
exclude:
- node_modules/**
- .git/**
- .venv/**
functions:
process-purchase:
module: state-machine
memorySize: 128
stages:
- testing
- dev
handler: ProcessPurchase.process_purchase
process-refund:
module: state-machine
memorySize: 128
stages:
- testing
- dev
handler: ProcessRefund.process_refund
stepFunctions:
validate: true
stateMachines:
TransactionChoiceMachine:
name: ChoiceMachineTest-${self:provider.stage}
dependsOn: CustomIamRole
definition:
Comment: "Purchase refund choice"
StartAt: ProcessTransaction
States:
ProcessTransaction:
Type: Choice
Choices:
- Variable: "$.TransactionType"
StringEquals: "PURCHASE"
Next: PurchaseState
- Variable: "$.TransactionType"
StringEquals: "REFUND"
Next: RefundState
PurchaseState:
Type: Task
Resource:
Fn::GetAtt: [process-purchase, Arn]
End: true
RefundState:
Type: Task
Resourse:
Fn::GetAtt: [process-refund, Arn]
End: true这是我在SLS_DEBUG=true之后得到的日志
Type Error ---------------------------------------------
TypeError: Cannot read property 'startsWith' of undefined
at /home/maciej/node_modules/serverless-step-functions/lib/deploy/stepFunctions/compileIamRole.js:374:59
at arrayMap (/home/maciej/node_modules/lodash/lodash.js:639:23)
at map (/home/maciej/node_modules/lodash/lodash.js:9554:14)
at Function.flatMap (/home/maciej/node_modules/lodash/lodash.js:9257:26)
at ServerlessStepFunctions.getIamPermissions (/home/maciej/node_modules/serverless-step-functions/lib/deploy/stepFunctions/compileIamRole.js:327:12)
at /home/maciej/node_modules/serverless-step-functions/lib/deploy/stepFunctions/compileIamRole.js:423:56
at Array.forEach (<anonymous>)
at ServerlessStepFunctions.compileIamRole (/home/maciej/node_modules/serverless-step-functions/lib/deploy/stepFunctions/compileIamRole.js:412:32)
From previous event:
at PluginManager.invoke (/usr/lib/node_modules/serverless/lib/classes/PluginManager.js:498:22)
at PluginManager.spawn (/usr/lib/node_modules/serverless/lib/classes/PluginManager.js:518:17)
at /usr/lib/node_modules/serverless/lib/plugins/deploy/deploy.js:122:50
From previous event:
at Object.before:deploy:deploy [as hook] (/usr/lib/node_modules/serverless/lib/plugins/deploy/deploy.js:102:22)
at /usr/lib/node_modules/serverless/lib/classes/PluginManager.js:498:55
From previous event:
at PluginManager.invoke (/usr/lib/node_modules/serverless/lib/classes/PluginManager.js:498:22)
at /usr/lib/node_modules/serverless/lib/classes/PluginManager.js:533:24
From previous event:
at PluginManager.run (/usr/lib/node_modules/serverless/lib/classes/PluginManager.js:533:8)
at /usr/lib/node_modules/serverless/lib/Serverless.js:168:33
From previous event:
at Serverless.run (/usr/lib/node_modules/serverless/lib/Serverless.js:155:74)
at /usr/lib/node_modules/serverless/scripts/serverless.js:50:26
at processImmediate (internal/timers.js:461:21)
From previous event:
at Object.<anonymous> (/usr/lib/node_modules/serverless/scripts/serverless.js:50:4)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/usr/lib/node_modules/serverless/bin/serverless.js:47:1)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
at internal/main/run_main_module.js:17:47发布于 2020-12-03 02:06:25
我的serverless.yml中的第77行有打字错误...应为Resource。
https://stackoverflow.com/questions/65104056
复制相似问题