Terraform provider aws Terraform RDS选项组选项正在使用动态块重新应用相同的更改

Terraform provider aws Terraform RDS选项组选项正在使用动态块重新应用相同的更改,terraform-provider-aws,Terraform Provider Aws,我有一个Terraform RDS代码,我使用动态块,每个块都有,当我进行Terraform规划时,每次都会重新应用选项组选项。谁能帮帮我吗?我认为这是一个错误 有人能帮我吗 main.tf resource "aws_db_option_group" "without_s3_integration" { #count = "${var.enable_s3_integration == false ? 1 : 0}" nam

我有一个Terraform RDS代码,我使用动态块,每个块都有,当我进行Terraform规划时,每次都会重新应用选项组选项。谁能帮帮我吗?我认为这是一个错误

有人能帮我吗

main.tf

resource "aws_db_option_group" "without_s3_integration" {
  #count = "${var.enable_s3_integration == false ? 1 : 0}"

  name                     = lower("${var.db_name}-${formatdate("YYYY-MM-DD-hhmm", timestamp())}-og")
  option_group_description = format("Option group for %s", var.db_name)
  engine_name              = var.engine_name
  major_engine_version     = var.major_engine_version

  option {
    option_name = "Timezone"

    option_settings {
      name  = "TIME_ZONE"
      value = "US/Eastern"
    }
  }

  dynamic "option" {
    #for_each = var.option_group_add_sqlt == false ? [] : [var.option_group_add_sqlt]
    for_each = range(var.option_group_add_sqlt == true ? 1 : 0)

    content {
      option_name = "SQLT"

      option_settings {
        name  = "LICENSE_PACK"
        value = "T"
      }
    }
  }
我不知道它为什么要删除和添加选项。当我在地形应用后进行地形规划时。它不应该做任何改变,因为我没有添加任何额外的东西,为什么terraform总是添加资源并删除它?有没有办法防止这样的事情发生

variable.tf

variable "option_group_add_sqlt"{
  description = "Add SQLT to option group"
  type        = bool
  default     = true
}
variable "option_group_add_utlmail"{
  description = "Add utlmail to option group"
  type        = bool
  default     = true
}
variable "option_group_add_oem"{
  description = "Add oem to option group"
  type        = bool
  default     = false
}
variable "enable_s3_integration"{
  description = "Indicates if S3 integration should be turned on or not"
  type        = bool
  default     = true
}
terraform plan

  # aws_db_option_group.without_s3_integration will be updated in-place
  ~ resource "aws_db_option_group" "without_s3_integration" {
        id                       = "rajtest4-2021-05-13-1621-og"
        name                     = "rajtest4-2021-05-13-1621-og"
        tags                     = {
            "Author" = "Effectual Terraform script"
            "Date"   = "2021-05-13T16:21:54Z"
        }
        # (4 unchanged attributes hidden)

      - option {
          - db_security_group_memberships  = [] -> null
          - option_name                    = "S3_INTEGRATION" -> null
          - port                           = 0 -> null
          - version                        = "1.0" -> null
          - vpc_security_group_memberships = [] -> null
        }
      + option {
          + db_security_group_memberships  = []
          + option_name                    = "S3_INTEGRATION"
          + version                        = "1.0"
          + vpc_security_group_memberships = []
        }
      - option {
          - db_security_group_memberships  = [] -> null
          - option_name                    = "SQLT" -> null
          - port                           = 0 -> null
          - version                        = "2018-07-25.v1" -> null
          - vpc_security_group_memberships = [] -> null

          - option_settings {
              - name  = "LICENSE_PACK" -> null
              - value = "T" -> null
            }
        }
      + option {
          + db_security_group_memberships  = []
          + option_name                    = "SQLT"
          + vpc_security_group_memberships = []

          + option_settings {
              + name  = "LICENSE_PACK"
              + value = "T"
            }
        }
      - option {
          - db_security_group_memberships  = [] -> null
          - option_name                    = "Timezone" -> null
          - port                           = 0 -> null
          - vpc_security_group_memberships = [] -> null

          - option_settings {
              - name  = "TIME_ZONE" -> null
              - value = "US/Eastern" -> null
            }
        }
      + option {
          + db_security_group_memberships  = []
          + option_name                    = "Timezone"
          + vpc_security_group_memberships = []

          + option_settings {
              + name  = "TIME_ZONE"
              + value = "US/Eastern"
            }
        }
      + option {
          + db_security_group_memberships  = []
          + option_name                    = "UTL_MAIL"
          + vpc_security_group_memberships = []
        }
    }

Plan: 0 to add, 2 to change, 0 to destroy.