Skip to content

Resource: awsDbParameterGroup

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 awsDbParameterGroup in use, follow the Manage AWS RDS Instances tutorial on HashiCorp Learn.

\~> NOTE: After applying your changes, you may encounter a perpetual diff in your Terraform plan output for a parameter whose value remains unchanged but whose applyMethod is changing (e.g., from immediate to pendingReboot, or pendingReboot to immediate). If only the apply method of a parameter is changing, the AWS API will not register this change. To change the applyMethod of a parameter, its value must also change.

Example Usage

Basic Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.dbParameterGroup.DbParameterGroup(this, "default", {
  family: "mysql5.6",
  name: "rds-pg",
  parameter: [
    {
      name: "character_set_server",
      value: "utf8",
    },
    {
      name: "character_set_client",
      value: "utf8",
    },
  ],
});

createBeforeDestroy Lifecycle Configuration

The createBeforeDestroy 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.

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsDbParameterGroupExample = new aws.dbParameterGroup.DbParameterGroup(
  this,
  "example",
  {
    family: "postgres13",
    name: "my-pg",
    parameter: [
      {
        name: "log_connections",
        value: "1",
      },
    ],
  }
);
awsDbParameterGroupExample.addOverride("lifecycle", [
  {
    create_before_destroy: true,
  },
]);
const awsDbInstanceExample = new aws.dbInstance.DbInstance(this, "example_1", {
  applyImmediately: true,
  parameterGroupName: awsDbParameterGroupExample.name,
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsDbInstanceExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

  • name - (Optional, Forces new resource) The name of the DB parameter group. If omitted, Terraform will assign a random, unique name.
  • namePrefix - (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) A list of DB parameters to apply. Note that parameters may differ from a family to an other. Full list of all parameters can be discovered via awsRdsDescribeDbParameters after initial creation of the group.
  • tags - (Optional) A map of tags to assign to the resource. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

Parameter blocks support the following:

  • name - (Required) The name of the DB parameter.
  • value - (Required) The value of the DB parameter.
  • applyMethod - (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.

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • id - The db parameter group name.
  • arn - The ARN of the db parameter group.
  • tagsAll - A map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.

Import

DB Parameter groups can be imported using the name, e.g.,

$ terraform import aws_db_parameter_group.rds_pg rds-pg