aws-lambda - CloudFormation - 无法在 StepFunctions StateMachine 的 DefinitionString 中导入 lambda arn

标签 aws-lambda aws-cloudformation aws-step-functions

我正在创建 StepFunctions,它引用在单独的 cloudformation 堆栈中创建的 Lambda 函数。 我将 Lambda arn 导出到 CloudFormation 导出。 我想通过导入导出的值来实现从 StepFunctions 引用 Lambda 函数。

这是我的云信息片段。

  StepFunction:
    Type: 'AWS::StepFunctions::StateMachine'
    Properties:
      RoleArn: !GetAtt IamRole.Arn
      DefinitionString: 
        Fn::Sub:
          - |-
            {
              "StartAt": "MessageGenerator",
              "States": {
                "MessageGenerator": {
                  "Comment": "generate queue message.",
                  "Type": "Task",
                  "Resource": "${LambdaMessageGenerator}",
                  "ResultPath": "$",
                  "OutputPath": "$",
                  "Next": "WaitSeconds"
                },
                ...
              }
            }
          - LambdaMessageGenerator:
              Fn::ImportValue: some-export-name

我按照下面的答案做了这个。 Cloudformation - Unable to Import resource

但是,aws cloudformation deploy 命令失败,并且出现以下错误。

Invalid State Machine Definition: 'SCHEMA_VALIDATION_FAILED: Value is not a valid resource ARN at /States/MessageGenerator/Resource' (Service: AWSStepFunctions; Status Code: 400; Error Code: InvalidDefinition; Request ID: 01713d53-4605-11e9-9cf3-c15ff9ce09ae)

有人可以帮我吗?

最佳答案

尝试使用这一行: "资源": "arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${LambdaFunctionName}"

在这种情况下,您只需传递 lambda 函数的名称。

关于aws-lambda - CloudFormation - 无法在 StepFunctions StateMachine 的 DefinitionString 中导入 lambda arn,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55154557/

相关文章:

google-chrome - Chrome——AWS Lambda 的 headless ?

amazon-web-services - 通过 CloudFormation 更新 Amplify 生成的 S3 的 S3 存储桶策略

python - 在 AWS 中运行 python 脚本的最佳方法是什么?

amazon-web-services - 如何正确地将 MethodResponse 应用于 "filter"AWS api 网关响应

aws-step-functions - Fork/Join on StepFunction Map Steps with failures

json - 选择状态不指向下一个状态 - AWS

java - AWS Lambda 与 Java Spring

jwt - 使用 AWS API Gateway 时是否可以从自定义 Lambda 授权方传回 JWT 负载?

python - Boto3、AWS Lambda - 每次调用的结果复合

amazon-web-services - 假定的 IAM 角色无权对资源执行:states:GetActivityTask:arn:aws:states::012345678910:role/