0
votes

I use Terraform by Hashicorp to manage AWS infrastructure. Some migration tasks require renaming of several resources such as the db_option_group.

I have no clue why Terraform says "forces replacement" by just renaming the db_option_group. On the API documentation it says that "description" is an optional attribute and no replacement is required.

  # 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"
        }

What causes Terraform to behave like this?

1
It's possible that this is a bug or AWS API requires deleting the resource and re-adding it if the optional option_group_description argument is changed. I've seen this before for optional arguments for other resources. You should create a ticket with the aws provider to be certain.SomeGuyOnAComputer
I replied on the issue but you can't modify the description of an RDS option group so Terraform is forced to destroy and recreate if you tell it to change it.ydaetskcoR

1 Answers

0
votes

As mentioned in the comments, the AWS API does currently not support the possibility to change renaming in-place. You must log into your AWS Accounts and manually adjust the name. Then you may import the resource into the terraform state file.