title: How to automatic switch to new parameter group in AWS' RDS with Terraform?
body: <p>Set a new parameter group for RDS, its plan is</p>
  <pre><code>An execution plan has been generated and is shown below.
  Resource actions are indicated with the following symbols:
  + create
  ~ update in-place
  - destroy
  
  Terraform will perform the following actions:
  
    # aws_db_parameter_group.this will be destroyed
  - resource &quot;aws_db_parameter_group&quot; &quot;this&quot; {
        - arn         = &quot;arn:aws:rds:us-east-1:12301923210921:pg:db-aurora-parameter-group&quot; -&gt; null
        - description = &quot;Parameter group for db Aurora Postgres instance&quot; -&gt; null
        - family      = &quot;aurora-postgresql12&quot; -&gt; null
        - id          = &quot;db-aurora-parameter-group&quot; -&gt; null
        - name        = &quot;db-aurora-parameter-group&quot; -&gt; null
        - tags        = {
            - &quot;Application&quot; = &quot;myapp db&quot;
            - &quot;Project&quot;     = &quot;myproj&quot;
            - &quot;Terraform&quot;   = &quot;true&quot;
          } -&gt; null
      }
  
    # aws_rds_cluster.this will be updated in-place
  ~ resource &quot;aws_rds_cluster&quot; &quot;this&quot; {
        ~ db_cluster_parameter_group_name     = &quot;db-aurora-cluster-parameter-group&quot; -&gt; (known after apply)
          id                                  = &quot;db&quot;
          tags                                = {
              &quot;Application&quot; = &quot;myapp db&quot;
              &quot;Project&quot;     = &quot;myproj&quot;
              &quot;Terraform&quot;   = &quot;true&quot;
          }
          # (31 unchanged attributes hidden)
      }
  
    # aws_rds_cluster_instance.this will be updated in-place
  ~ resource &quot;aws_rds_cluster_instance&quot; &quot;this&quot; {
        ~ db_parameter_group_name         = &quot;db-aurora-parameter-group&quot; -&gt; (known after apply)
          id                              = &quot;instance001&quot;
          tags                            = {
              &quot;Application&quot; = &quot;myapp db&quot;
              &quot;Project&quot;     = &quot;myproj&quot;
              &quot;Terraform&quot;   = &quot;true&quot;
          }
          # (25 unchanged attributes hidden)
      }
  
    # aws_rds_cluster_parameter_group.this will be destroyed
  - resource &quot;aws_rds_cluster_parameter_group&quot; &quot;this&quot; {
        - arn         = &quot;arn:aws:rds:us-east-1:12301923210921:cluster-pg:db-aurora-cluster-parameter-group&quot; -&gt; null
        - description = &quot;Cluster parameter group for db Aurora Postgres instance&quot; -&gt; null
        - family      = &quot;aurora-postgresql12&quot; -&gt; null
        - id          = &quot;db-aurora-cluster-parameter-group&quot; -&gt; null
        - name        = &quot;db-aurora-cluster-parameter-group&quot; -&gt; null
        - tags        = {
            - &quot;Application&quot; = &quot;myapp db&quot;
            - &quot;Project&quot;     = &quot;myproj&quot;
            - &quot;Terraform&quot;   = &quot;true&quot;
          } -&gt; null
  
        - parameter {
            - apply_method = &quot;immediate&quot; -&gt; null
            - name         = &quot;log_lock_waits&quot; -&gt; null
            - value        = &quot;1&quot; -&gt; null
          }
        - parameter {
            - apply_method = &quot;immediate&quot; -&gt; null
            - name         = &quot;log_temp_files&quot; -&gt; null
            - value        = &quot;0&quot; -&gt; null
          }
        - parameter {
            - apply_method = &quot;immediate&quot; -&gt; null
            - name         = &quot;pgaudit.log_catalog&quot; -&gt; null
            - value        = &quot;0&quot; -&gt; null
          }
      }
  
    # module.aws_db_parameter_group.aws_db_parameter_group.this will be created
  + resource &quot;aws_db_parameter_group&quot; &quot;this&quot; {
        + arn         = (known after apply)
        + description = &quot;Parameter group for db Aurora Postgres instance&quot;
        + family      = &quot;aurora-postgresql12&quot;
        + id          = (known after apply)
        + name        = (known after apply)
        + name_prefix = &quot;db-&quot;
        + tags        = {
            + &quot;Application&quot; = &quot;myapp db&quot;
            + &quot;Name&quot;        = &quot;db&quot;
            + &quot;Project&quot;     = &quot;myproj&quot;
            + &quot;Terraform&quot;   = &quot;true&quot;
          }
      }
  
    # module.aws_db_parameter_group.aws_rds_cluster_parameter_group.this will be created
  + resource &quot;aws_rds_cluster_parameter_group&quot; &quot;this&quot; {
        + arn         = (known after apply)
        + description = &quot;Cluster parameter group for db Aurora Postgres instance&quot;
        + family      = &quot;aurora-postgresql12&quot;
        + id          = (known after apply)
        + name        = (known after apply)
        + name_prefix = &quot;db-&quot;
        + tags        = {
            + &quot;Application&quot; = &quot;myapp db&quot;
            + &quot;Name&quot;        = &quot;db&quot;
            + &quot;Project&quot;     = &quot;myproj&quot;
            + &quot;Terraform&quot;   = &quot;true&quot;
          }
  
        + parameter {
            + apply_method = &quot;immediate&quot;
            + name         = &quot;log_lock_waits&quot;
            + value        = &quot;1&quot;
          }
        + parameter {
            + apply_method = &quot;immediate&quot;
            + name         = &quot;log_temp_files&quot;
            + value        = &quot;0&quot;
          }
        + parameter {
            + apply_method = &quot;pending-reboot&quot;
            + name         = &quot;pgaudit.log_catalog&quot;
            + value        = &quot;0&quot;
          }
      }
  
  Plan: 2 to add, 2 to change, 2 to destroy.
  </code></pre>
  <p>After apply it by terraform, it will delete the old parameter group but can't due to the AWS rule.
  If switch to the new group in AWS manually, it's possible.</p>
  <p>Is there a way to use terraform do the automation? If want to add a new parameter group in the future, what's the best practice?</p>