删除 AWS Amplify 函数 - 无法删除资源,因为它依赖于另一个资源

Sah*_*sha 5 amazon-web-services aws-lambda aws-amplify

我在我的 AWS Amplify 项目中添加了 S3 lambda 触发器。但是,当我尝试使用 删除该 lambda 触发器时amplify remove function,它显示以下错误。

Resource cannot be removed because it has a dependency on another resource
Dependency: S3 - s3xxxxxxxx
An error occurred when removing the resources from the local directory
Run Code Online (Sandbox Code Playgroud)

AWS Amplify 删除函数错误

AWS Amplify 文档没有删除 lambda 函数的明确指南。那么,如何在不删除S3资源的情况下删除该功能呢?

Sah*_*sha 6

  1. 由于我在 S3 资源上创建了一个触发器,因此我需要首先通过运行来删除该触发器amplify update storage。然后选择您之前配置的选项。当 Amplify CLI 提示选择选项时,选择Remove the Trigger

在 CLI 中运行 amplify 更新存储

  1. 然后运行amplify push将本地更改与云端同步。

  2. 现在,如果我们amplify remove function再次运行,并选择 S3 触发功能。它将执行而不会出现错误。请记住amplify push最后再执行一次同步并删除该功能。