TerraShelf

Catalog · Data · v1.0.0

rds-postgres

Encrypted Postgres with security-group ingress and a Secrets Manager master password.

Tests passed 6 of 6. Failed 0.

Inputs

NameTypeRequiredDescription
allocated_storagenumbernoAllocated storage in gibibytes.
allowed_security_group_idslist(string)yesSecurity groups allowed to connect on the Postgres port. CIDR blocks, including 0.0.0.0/0, are not accepted.
backup_retention_daysnumbernoAutomated backup retention in days.
database_namestringnoInitial database name.
engine_versionstringnoPostgres engine version.
envstringyesEnvironment name. prod turns on deletion protection and requires a final snapshot. dev and staging do not.
instance_classstringnoRDS instance class.
master_usernamestringnoMaster username. The password is not set in this module. RDS stores it in Secrets Manager.
monitoring_intervalnumbernoEnhanced monitoring interval in seconds. Zero disables it.
multi_azboolnoEnable a Multi-AZ deployment.
namestringyesDatabase identifier, subnet group name, and name prefix. Do not encode an environment into this name; use env.
parameter_group_familystringnoParameter group family. Must match engine_version.
performance_insightsboolnoEnable Performance Insights.
performance_insights_kms_key_arnstringnoOptional customer managed key ARN for Performance Insights. Null uses the AWS managed key when Performance Insights is on.
portnumbernoPostgres port.
subnet_idslist(string)yesPrivate subnet ids for the DB subnet group. At least two.
tagsmap(string)noExtra tags merged onto every taggable resource. ManagedBy and Module are always set by the module.
vpc_idstringyesVPC that holds the database security group.

Outputs

NameDescription
backup_retention_daysAutomated backup retention in days.
caller_contextAccount, partition, and region resolved from data sources.
deletion_protectionWhether deletion protection is on. True only when env is prod.
endpointRDS endpoint address.
force_sslValue of rds.force_ssl in the parameter group.
identifierRDS instance identifier.
ingress_cidr_blocksCIDR blocks on the database security group. This module always leaves the list empty.
ingress_security_group_idsSecurity group ids allowed to reach Postgres.
manage_master_user_passwordTrue when RDS stores the master password in Secrets Manager. This module never sets a password.
performance_insights_enabledWhether Performance Insights is enabled.
portPostgres port.
publicly_accessibleWhether the instance is publicly accessible.
security_group_idSecurity group id attached to the instance.
skip_final_snapshotWhether a final snapshot is skipped. False when env is prod.
storage_encryptedWhether storage encryption is on.
tag_auditTags on every taggable resource this module creates.

Example

The caller supplies the region. This example does not embed an account id.

module "db" {
  source = "../.."

  name                       = "app-db"
  env                        = "dev"
  vpc_id                     = "vpc-0abc1234def56789"
  subnet_ids                 = ["subnet-0abc1234def56789", "subnet-0abc1234def56780"]
  allowed_security_group_ids = ["sg-0abc1234def56789"]
  tags = {
    Example = "basic"
  }
}

Tests

Mock plan excerpt

mocked provider: ARNs and IDs are simulated. This excerpt is from terraform test with a mocked provider, not a live plan.

mocked provider: ARNs and IDs are simulated. This is terraform test -verbose, not a live plan.

tests\rds-postgres.tftest.hcl... in progress
  run "dev_locked_down"... pass

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_db_instance.this will be created
  + resource "aws_db_instance" "this" {
      + address                               = (known after apply)
      + allocated_storage                     = 20
      + apply_immediately                     = false
      + arn                                   = (known after apply)
      + auto_minor_version_upgrade            = true
      + availability_zone                     = (known after apply)
      + backup_retention_period               = 7
      + backup_target                         = (known after apply)
      + backup_window                         = "03:00-04:00"
      + ca_cert_identifier                    = (known after apply)
      + character_set_name                    = (known after apply)
      + copy_tags_to_snapshot                 = true
      + db_name                               = "appdb"
      + db_subnet_group_name                  = "app-pg"
      + deletion_protection                   = false
      + domain_fqdn                           = (known after apply)
      + enabled_cloudwatch_logs_exports       = [
          + "postgresql",
          + "upgrade",
        ]
      + endpoint                              = (known after apply)
      + engine                                = "postgres"
      + engine_lifecycle_support              = (known after apply)
      + engine_version                        = "16.4"
      + engine_version_actual                 = (known after apply)
      + hosted_zone_id                        = (known after apply)
      + iam_database_authentication_enabled   = true

Resources

graphviz dot was not installed. The figure is a python-hcl2 resource list.

Resource list for rds-postgres

Changelog

Changelog

All notable changes to this module are documented in this file.

The format is based on Keep a Changelog, and this module uses Semantic Versioning.

[1.0.0] - 2026-10-03

Added

Billable item names

Names only. This page does not quote a price. Example amounts, including a budget limit, are placeholders and are not recommendations. GuardDuty and Security Hub stay off unless a module switch is set, because those services are billable.