Amazon web services AWS SAM-资源之间的循环依赖关系错误

Amazon web services AWS SAM-资源之间的循环依赖关系错误,amazon-web-services,amazon-s3,lambda,amazon-cloudformation,amazon-iam,Amazon Web Services,Amazon S3,Lambda,Amazon Cloudformation,Amazon Iam,我随后设置了一个AWS Lambda函数,该函数在上传到S3时被调用,并填充DynamoDB 我正试图实现同样的目标,为此我需要定义一个带有配置信息的template.yaml文件。在使用Cloudformation部署时,我经常遇到此错误- Failed to create the changeset: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state Status: FAILE

我随后设置了一个AWS Lambda函数,该函数在上传到S3时被调用,并填充DynamoDB

我正试图实现同样的目标,为此我需要定义一个带有配置信息的
template.yaml
文件。在使用Cloudformation部署时,我经常遇到此错误-

Failed to create the changeset: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state Status: FAILED. Reason: Circular dependency between resources: [LambdaPerm]
我找不到这方面的很多信息,所以我正在努力调试。导致此错误的原因是什么?如何解决此问题?这是我的模板配置-

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
  Gradebook:
    Type: AWS::Serverless::Function
    Properties:
      FunctionName: LambdaGradebookServerless
      Handler: serverless.LambdaGradebook
      Runtime: java8
      CodeUri: ./target/serverless-0.0.1-SNAPSHOT.jar
      Role: arn:aws:iam::xxxxxxxxxxxx:role/lambda-s3-execution-role
  LambdaPerm:
    Type: AWS::Lambda::Permission
    Properties:
      Action: lambda:InvokeFunction
      FunctionName:
        Ref: Gradebook
      Principal: s3.amazonaws.com
      SourceAccount:
        Ref: AWS::xxxxxxxxxxxx
      SourceArn:
        Fn::Join:
        - ':'
        - - arn
          - aws
          - s3
          - ''
          - ''
          - Ref: gradebookBucket
  gradebookBucket:
    Type: AWS::S3::Bucket
    Properties:
      Bucket: gradebook-lambda
      NotificationConfiguration:
        LambdaConfigurations:
        - Event: s3:ObjectCreated:*
          Function:
            Ref: Gradebook

为了避免这种循环依赖关系,请独立创建S3 bucket和Lambda函数,然后使用更新堆栈。

我得到了循环依赖关系错误,结果发现我从CloudFormation模板上的资源中引用了一个缺少的参数

顺便说一句:你可以使用!参考“AWS::AccountId”,而不是硬编码您的帐户ID。但这不是循环依赖的原因。