考虑一个代码:
无服务器.yml
service: my-service
frameworkVersion: ">=1.38.0 <2.0.0"
plugins:
- serverless-step-functions
- serverless-pseudo-parameters
- serverless-cf-vars
- serverless-parameters
provider:
name: aws
stage: ${opt:stage}
region: us-east-1
stepFunctions:
stateMachines:
MyStateMachine:
name: my_state_machine
notifications:
ABORTED:
- sns:
Ref: SnsTopic
FAILED:
- sns:
Ref: SnsTopic
definition:
StartAt: "Just Pass"
States:
"Just Pass":
Type: Pass
End: true
Resources:
SnsTopic:
Type: AWS::SNS::Topic
Properties:
TopicName: MySnsTopic
包.json
{
"devDependencies": {
"serverless-pseudo-parameters": "^2.5.0",
"serverless-step-functions": "^2.10.0",
"serverless-cf-vars": "^0.3.2",
"serverless-domain-manager": "3.2.7",
"serverless-aws-nested-stacks": "^0.1.2",
"serverless-parameters": "0.1.0"
}
}
失败并出现错误:
Error --------------------------------------------------
Error: The CloudFormation template is invalid: Template format error: Unresolved resource dependencies [SnsTopic] in the Resources block of the template
所以看起来在创建状态机时没有SnsTopic
资源。但是如何在状态机之前创建呢?
DependsOn
状态机上的属性导致相同的错误。有任何想法吗?