【问题标题】:Template error: instance of Fn::GetAtt references undefined resource EventHandlerLambdaFunction模板错误:Fn::GetAtt 的实例引用了未定义的资源 EventHandlerLambdaFunction
【发布时间】:2021-10-25 20:55:21
【问题描述】:

谁能帮我找出问题所在?

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

Resources:
  eventHandler:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: eventLambda/
      Handler: dist/app.eventHandler
      Runtime: nodejs12.x
      FunctionName: eventHandler

这是我引用它的地方:

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'

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

The CloudFormation template is invalid: Template error: instance of Fn::GetAtt references undefined resource EventHandlerLambdaFunction

【问题讨论】:

    标签: amazon-web-services resources amazon-cloudformation serverless


    【解决方案1】:

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


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

    Targets:
      - Arn: !GetAtt eventHandler.Arn
    

    参考:Fn::GetAtt AWS Documentation

    【讨论】:

      猜你喜欢
      • 2017-06-10
      • 1970-01-01
      • 1970-01-01
      • 2021-11-21
      • 2020-08-30
      • 2021-11-12
      • 1970-01-01
      • 2021-08-07
      • 2019-04-26
      相关资源
      最近更新 更多