Resource: aws_db_parameter_group

Provides an RDS DB parameter group resource. Documentation of the available parameters for various RDS engines can be found at:

Hands-on: For an example of the aws_db_parameter_group in use, follow the Manage AWS RDS Instances tutorial on HashiCorp Learn.

Example Usage

Basic Usage

resource "aws_db_parameter_group" "default" {
  name   = "rds-pg"
  family = "mysql5.6"

  parameter {
    name  = "character_set_server"
    value = "utf8"
  }

  parameter {
    name  = "character_set_client"
    value = "utf8"
  }
}

create_before_destroy Lifecycle Configuration

The create_before_destroy lifecycle configuration is necessary for modifications that force re-creation of an existing, in-use parameter group. This includes common situations like changing the group name or bumping the family version during a major version upgrade. This configuration will prevent destruction of the deposed parameter group while still in use by the database during upgrade.

resource "aws_db_parameter_group" "example" {
  name   = "my-pg"
  family = "postgres13"

  parameter {
    name  = "log_connections"
    value = "1"
  }

  lifecycle {
    create_before_destroy = true
  }
}

resource "aws_db_instance" "example" {
  # other attributes
  parameter_group_name = aws_db_parameter_group.example.name
  apply_immediately    = true
}

Argument Reference

This resource supports the following arguments:

parameter Block

The parameter blocks support the following arguments:

Attribute Reference

This resource exports the following attributes in addition to the arguments above:

Import

In Terraform v1.5.0 and later, use an import block to import DB Parameter groups using the name. For example:

import {
  to = aws_db_parameter_group.rds_pg
  id = "rds-pg"
}

Using terraform import, import DB Parameter groups using the name. For example:

% terraform import aws_db_parameter_group.rds_pg rds-pg