Modernisation Platform Terraform RDS Instance

June 25, 2026 ยท View on GitHub

Standards Icon Format Code Icon Scorecards Icon SCA Icon Terraform SCA Icon

Terraform module for provisioning an AWS RDS instance on the Modernisation Platform.

This repository is for Modernisation Platform usage only. If you have a suggestion for a change that would benefit multiple teams, please raise an issue with the team here.

Usage


module "rds" {

  source = "github.com/ministryofjustice/modernisation-platform-terraform-rds-instance?ref=2d8e3b21b8f9a0b8acb81597a2d4575068edfede" # v0.6.0

  tags             = local.tags
  application_name = local.application_name

  vpc_id     = data.aws_vpc.shared.id
  subnet_ids = data.aws_subnets.shared_private.ids

  allowed_security_groups = [aws_security_group.application.id]

  db_engine                 = "postgres"
  db_engine_version         = "16"
  db_parameter_group_family = "postgres16"
  db_name                   = "app"
  db_username               = "app_admin"

  monitoring_role_arn = aws_iam_role.rds_monitoring.arn

}

Looking for issues?

If you're looking to raise an issue with this module, please create a new issue in the Modernisation Platform repository.

Requirements

NameVersion
terraform~> 1.0
aws~> 6.0
random~> 3.0

Providers

NameVersion
aws~> 6.0
random~> 3.0

Modules

No modules.

Resources

NameType
aws_cloudwatch_log_group.rdsresource
aws_cloudwatch_log_subscription_filter.rdsresource
aws_db_instance.rdsresource
aws_db_parameter_group.rdsresource
aws_db_subnet_group.rdsresource
aws_secretsmanager_secret.rdsresource
aws_secretsmanager_secret_version.rdsresource
aws_security_group.rdsresource
aws_vpc_security_group_ingress_rule.allowed_cidrsresource
aws_vpc_security_group_ingress_rule.allowed_sgsresource
random_id.secret_suffixresource
random_password.rdsresource
random_string.log_suffixresource
aws_kinesis_firehose_delivery_stream.xsiamdata source
aws_subnets.rdsdata source

Inputs

NameDescriptionTypeDefaultRequired
allow_major_version_upgradeAllow major engine version upgrades when changing engine_versionboolfalseno
allowed_cidr_blocksList of CIDR blocks permitted to connect to the RDS instancelist(string)[]no
allowed_security_groupsList of security group IDs permitted to connect to the RDS instancelist(string)[]no
application_nameName of applicationstringn/ayes
auto_minor_version_upgradeAutomatically apply minor engine version upgrades during the maintenance windowbooltrueno
backup_retention_periodNumber of days to retain automated backups. 0 disables automated backups.number7no
backup_windowPreferred daily time range for automated backups in UTC (e.g. 03:00-06:00)string"03:00-06:00"no
ca_cert_identifierIdentifier of the CA certificate for the DB instance. Defaults to rds-ca-rsa4096-g1 (RSA 4096-bit, 100-year validity). Override to rds-ca-ecc384-g1 for ECC or rds-ca-rsa2048-g1 for broader client compatibility.string"rds-ca-rsa4096-g1"no
cloudwatch_log_retention_daysNumber of days to retain RDS logs in CloudWatch log groups.number30no
db_allocated_storageAllocated storage in GiBnumber20no
db_engineDatabase engine type (e.g. postgres, mysql, mariadb, oracle-se2, sqlserver-se)stringn/ayes
db_engine_versionDatabase engine versionstringn/ayes
db_instance_classRDS instance classstring"db.t3.medium"no
db_iopsProvisioned IOPS for the storage. Required for io1 and io2 storage types. Minimum 1000.numbernullno
db_max_allocated_storageUpper limit for storage autoscaling in GiB. Set to 0 to disable autoscaling.number0no
db_nameName of the initial database to create. When restoring from a snapshot or creating a replica, this is inherited from the source and can be left null.stringnullno
db_parameter_group_familyParameter group family used to create the module-managed parameter group with SSL enforcement (e.g. postgres16, mysql8.0, mariadb10.11, sqlserver-se-15.0). Required unless parameter_group_name is set. Not applicable to Oracle - configure SSL via the option group instead.stringnullno
db_portPort on which the DB accepts connections. Defaults to 5432 (PostgreSQL).number5432no
db_storage_typeStorage type (gp2, gp3, io1, io2)string"gp3"no
db_usernameMaster username for the database. Required for new instances and snapshot restores. Inherited from the source instance when replicate_source_db is set.stringnullno
deletion_protectionEnables deletion protection on the RDS instancebooltrueno
kms_key_idARN of the KMS key used for storage and Secrets Manager encryption. Uses the AWS-managed key if not set.stringnullno
maintenance_windowPreferred weekly time range for maintenance (e.g. Mon:00:00-Mon:03:00)string"Mon:00:00-Mon:03:00"no
monitoring_intervalInterval in seconds for Enhanced Monitoring metrics. Must be 1, 5, 10, 15, 30, or 60. Defaults to 60 (enabled).number60no
monitoring_role_arnARN of the IAM role that allows RDS to send Enhanced Monitoring metrics to CloudWatch. Required for monitoring.stringn/ayes
multi_azWhether to deploy the RDS instance across multiple Availability Zonesbooltrueno
opt_in_xsiam_loggingIf true, forwards RDS CloudWatch logs to XSIAM Cortex via Kinesis Firehose. Requires xsiam_firehose_stream_name and xsiam_cloudwatch_role_arn.boolfalseno
option_group_nameName of the DB option group to associate with the instance (MySQL and Oracle only)stringnullno
parameter_group_nameName of a pre-existing DB parameter group to associate with the instance. When set, the module-managed parameter group (and its SSL enforcement settings) is not created.stringnullno
performance_insights_enabledEnable Performance Insights for the RDS instancebooltrueno
performance_insights_retention_periodRetention period for Performance Insights data in days. Must be 7 or 731.number7no
replicate_source_dbIdentifier or ARN of the source RDS instance to create a read replica from. When set, db_username, db_name, and the master password are inherited from the source โ€” Secrets Manager is not provisioned for the replica.stringnullno
skip_final_snapshotWhether to skip taking a final snapshot before destroying the instanceboolfalseno
snapshot_identifierSnapshot identifier to restore the instance from. When set, the instance is created from this snapshot instead of a blank database. db_username must match the snapshot's master username.stringnullno
subnet_idsList of explicit subnet IDs for the DB subnet group. When set, overrides subnet discovery via tags.list(string)nullno
subnet_tagsSubnet tags used to discover existing subnets for the DB subnet group in the target VPC. Ignored if subnet_ids is set.map(string)
{
"Type": "data"
}
no
tagsCommon tags to be used by all resourcesmap(string)n/ayes
vpc_idVPC ID where the RDS instance will be deployedstringn/ayes
xsiam_cloudwatch_role_arnARN of the IAM role that allows CloudWatch Logs to write to the Firehose stream. Required when opt_in_xsiam_logging = true.stringnullno
xsiam_firehose_stream_nameName of the Kinesis Firehose delivery stream to send logs to. Required when opt_in_xsiam_logging = true.stringnullno

Outputs

No outputs.