我正在创建 Step Functions,并希望在 cloudformation 代码中引用 Lambda 函数。 lambda 已经从单独的堆栈创建并导出为LambdaA
从那个堆栈。
当我尝试导入时遇到问题LambdaA
进入我的步骤功能代码。
这是我的云信息片段。
ABCStateMachine:
Type: 'AWS::StepFunctions::StateMachine'
Properties:
StateMachineName: 'AbcStateMachine_1.0'
RoleArn:
Fn::GetAtt: [ AbcStateMachineRole, Arn ]
DefinitionString:
Fn::Sub:
- |-
{
"StartAt": "DoStuff",
"Version": "1.0",
"States": {
"DoStuff" : {
"Type": "Task",
"Comment": "Does some stuff.,
"Resource": {"Fn::ImportValue": "LambdaA"}, # error here
"Next": "IsStuffDone"
},
"IsStuffDone": {
"Type": "Choice",
...
...
我在 Cloudformation 控制台中收到以下错误:
状态机定义无效:“SCHEMA_VALIDATION_FAILED at /DoStuff/Resource”(服务:AWSStepFunctions;状态代码:400;错误代码:InvalidDefinition。
知道这里可能出了什么问题吗?
您不能在内部使用其他内部函数Fn::Sub
功能。但Fn::Sub
提供了解决这个问题的方法。它的工作原理有点像format
函数可以在其他编程语言中工作。这是针对您的具体情况的示例:
ABCStateMachine:
Type: 'AWS::StepFunctions::StateMachine'
Properties:
StateMachineName: 'AbcStateMachine_1.0'
RoleArn:
Fn::GetAtt: [ AbcStateMachineRole, Arn ]
DefinitionString:
Fn::Sub:
- |-
{
"StartAt": "DoStuff",
"Version": "1.0",
"States": {
"DoStuff" : {
"Type": "Task",
"Comment": "Does some stuff.,
"Resource": ${LambdaToImport}, # error here
"Next": "IsStuffDone"
}
...
}
...
}
- LambdaToImport:
Fn::ImportValue: LambdaA
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)