Skip to main content
The db_option_group submodule creates an aws_db_option_group that can enable additional features for supported RDS engines such as MySQL, Oracle, Microsoft SQL Server, and MariaDB.
Option groups are not applicable to PostgreSQL. Do not set create_db_option_group = true or reference this submodule for PostgreSQL DB instances. PostgreSQL manages engine features through parameter groups instead.

Source

./modules/db_option_group

Usage

Use this submodule standalone to manage an option group independently of the DB instance lifecycle:
module "db_option_group" {
  source  = "terraform-aws-modules/rds/aws//modules/db_option_group"
  version = "~> 7.0"

  name                     = "mysql80-audit"
  use_name_prefix          = false
  option_group_description = "MySQL 8.0 option group with audit plugin"
  engine_name              = "mysql"
  major_engine_version     = "8.0"

  options = [
    {
      option_name = "MARIADB_AUDIT_PLUGIN"
      option_settings = [
        {
          name  = "SERVER_AUDIT_EVENTS"
          value = "CONNECT,QUERY"
        },
        {
          name  = "SERVER_AUDIT_FILE_ROTATIONS"
          value = "10"
        },
      ]
    },
  ]

  timeouts = {
    delete = "15m"
  }

  tags = {
    Environment = "production"
  }
}
Then reference the output in a DB instance:
module "db" {
  source  = "terraform-aws-modules/rds/aws"
  version = "~> 7.0"

  identifier             = "mydb"
  engine                 = "mysql"
  create_db_option_group = false
  option_group_name      = module.db_option_group.db_option_group_id

  # ... other variables
}

Input variables

create
bool
Whether to create the option group resource.Default: true
name
string
The name of the option group. When use_name_prefix is true, this is used as a prefix.Default: ""
use_name_prefix
bool
Determines whether to use name as-is or create a unique name beginning with name as the prefix.Default: true
option_group_description
string
The description of the option group.Default: null
engine_name
string
The name of the engine the option group should be associated with (e.g. mysql, oracle-se2, sqlserver-ex, mariadb).Default: null
major_engine_version
string
The major version of the engine the option group should be associated with (e.g. 8.0, 19, 15.00).Default: null
options
list(object)
A list of options to enable in the option group.Default: null
skip_destroy
bool
Set to true to prevent the option group from being deleted at destroy time. The resource is instead just removed from Terraform state. Useful when active DB instances are associated with this option group.Default: null
timeouts
object
Maximum timeout for deletion of the aws_db_option_group resource.Default: null
region
string
Region where the option group will be managed. Defaults to the region set in the provider configuration.Default: null
tags
map(string)
A mapping of tags to assign to the option group resource.Default: {}

Outputs

db_option_group_id
string
The name (ID) of the DB option group. Pass this to the option_group_name input of a DB instance.
db_option_group_arn
string
The ARN of the DB option group.

Build docs developers (and LLMs) love