如何使用 terraform 解决 AWS 中的 LimitExceeded 问题?

Mia*_*ian 6 amazon-web-services amazon-iam terraform

当我运行 terraform apply 时,出现以下错误:

running "...terraform apply" in ".../aws-config": exit status 1
module.aws_config_role.aws_iam_policy.default: Modifying... [id=arn:aws:iam::10391031030:policy/my-aws-config-role]

Error: Error updating IAM policy arn:aws:iam::10391031030:policy/my-aws-config-role: LimitExceeded: Cannot exceed quota for PolicySize: 6144
    status code: 409, request id: 313b0l20-a29d-0121-la32-01210d0103c01
Run Code Online (Sandbox Code Playgroud)

事实上这个任务会更新IAM策略并添加许多新项目,从terraform计划中得知:

~ update in-place

Terraform will perform the following actions:

  # module.aws_config_role.aws_iam_policy.default will be updated in-place
~ resource "aws_iam_policy" "default" {
        arn    = "arn:aws:iam::10391031030:policy/my-aws-config-role"
        id     = "arn:aws:iam::10391031030:policy/my-aws-config-role"
        name   = "my-aws-config-role"
        path   = "/"
      ~ policy = jsonencode(
          ~ {
              ~ Statement = [
                  ~ {
                      ~ Action   = [
                            "..." // old
                            "..." // old
                            "..." // old
                          + "..." // new
                          + "..." // new
                          + "..." // new
                          + "..." // new
                          + "..." // new
                          ...

 Plan: 0 to add, 1 to change, 0 to destroy.
Run Code Online (Sandbox Code Playgroud)

在 aws 提供商版本升级后,得到了此更改。如何避免呢?忽略此任务还是可以扩展 AWS 的 plicy 大小?

Mar*_*cin 7

托管策略的字符限制6144来自 AWS,而不是 TF。因此,您必须从 AWS 的角度而不是 TF 的角度来修复/解决它。

您可以遵循AWS 官方建议: