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.
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 ConfigurationThe 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
}
This resource supports the following arguments:
name
- (Optional, Forces new resource) The name of the DB parameter group. If omitted, Terraform will assign a random, unique name.name_prefix
- (Optional, Forces new resource) Creates a unique name beginning with the specified prefix. Conflicts with name
.family
- (Required, Forces new resource) The family of the DB parameter group.description
- (Optional, Forces new resource) The description of the DB parameter group. Defaults to "Managed by Terraform".parameter
- (Optional) The DB parameters to apply. See parameter
Block below for more details. Note that parameters may differ from a family to an other. Full list of all parameters can be discovered via aws rds describe-db-parameters
after initial creation of the group.tags
- (Optional) A map of tags to assign to the resource. If configured with a provider default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.parameter
BlockThe parameter
blocks support the following arguments:
name
- (Required) The name of the DB parameter.value
- (Required) The value of the DB parameter.apply_method
- (Optional) "immediate" (default), or "pending-reboot". Some
engines can't apply some parameters without a reboot, and you will need to
specify "pending-reboot" here.This resource exports the following attributes in addition to the arguments above:
id
- The db parameter group name.arn
- The ARN of the db parameter group.tags_all
- A map of tags assigned to the resource, including those inherited from the provider default_tags
configuration block.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