未在 AWS SAM Lambda 函数上创建 SQS 事件源

SQS Event Source not being created on AWS SAM Lambda function

请帮忙。我在 AWS SAM YAML 文件中定义了一个 AWS Lambda,该文件已部署但未与其一起创建事件源。拜托,我可能在这里遗漏了什么?我已经尝试将某些权限添加到 Lambda 的 SQS 和 SQSPoller 权限,但这没有用。我已经在这上面花了太多时间了。非常感谢

  BootstrapFunction:
    Type: AWS::Serverless::Function
    Properties:
      PackageType: Zip
      FunctionName: !Sub '${appName}-${env}-${sourceCodeName}-bootstrap'
      CodeUri:
        Bucket: !Ref sourceCodeBucketName
        Key: !Sub '${sourceCodeName}/${sourceCodeTag}.zip'
      Description: Bootstrap the Project State Machine
      Handler: build/src/bootstrapHandler.bootstrap
      Policies:
        - AWSLambdaExecute
      Runtime: nodejs14.x
      MemorySize: 1024
      Timeout: 30
      Environment:
        Variables:
          LOG_LEVEL: 'debug'
          REGION: !Ref AWS::Region
      VpcConfig:
        SecurityGroupIds:
          - !Ref clusterSecurityGroupId
        SubnetIds: !Ref subnetIds
    Events:
      BootstrapFunctionSQSEvent:
        Type: SQS
        Properties:
          Queue: !GetAtt TaskQueue.Arn
          BatchSize: 1
          Enabled: true

TaskQueue:
    Type: AWS::SQS::Queue
    Properties:
      QueueName: !Sub '${appName}-${env}-${sourceCodeName}-task'
      MessageRetentionPeriod: !Ref sqsMessageRetentionSeconds
      RedrivePolicy:
        deadLetterTargetArn: !GetAtt TaskDlQueue.Arn
        maxReceiveCount: !Ref maxReceiveCountForDlq

  TaskQueueWritePolicy:
    Type: AWS::IAM::ManagedPolicy
    Properties:
      ManagedPolicyName: !Sub '${appName}-${env}-${sourceCodeName}-task-queue-write-policy'
      PolicyDocument:
        Version: 2012-10-17
        Statement:
          - Sid: AllowQueueAccess
            Effect: Allow
            Action:
              - sqs:SendMessage
              - sqs:ChangeMessageVisibility
            Resource:
              - !GetAtt TaskQueue.Arn

  TaskQueueReadPolicy:
    Type: AWS::IAM::ManagedPolicy
    Properties:
      ManagedPolicyName: !Sub '${appName}-${env}-${sourceCodeName}-task-queue-read-policy'
      PolicyDocument:
        Version: 2012-10-17
        Statement:
          - Sid: AllowQueueAccess
            Effect: Allow
            Action:
              - sqs:ChangeMessageVisibility
              - sqs:ReceiveMessage
              - sqs:DeleteMessage
            Resource:
              - !GetAtt TaskQueue.Arn

Events 应在 BootstrapFunction 资源中的 Properties 下方缩进:

  BootstrapFunction:
    Type: AWS::Serverless::Function
    Properties:
      PackageType: Zip
      FunctionName: !Sub '${appName}-${env}-${sourceCodeName}-bootstrap'
      CodeUri:
        Bucket: !Ref sourceCodeBucketName
        Key: !Sub '${sourceCodeName}/${sourceCodeTag}.zip'
      Description: Bootstrap the Project State Machine
      Handler: build/src/bootstrapHandler.bootstrap
      Policies:
        - AWSLambdaExecute
      Runtime: nodejs14.x
      MemorySize: 1024
      Timeout: 30
      Environment:
        Variables:
          LOG_LEVEL: 'debug'
          REGION: !Ref AWS::Region
      VpcConfig:
        SecurityGroupIds:
          - !Ref clusterSecurityGroupId
        SubnetIds: !Ref subnetIds
      Events:
        BootstrapFunctionSQSEvent:
          Type: SQS
          Properties:
            Queue: !GetAtt TaskQueue.Arn
            BatchSize: 1
            Enabled: true