Cloud 更改rds资源中的db_选项_组时的资源替换

Cloud 更改rds资源中的db_选项_组时的资源替换,cloud,terraform,rds,terraform-provider-aws,infrastructure-as-code,Cloud,Terraform,Rds,Terraform Provider Aws,Infrastructure As Code,我使用Hashicorp提供的Terraform来管理AWS基础设施。某些迁移任务需要重命名多个资源,例如db_option_组 我不知道为什么Terraform仅仅通过重命名db_option_组来表示“强制替换”。在API文档中,它说“description”是一个可选属性,不需要替换 # module.db_instance.aws_db_option_group.db-option-group must be replaced -/+ resource "aws_db_option_

我使用Hashicorp提供的Terraform来管理AWS基础设施。某些迁移任务需要重命名多个资源,例如db_option_组

我不知道为什么Terraform仅仅通过重命名db_option_组来表示“强制替换”。在API文档中,它说“description”是一个可选属性,不需要替换

  # module.db_instance.aws_db_option_group.db-option-group must be replaced
-/+ resource "aws_db_option_group" "db-option-group" {
      ~ arn                      = "arn:aws:rds:eu-central-1:xxxxxxxxxx:xx:xxxxx-xx-xxxx-cc01-sqlserver-se-14-00" -> (known after apply)
        engine_name              = "sqlserver-se"
      ~ id                       = "xxxxxx-xxx-xxxxx-cc01-sqlserver-se-14-00" -> (known after apply)
        major_engine_version     = "14.00"
        name                     = "xxxxxx-xxx-xxxxx-cc01-sqlserver-se-14-00"
      + name_prefix              = (known after apply)
      ~ option_group_description = "xxxxxx-xxx-xxxxx-cc01-sqlserver-se-14-00" -> "Option group for xxxxx-xxx-xxxxx-cc01" # forces replacement
      ~ tags                     = {
          + "Project"        = "xxxxx"
          + "ProjectId"      = "xxxxx"
          + "global.app"     = "xxxxx"
          + "global.cbp"     = "xxxxx"
          + "global.dcs"     = "xxxxx"
          + "global.env"     = "qa"
          + "global.opco"    = "xxxxx"
          + "global.project" = "xxxxx"
        }

是什么导致Terraform表现出这种行为?

如评论中所述,AWS API目前不支持就地更改重命名。您必须登录AWS帐户并手动调整名称。然后您可以将资源导入terraform状态文件

如果可选的
option\u group\u description
参数发生更改,则这可能是一个bug或AWS API需要删除资源并重新添加它。我以前见过其他资源的可选参数。您应该与aws提供商一起创建一个票证,这是肯定的。我创建了一个票证:我回答了这个问题,但您不能修改RDS选项组的描述,因此如果您让Terraform更改它,它将被迫销毁并重新创建。