使用 terraform-aws-lambda 模块更新 AWS lambda 策略返回错误“存在根资源,但现在不存在”

问题描述

我使用 https://github.com/terraform-aws-modules/terraform-aws-lambda/ 创建一个 AWS Lambda。我正在更改块,如下所示:

WAS

  attach_policy = true
  policy        = aws_iam_policy.allow_ssm_read.arn
  
NOW

attach_policies = true
  policies = [
    aws_iam_policy.allow_ssm_read.arn,"arn:aws:iam::aws:policy/CloudWatchLambdaInsightsExecutionRolePolicy"
  ]
  number_of_policies = 2

我得到了一个行为,当我第一次运行 terraform 时,我得到:

Error: Provider produced inconsistent result after apply

When applying changes to
module.<my-module>.module.lambda.aws_iam_role_policy_attachment.additional_many[0],provider "registry.terraform.io/hashicorp/aws" produced an unexpected new
value: Root resource was present,but now absent.

This is a bug in the provider,which should be reported in the provider's own
issue tracker.

然而,第二次运行添加了与 SSM 相关的策略(最初使用的)并且没有产生错误。

有什么可以改进的,所以我在第一次运行时不会出错?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)