Link Search Menu Expand Document

postgresql_clusters

Description

This Provose configuration sets up AWS Aurora PostgreSQL clusters.

Examples

resource "random_password" "pg1_password" {
  # AWS RDS passwords must be between 8 and 41 characters
  length = 41
  # This is a list of special characters that can be included in the
  # password. This lits omits characters that often need to be
  # escaped.
  override_special = "()-_=+[]{}<>?"
}

resource "random_password" "bigpg_password" {
  length           = 41
  override_special = "()-_=+[]{}<>?"
}

module "myproject" {
  source = "github.com/provose/provose?ref=v2.0.0"
  provose_config = {
    authentication = {
      aws = {
        region = "us-east-1"
      }
    }
    name                 = "myproject"
    internal_root_domain = "example-internal.com"
    internal_subdomain   = "production"
  }
  postgresql_clusters = {
    # This creates an AWS Aurora PostgreSQL cluster available
    # at the host pg1.production.example-internal.com.
    # This host is only available within the VPC.
    pg1 = {
      engine_version = "11.6"
      database_name  = "exampledb"
      password       = random_password.pg1_password.result
      instances = {
        instance_type  = "db.r5.large"
        instance_count = 1
      }
    }
    # This creates a cluster at bigpg.production.example-internal.com.
    # This host is only available within the VPC.
    bigpg = {
      engine_version = "11.6"
      database_name  = "exampledb"
      password       = random_password.bigpg_password.result
      instances = {
        instance_type  = "db.t3.medium"
        instance_count = 3
      }
    }
  }
}

Inputs

  • instancesRequired. Settings for the AWS RDS instances running the PostgreSQL cluster.

    • instance_typeRequired. The database instance type, like "db.r5.large". The accepted database instance types for AWS Aurora PostgreSQL can be found here on the AWS website.

    • instance_countRequired. The number of database instances in the cluster. Provose requires that all database instances be of the same instance_type.

  • engine_versionRequired. This is the version of the AWS Aurora PostgreSQL cluster. The currently-supported engine versions can be found here on the AWS website.

  • database_nameRequired. The name of the initial database created by AWS RDS. You can create additional databases by logging into the instance with "root" as the username and the password you set below.

  • passwordRequired. The password for the database root user.

  • snapshot_identifierOptional. If set, this is the ARN of the RDS snapshot to create this instance from. If not set, Provose provisions a blank database.

  • apply_immediatelyOptional Defaults to true, which means that configuration changes to the database are applied immediately. If set to false, any changes to the database configuration made through Provose or Terraform will be applied during the database’s next maintenance window. Be careful that making configuration changes can result in a database outage.

  • deletion_protectionOptional. Defaults to true, which is the opposite of the typical Terraform configuration. When set to true, the database cannot be deleted. Set to false if you are okay with deleting this database when running terraform destroy or other commands.

Outputs

  • postgresql_clusters.aws_db_subnet_group.postgresql – A mapping of aws_db_subnet_group resources that describe the subnets for every cluster specified. Provose defaults to setting all of the subnets available in the VPC.

  • postgresql_clusters.aws_security_group.postgresql – An aws_security_group resource that governs access to the PostgreSQL clusters. By default, the database is open to connection from anywhere within the VPC. The database is not accessible to the public Internet.

  • postgresql_clusters.aws_rds_cluster.postgresql – A mapping of aws_rds_cluster resources for every cluster specified.

  • postgresql_clusters.aws_rds_cluster_instance.postgresql – A mapping of aws_rds_cluster_instance resources–of every instance in every Aurora PostgreSQL cluster created by Provose.

  • postgresql.aws_route53_record.postgresql – A mapping of aws_route53_record resources that give a friendly DNS name for every Aurora PostgreSQL cluster specified.

  • postgresql.aws_route53_record.postgresql__readonly – A mapping of aws_route53_record resources that give a friendly DNS name for the readonly endpoint for every Aurora postgresql cluster specified.

Supported engine versions

You can check which versions of AWS Aurora PostgreSQl are available by running the following AWS CLI comamnd and looking for the EngineVersion keys:

aws rds describe-db-engine-versions --engine aurora-postgresql

Currently, the available versions are, in order from newest to oldest:

  • "11.7"
  • "11.6"
  • "11.4"
  • "10.12"
  • "10.11"
  • "10.7"
  • "10.7"
  • "10.6"
  • "10.5"
  • "10.4"
  • "9.6.17"
  • "9.6.16"
  • "9.6.12"
  • "9.6.11"
  • "9.6.9"
  • "9.6.8"
  • "9.6.6"
  • "9.6.3"