模板错误:Fn::GetAtt 的实例引用未定义的资源 EventHandlerLambdaFunction

sta*_*eve 9 resources amazon-web-services aws-cloudformation serverless

谁能帮我找出问题所在吗?

我正在我的无服务器 yml 中导入此 cloudformation 资源。这是我的功能配置:

Resources:
  eventHandler:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: eventLambda/
      Handler: dist/app.eventHandler
      Runtime: nodejs12.x
      FunctionName: eventHandler
Run Code Online (Sandbox Code Playgroud)

这是我引用它的地方:

eventSourceRule:
    Type: 'AWS::Events::Rule'
    Properties:
      Name: eventSourceRule
      EventBusName: omnibus-${self:custom.stage}
      EventPattern: |
        {
          "source": ["op.api"]
        }
      RetryPolicy:
        MaximumRetryAttempts: 5
        MaximumEventAgeInSeconds: 900
      DeadLetterConfig:
        Type: SQS
        QueueLogicalId: EBRuleDLQ
      Targets:
        - Arn:
            Fn::GetAtt:
              - 'EventHandlerLambdaFunction'
              - 'Arn'
          Id: 'eventSourceRule'
Run Code Online (Sandbox Code Playgroud)

请注意,我已经尝试过了eventHandlerEventHandler但这些都不起作用。这就是我收到的错误:

The CloudFormation template is invalid: Template error: instance of Fn::GetAtt references undefined resource EventHandlerLambdaFunction
Run Code Online (Sandbox Code Playgroud)

Ani*_*rni 7

我认为你必须添加 资源的逻辑名称。
替换EventHandlerLambdaFunction为实际资源名称eventHandler
您没有使用已定义的 Lambda 资源的逻辑名称。


您可以尝试使用简单的 YAML 语法:

Targets:
  - Arn: !GetAtt eventHandler.Arn
Run Code Online (Sandbox Code Playgroud)

参考:Fn::GetAtt AWS 文档