Skip to main content

Component: aurora-postgres

This component is responsible for provisioning Aurora Postgres RDS clusters. It seeds relevant database information (hostnames, username, password, etc.) into AWS SSM Parameter Store.


Stack Level: Regional

Here's an example for how to use this component.

stacks/catalog/aurora-postgres/defaults.yaml file (base component for all Aurora Postgres clusters with default settings):

type: abstract
enabled: true
name: aurora-postgres
Team: sre
Service: aurora-postgres
cluster_name: shared
deletion_protection: false
storage_encrypted: true
engine: aurora-postgresql
engine_mode: provisioned
# aws rds describe-db-engine-versions --engine aurora-postgresql --query 'DBEngineVersions[].EngineVersion'
engine_version: "13.4"
# engine and cluster family are notoriously hard to find.
# If you know the engine version (example here is "12.4"), use Engine and DBParameterGroupFamily from:
# aws rds describe-db-engine-versions --engine aurora-postgresql --query "DBEngineVersions[]" | \
# jq '.[] | select(.EngineVersion == "12.4") |
# { Engine: .Engine, EngineVersion: .EngineVersion, DBParameterGroupFamily: .DBParameterGroupFamily }'
cluster_family: aurora-postgresql13
# 1 writer, 1 reader
cluster_size: 1
admin_user: postgres
admin_password: "" # generate random password
database_name: postgres
database_port: 5432
instance_type: db.t3.medium
skip_final_snapshot: false
# Enhanced Monitoring
# A boolean flag to enable/disable the creation of the enhanced monitoring IAM role.
# If set to false, the module will not create a new role and will use rds_monitoring_role_arn for enhanced monitoring
enhanced_monitoring_role_enabled: true
# The interval, in seconds, between points when enhanced monitoring metrics are collected for the DB instance.
# To disable collecting Enhanced Monitoring metrics, specify 0. The default is 0. Valid Values: 0, 1, 5, 10, 15, 30, 60
rds_monitoring_interval: 15
# Allow ingress from the following accounts
# If any of tenant, stage, or environment aren't given, this will be taken
- tenant: core
stage: auto

Example (not actual) stacks/uw2-dev.yaml file (override the default settings for the cluster in the dev account, create an additional database and user):

- catalog/aurora-postgres/defaults

component: aurora-postgres
- aurora-postgres/defaults
enabled: true


terraform>= 1.3.0
aws>= 4.9.0
postgresql>= 1.17.1
random>= 2.3


aws>= 4.9.0
random>= 2.3




aws_caller_identity.currentdata source
aws_iam_policy_document.kms_key_rdsdata source
aws_partition.currentdata source
aws_ssm_parameter.passworddata source


additional_databasesAdditional databases to be created with the clusterset(string)[]no
additional_tag_mapAdditional key-value pairs to add to each map in tags_as_list_of_maps. Not added to tags or id.
This is for some rare cases where resources want additional configuration of tags
and therefore take a list of maps with tag key, value, and additional configuration.
admin_passwordPostgres password for the admin userstring""no
admin_userPostgres admin user namestring""no
allow_ingress_from_vpc_accountsList of account contexts to pull VPC ingress CIDR and add to cluster security group.
environment = "ue2",
stage = "auto",
tenant = "core"
environment = optional(string)
stage = optional(string)
tenant = optional(string)
allowed_cidr_blocksList of CIDRs allowed to access the database (in addition to security groups and subnets)list(string)[]no
attributesID element. Additional attributes (e.g. workers or cluster) to add to id,
in the order they appear in the list. New attributes are appended to the
end of the list. The elements of the list are joined by the delimiter
and treated as a single ID element.
autoscaling_enabledWhether to enable cluster autoscalingboolfalseno
autoscaling_max_capacityMaximum number of instances to be maintained by the autoscalernumber5no
autoscaling_min_capacityMinimum number of instances to be maintained by the autoscalernumber1no
autoscaling_policy_typeAutoscaling policy type. TargetTrackingScaling and StepScaling are supportedstring"TargetTrackingScaling"no
autoscaling_scale_in_cooldownThe amount of time, in seconds, after a scaling activity completes and before the next scaling down activity can start. Default is 300snumber300no
autoscaling_scale_out_cooldownThe amount of time, in seconds, after a scaling activity completes and before the next scaling up activity can start. Default is 300snumber300no
autoscaling_target_metricsThe metrics type to use. If this value isn't provided the default is CPU utilizationstring"RDSReaderAverageCPUUtilization"no
autoscaling_target_valueThe target value to scale with respect to target metricsnumber75no
cluster_dns_name_partPart of DNS name added to module and cluster name for DNS for cluster endpointstring"writer"no
cluster_familyFamily of the DB parameter group. Valid values for Aurora PostgreSQL: aurora-postgresql9.6, aurora-postgresql10, aurora-postgresql11, aurora-postgresql12string"aurora-postgresql13"no
cluster_nameShort name for this clusterstringn/ayes
cluster_sizePostgres cluster sizenumbern/ayes
contextSingle object for setting entire context at once.
See description of individual variables for details.
Leave string and numeric variables as null to use default value.
Individual variable settings (non-null) override settings in context object,
except for attributes, tags, and additional_tag_map, which are merged.
"additional_tag_map": {},
"attributes": [],
"delimiter": null,
"descriptor_formats": {},
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_key_case": null,
"label_order": [],
"label_value_case": null,
"labels_as_tags": [
"name": null,
"namespace": null,
"regex_replace_chars": null,
"stage": null,
"tags": {},
"tenant": null
database_nameName for an automatically created database on cluster creation. An empty name will generate a db name.string""no
database_portDatabase portnumber5432no
deletion_protectionSpecifies whether the Cluster should have deletion protection enabled. The database can't be deleted when this value is set to trueboolfalseno
delimiterDelimiter to be used between ID elements.
Defaults to - (hyphen). Set to "" to use no delimiter at all.
descriptor_formatsDescribe additional descriptors to be output in the descriptors output map.
Map of maps. Keys are names of descriptors. Values are maps of the form
{<br/> format = string<br/> labels = list(string)<br/>}
(Type is any so the map values can later be enhanced to provide additional options.)
format is a Terraform format string to be passed to the format() function.
labels is a list of labels, in order, to pass to format() function.
Label values will be normalized before being passed to format() so they will be
identical to how they appear in id.
Default is {} (descriptors output will be empty).
dns_gbl_delegated_environment_nameThe name of the environment where global dns_delegated is provisionedstring"gbl"no
eks_component_namesThe names of the eks componentsset(string)
eks_security_group_enabledUse the eks default security groupboolfalseno
enabledSet to false to prevent the module from creating any resourcesboolnullno
enabled_cloudwatch_logs_exportsList of log types to export to cloudwatch. The following log types are supported: audit, error, general, slowquerylist(string)[]no
engineName of the database engine to be used for the DB clusterstring"postgresql"no
engine_modeThe database engine mode. Valid values: global, multimaster, parallelquery, provisioned, serverlessstringn/ayes
engine_versionEngine version of the Aurora global databasestring"13.4"no
enhanced_monitoring_role_enabledA boolean flag to enable/disable the creation of the enhanced monitoring IAM role. If set to false, the module will not create a new role and will use rds_monitoring_role_arn for enhanced monitoringbooltrueno
environmentID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT'stringnullno
iam_database_authentication_enabledSpecifies whether or mappings of AWS Identity and Access Management (IAM) accounts to database accounts is enabledboolfalseno
id_length_limitLimit id to this many characters (minimum 6).
Set to 0 for unlimited length.
Set to null for keep the existing setting, which defaults to 0.
Does not affect id_full.
import_profile_nameAWS Profile name to use when importing a resourcestringnullno
import_role_arnIAM Role ARN to use when importing a resourcestringnullno
instance_typeEC2 instance type for Postgres clusterstringn/ayes
kms_alias_name_ssmKMS alias name for SSMstring"alias/aws/ssm"no
label_key_caseControls the letter case of the tags keys (label names) for tags generated by this module.
Does not affect keys of tags passed in via the tags input.
Possible values: lower, title, upper.
Default value: title.
label_orderThe order in which the labels (ID elements) appear in the id.
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present.
label_value_caseControls the letter case of ID elements (labels) as included in id,
set as tag values, and output by this module individually.
Does not affect values of tags passed in via the tags input.
Possible values: lower, title, upper and none (no transformation).
Set this to title and set delimiter to "" to yield Pascal Case IDs.
Default value: lower.
labels_as_tagsSet of labels (ID elements) to include as tags in the tags output.
Default is to include all labels.
Tags with empty values will not be included in the tags output.
Set to [] to suppress all generated tags.
The value of the name tag, if included, will be the id, not the name.
Unlike other null-label inputs, the initial setting of labels_as_tags cannot be
changed in later chained modules. Attempts to change it will be silently ignored.
maintenance_windowWeekly time range during which system maintenance can occur, in UTCstring"wed:03:00-wed:04:00"no
nameID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.
This is the only ID element not also included as a tag.
The "name" tag is set to the full id string. There is no tag with the value of the name input.
namespaceID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally uniquestringnullno
performance_insights_enabledWhether to enable Performance Insightsboolfalseno
publicly_accessibleSet true to make this database accessible from the public internetboolfalseno
rds_monitoring_intervalThe interval, in seconds, between points when enhanced monitoring metrics are collected for the DB instance. To disable collecting Enhanced Monitoring metrics, specify 0. The default is 0. Valid Values: 0, 1, 5, 10, 15, 30, 60number60no
reader_dns_name_partPart of DNS name added to module and cluster name for DNS for cluster readerstring"reader"no
regex_replace_charsTerraform regular expression (regex) string.
Characters matching the regex will be removed from the ID elements.
If not set, "/[^a-zA-Z0-9-]/" is used to remove all characters other than hyphens, letters and digits.
regionAWS Regionstringn/ayes
skip_final_snapshotNormally AWS makes a snapshot of the database before deleting it. Set this to true in order to skip this.
NOTE: The final snapshot has a name derived from the cluster name. If you delete a cluster, get a final snapshot,
then create a cluster of the same name, its final snapshot will fail with a name collision unless you delete
the previous final snapshot first.
snapshot_identifierSpecifies whether or not to create this cluster from a snapshotstringnullno
ssm_password_sourceIf var.ssm_passwords_enabled is true, DB user passwords will be retrieved from SSM using
var.ssm_password_source and the database username. If this value is not set,
a default path will be created using the SSM path prefix and ID of the associated Aurora Cluster.
ssm_path_prefixTop level SSM path prefix (without leading or trailing slash)string"aurora-postgres"no
stageID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release'stringnullno
storage_encryptedSpecifies whether the DB cluster is encryptedbooltrueno
tagsAdditional tags (e.g. {'BusinessUnit': 'XYZ'}).
Neither the tag keys nor the tag values will be modified by this module.
tenantID element _(Rarely used, not included by default)_. A customer identifier, indicating who this instance of a resource is forstringnullno


admin_usernamePostgres admin username
cluster_identifierPostgres cluster identifier
config_mapMap containing information pertinent to a PostgreSQL client configuration.
database_namePostgres database name
kms_key_arnKMS key ARN for Aurora Postgres
master_hostnamePostgres master hostname
replicas_hostnamePostgres replicas hostname
ssm_key_pathsNames (key paths) of all SSM parameters stored for this cluster