AWS SAM - 资源错误之间的循环依赖
AWS SAM - Circular dependency between resources error
我按照此 tutorial 设置了一个 AWS Lambda 函数,该函数在上传到 S3 时调用并填充 DynamoDB。
我正在尝试使用 AWS SAM 实现相同的目的,为此我需要定义一个包含配置信息的 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 存储桶和 Lambda 函数,然后使用 S3 notification configuration.
更新堆栈
我遇到了循环依赖错误,事实证明这是我从 CloudFormation 模板上的资源中引用的缺少参数!
如果有人来搜索这个,我写了一篇博客来解决这个问题。
https://aws.amazon.com/blogs/mt/resolving-circular-dependency-in-provisioning-of-amazon-s3-buckets-with-aws-lambda-event-notifications/
实现方法与 jarmod 在接受的答案中描述的类似。稍后使用 CloudFormation 自定义资源设置事件通知。
我按照此 tutorial 设置了一个 AWS Lambda 函数,该函数在上传到 S3 时调用并填充 DynamoDB。
我正在尝试使用 AWS SAM 实现相同的目的,为此我需要定义一个包含配置信息的 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 存储桶和 Lambda 函数,然后使用 S3 notification configuration.
更新堆栈我遇到了循环依赖错误,事实证明这是我从 CloudFormation 模板上的资源中引用的缺少参数!
如果有人来搜索这个,我写了一篇博客来解决这个问题。 https://aws.amazon.com/blogs/mt/resolving-circular-dependency-in-provisioning-of-amazon-s3-buckets-with-aws-lambda-event-notifications/
实现方法与 jarmod 在接受的答案中描述的类似。稍后使用 CloudFormation 自定义资源设置事件通知。