Search code examples
terraformamazon-rdsterraform-provider-aws

Terraform & RDS Postgres: why isn't pg_repack allowed in shared_preload_libraries?


AWS docs say:

This extension is supported on RDS for PostgreSQL versions 9.6.3 and higher.

Alas, below error is returned when provisioning RDS instance with this parameters:

resource "aws_db_parameter_group" "this" {
  "parameter" {
          name = "shared_preload_libraries"
          value = "pg_stat_statements,auto_explain,pg_repack"
          apply_method = "pending-reboot"
      }
  # ...
}

resource "aws_db_instance" "this" {
  engine_version = "11.12"
  # ...
}

Error: Error modifying DB Parameter Group: InvalidParameterValue: Invalid parameter value: pg_repack for: shared_preload_libraries allowed values are: auto_explain,orafce,pgaudit,pglogical,pg_bigm,pg_hint_plan,pg_prewarm,pg_similarity,pg_stat_statements,pg_transport,plprofiler

The error disappears if pg_repack is removed from the above value list.

Env:

  • terraform 1.3.1
  • hashicorp/aws 4.18.0

Solution

  • Only those extensions listed needed to be installed in RDS via the shared_preload_libraries setting. As per the official documentation on using the pg_repack library in RDS, all you need to do is run CREATE EXTENSION pg_repack; and it will be made available in your RDS instance.