如何为使用 CloudFormation 模板创建的 AWS Lambda 函数添​​加触发器?

tra*_*t0r 7 amazon-s3 amazon-web-services aws-lambda

我正在尝试根据以下示例从 CloudFormation 模板创建 lambda 函数:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/quickref-lambda.html

从这个链接可以看出:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html

无法为 lambda 函数添​​加触发器(如 S3 上传触发器)。

是否有解决方法可以在编写模板时指定触发器?

jar*_*mod 0

您需要将NotificationConfiguration添加到S3存储桶定义中。但是,这将导致循环依赖,其中 S3 存储桶引用 Lambda 函数,而 Lambda 函数引用 S3 存储桶。

为了避免这种循环依赖,请在不指定通知配置的情况下创建所有资源(包括 S3 存储桶和 Lambda 函数) 。然后,在创建堆栈后,使用通知配置更新模板,然后更新堆栈。