Skip to main content
A DB parameter group acts as a container for engine configuration values that apply to all instances associated with that group. Common use cases include setting character encodings, adjusting connection limits, tuning autovacuum behavior in PostgreSQL, and enabling slow query logs. By default, this module creates a parameter group automatically. You can also reference an existing parameter group or fall back to the AWS-managed default.

Variables

VariableDefaultDescription
create_db_parameter_grouptrueWhether to create a parameter group. Set to false to use an existing one or the AWS default.
parameter_group_namenullName of the parameter group to create or reference. Defaults to the instance identifier.
parameter_group_use_name_prefixtrueWhen true, appends a unique suffix to the name to avoid conflicts. Set to false to use the exact name.
familynullThe parameter group family. Required when creating a new parameter group (e.g., mysql8.0, postgres17).
parametersnullList of parameter objects to apply.
parameter_group_descriptionnullDescription for the parameter group.
parameter_group_skip_destroynullWhen true, removes the parameter group from state on destroy without deleting it from AWS.

The parameters object

Each entry in parameters accepts the following fields, as defined in variables.tf:
parameters = [
  {
    name         = string           # Parameter name (required)
    value        = string           # Parameter value (required)
    apply_method = optional(string) # "immediate" or "pending-reboot" (optional)
  }
]
When apply_method is omitted, AWS uses the default for that parameter (usually immediate for dynamic parameters and pending-reboot for static ones).

Usage patterns

The module creates a parameter group by default. Provide family and parameters to configure it:
module "db" {
  source = "terraform-aws-modules/rds/aws"

  identifier = "demodb"

  engine            = "mysql"
  engine_version    = "8.0"
  instance_class    = "db.t4g.large"
  allocated_storage = 20

  # Parameter group
  family = "mysql8.0"

  parameters = [
    {
      name  = "character_set_client"
      value = "utf8mb4"
    },
    {
      name  = "character_set_server"
      value = "utf8mb4"
    }
  ]

  # ... other required variables
}
To use an exact name instead of a generated prefix:
parameter_group_name            = "prod-instance-mysql-8.0"
parameter_group_use_name_prefix = false
To use a prefix (the default):
parameter_group_name = "prod-instance-mysql-8.0"
# parameter_group_use_name_prefix = true (default)
AWS will create a parameter group named something like prod-instance-mysql-8.0-20240101120000000000000001.

PostgreSQL example

For PostgreSQL, the family format is postgres{major_version}:
module "db" {
  source = "terraform-aws-modules/rds/aws"

  identifier = "complete-postgresql"

  engine         = "postgres"
  engine_version = "17"
  family         = "postgres17"
  instance_class = "db.t4g.large"

  parameters = [
    {
      name  = "autovacuum"
      value = 1
    },
    {
      name  = "client_encoding"
      value = "utf8"
    }
  ]

  # ... other required variables
}

Blue/green deployment parameter example

Some parameters require apply_method = "pending-reboot". For example, enabling logical replication in PostgreSQL for blue/green deployments:
parameters = [
  {
    name         = "rds.logical_replication"
    value        = 1
    apply_method = "pending-reboot"
  }
]

Family naming reference

EngineFamily patternExample
MySQLmysql{major}.{minor}mysql8.0, mysql8.4
MariaDBmariadb{major}.{minor}mariadb10.6
PostgreSQLpostgres{major}postgres14, postgres17
Oracle EEoracle-ee-{major}oracle-ee-19
Oracle SE2oracle-se2-{major}oracle-se2-19
SQL Server EXsqlserver-ex-{major}.{minor}sqlserver-ex-15.0
SQL Server SEsqlserver-se-{major}.{minor}sqlserver-se-15.0
Set parameter_group_skip_destroy = true in production to prevent accidental deletion of a parameter group that is associated with multiple instances. The parameter group will be removed from Terraform state but remain in AWS.

Build docs developers (and LLMs) love