我按照此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
答案 0 :(得分:1)
要避免此循环依赖关系,请单独创建S3存储桶和Lambda函数,然后使用S3 notification configuration更新堆栈。
答案 1 :(得分:0)
我得到了循环依赖性错误,结果发现它是我从CloudFormation模板上的资源引用的缺少参数!。