更改rds资源中的db_option_group时的资源替换

Resource replacement when changing the db_option_group in the rds resource

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

我不知道为什么 Terraform 通过重命名 db_option_group 来显示 "forces replacement"。在 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 状态文件。