Meet OPSd. The unique and effortless way of managing cloud infrastructure.
Terraform module which creates RDS Postgres on AWS.
source = "github.com/opsd-io/terraform-module-aws-rds-postgres"
instance_name = "example"
engine_version = "16.3"
instance_class = "db.t4g.micro"
username = "dbadmin"
password = "avoid-plaintext-passwords"
tags = {
"Name" = "example"
"Env" = "test"
}
}
IMPORTANT: Make sure not to pin to master because there may be breaking changes between releases.
var.common_tags
- assigned to every resource in this modulevar.instance_tags
- assigned to the DB instance and each of it's replicasvar.tags
- assigned to the DB instancevar.replica_tags
- assigned to every DB replica instancevar.db_subnet_group_tags
- assigned to the DB subnet groupvar.parameter_group_tags
- assigned to the DB parameter group
The module allows to create replica instance(s) in three different ways:
- Single replica instance
module "postgres_main" {
source = "github.com/opsd-io/terraform-module-aws-rds-postgres"
(...)
replica_enabled = true
}
- Simple mode - an option to create arbitrary number of replicas. It's not possible to set distinct settings for each instance.
module "postgres_main" {
source = "github.com/opsd-io/terraform-module-aws-rds-postgres"
(...)
number_of_replicas = 3
}
- Advanced mode - an option to create arbitrary number of replicas alongwith different settings for each instance. Offers the highest flexibility.
module "postgres_main" {
source = "github.com/opsd-io/terraform-module-aws-rds-postgres"
(...)
custom_replicas = {
"opsd-postgres-main-read-${var.env_name}" = {
"availability_zone" = "us-east-2b"
"tags" = { "replica" = "read" }
}
"opsd-postgres-main-analytics-${var.env_name}" = {
"availability_zone" = "us-east-2c"
"instance_class" = "db.t4g.small"
"tags" = { "replica" = "analytics" }
}
}
}
Name | Version |
---|---|
terraform | >= 1.5.5 |
aws | >= 5.50.0 |
Name | Version |
---|---|
aws | >= 5.50.0 |
No modules.
Name | Type |
---|---|
aws_cloudwatch_log_group.postgres | resource |
aws_cloudwatch_log_group.postgres_custom_replica | resource |
aws_cloudwatch_log_group.postgres_multi_replica | resource |
aws_cloudwatch_log_group.postgres_replica | resource |
aws_db_instance.custom_replica | resource |
aws_db_instance.main | resource |
aws_db_instance.multi_replica | resource |
aws_db_instance.replica | resource |
aws_db_instance_role_association.main | resource |
aws_db_parameter_group.main | resource |
aws_db_subnet_group.main | resource |
Name | Description | Type | Default | Required |
---|---|---|---|---|
allocated_storage | A size of the DB storage. | number |
20 |
no |
auto_minor_version_upgrade | Enables minor version auto upgrade. | bool |
false |
no |
availability_zone | The availability zone of the instance. | string |
null |
no |
backup_retention_period | The days to retain backups for. | number |
null |
no |
backup_window | The daily time range (in UTC) during which automated backups are created if they are enabled. | string |
"03:00-06:00" |
no |
blue_green_update_enabled | Enables low-downtime updates when true. | bool |
false |
no |
ca_cert_identifier | The identifier of the CA certificate for the DB instance. | string |
null |
no |
cloudwatch_log_group_class | The log class of the log group. | string |
"STANDARD" |
no |
cloudwatch_log_group_kms_key_id | The ARN of the KMS Key to use when encrypting log data. | string |
null |
no |
cloudwatch_log_group_retention_in_days | Tthe number of days to retain log events in the cloudwatch log group. | number |
7 |
no |
cloudwatch_log_group_skip_destroy | Set to true to prevent deletion fo the log group at terraform destroy time. | bool |
false |
no |
cloudwatch_logs_enabled | If true, cloudwatch log group is created. | bool |
false |
no |
common_tags | A map of tags to assign to every resource in this module. | map(string) |
{} |
no |
copy_tags_to_snapshot | Copy all Instance tags to snapshots. | bool |
false |
no |
custom_iam_instance_profile | The instance profile associated with the underlying Amazon EC2 instance of an RDS Custom DB instance. | string |
null |
no |
custom_replicas | A map of replica instances. Allows to set different settings for each one. | map(object({ |
{} |
no |
db_name | The database name. | string |
"defaultdb" |
no |
db_subnet_group_name | The name of DB subnet group. | string |
null |
no |
db_subnet_group_tags | A map of the DB subnet group tags. | map(string) |
{} |
no |
dedicated_log_volume | Use a dedicated log volume (DLV) for the DB instance. | bool |
false |
no |
delete_automated_backups | Specifies whether to remove automated backups immediately after the DB instance is deleted. | bool |
true |
no |
deletion_protection | The database can't be deleted when this value is set to true. | bool |
false |
no |
enabled_cloudwatch_logs_exports | Set of log types to enable for exporting to CloudWatch logs. | set(string) |
[ |
no |
engine_version | The engine version to use. | string |
"16.3" |
no |
final_snapshot_identifier | he name of your final DB snapshot when this DB instance is deleted. | string |
null |
no |
iam_database_authentication_enabled | Enables mappings of AWS IAM accounts to database accounts. | bool |
false |
no |
instance_class | The instance type of the RDS instance. | string |
"db.t4g.micro" |
no |
instance_name | The database instance identifier. | string |
n/a | yes |
instance_tags | A map of tags to assign to the DB instance and each of it's replicas. | map(string) |
{} |
no |
iops | The database storage type. | number |
null |
no |
kms_key_id | The ARN for the KMS encryption key. | string |
null |
no |
maintenance_window | The window to perform maintenance in. | string |
"Mon:00:00-Mon:03:00" |
no |
manage_master_user_password | Set to true to allow RDS to manage the master user password in Secrets Manager. | bool |
null |
no |
max_allocated_storage | The upper limit to which Amazon RDS can automatically scale the storage of the DB instance. | number |
0 |
no |
monitoring_interval | The interval, in seconds, between points when Enhanced Monitoring metrics are collected for the DB instance. | number |
0 |
no |
monitoring_role_arn | The ARN for the IAM role that permits RDS to send enhanced monitoring metrics to CloudWatch Logs. | string |
null |
no |
multi_az | Specifies if the RDS instance is multi-AZ. | bool |
false |
no |
network_type | The network type of the DB instance. | string |
"IPV4" |
no |
number_of_replicas | Allows creating arbitrary number of replicas. | number |
0 |
no |
parameter_group_family | The family of the DB parameter group. | string |
"postgres16" |
no |
parameter_group_list | A list of parameters included in the database parameter group. | list(map(string)) |
[] |
no |
parameter_group_name | The name of the database parameter group. | string |
null |
no |
parameter_group_tags | A map of the parameter group tags. | map(string) |
{} |
no |
password | Password for the master DB user. | string |
null |
no |
performance_insights_enabled | Specifies whether Performance Insights are enabled. | bool |
false |
no |
performance_insights_kms_key_id | The ARN for the KMS key to encrypt Performance Insights data. | string |
null |
no |
performance_insights_retention_period | Amount of time in days to retain Performance Insights data. | number |
0 |
no |
port | The port on which the DB accepts connections. | number |
5432 |
no |
publicly_accessible | Bool to control if instance is publicly accessible. | bool |
false |
no |
replica_availability_zone | The availability zone of the replica instance. | string |
null |
no |
replica_enabled | If true, the DB replica is created. | bool |
false |
no |
replica_name | The replica instance identifier. | string |
null |
no |
replica_tags | A map of tags to assign to each replica instance. | map(string) |
{} |
no |
restore_to_point_in_time | value | object({ |
{} |
no |
role_associations | A map of the database instance associations with an IAM Role. | map(string) |
{} |
no |
skip_final_snapshot | Determines whether a final DB snapshot is created before the DB instance is deleted. | bool |
true |
no |
snapshot_identifier | Specifies whether or not to create this database from a snapshot. | string |
null |
no |
storage_encrypted | The storage throughput value for the DB instance. | bool |
false |
no |
storage_throughput | The storage throughput value for the DB instance. | number |
null |
no |
storage_type | The database storage type. | string |
"gp3" |
no |
subnet_ids | A set of subnet IDs used to create the DB subnet group. | set(string) |
[] |
no |
tags | A map of the DB instance tags. | map(string) |
{} |
no |
timeouts | A map of timeouts to apply while creating, updating, or deleting the DB instance. | object({ |
{ |
no |
username | Username for the master DB user. | string |
"dbadmin" |
no |
vpc_security_group_ids | The database storage type. | list(string) |
[] |
no |
Name | Description |
---|---|
db_custom_replica_address | The address of the replica instance (Advanced mode). |
db_custom_replica_arn | The ARN of the replica instance (Advanced mode). |
db_custom_replica_availability_zone | The availability zone of the replica instance (Advanced mode). |
db_custom_replica_backup_retention_period | The backup window of the replica instance (Advanced mode). |
db_custom_replica_backup_window | The backup retention period of the replica instance (Advanced mode). |
db_custom_replica_endpoint | The connection endpoint of the replica instance (Advanced mode). |
db_custom_replica_engine_version_actual | The running version of the replica instance (Advanced mode). |
db_custom_replica_identifier | The replica instance identifier (Advanced mode). |
db_custom_replica_maintenance_window | The maintenance window of the replica instance (Advanced mode). |
db_custom_replica_resource_id | The Resource ID of the replica instance (Advanced mode). |
db_custom_replica_status | The status of the replica instance (Advanced mode). |
db_instance_address | The address of the RDS instance. |
db_instance_arn | The ARN of the RDS instance. |
db_instance_availability_zone | The availability zone of the RDS instance. |
db_instance_backup_retention_period | The backup window of the RDS instance. |
db_instance_backup_window | The backup retention period of the RDS instance. |
db_instance_endpoint | The connection endpoint of the RDS instance. |
db_instance_engine_version_actual | The running version of the RDS instance. |
db_instance_identifier | The RDS instance identifier. |
db_instance_maintenance_window | The maintenance window of the RDS instance. |
db_instance_replica_address | The address of the replica instance. |
db_instance_replica_arn | The ARN of the replica instance. |
db_instance_replica_availability_zone | The availability zone of the replica instance. |
db_instance_replica_backup_retention_period | The backup window of the replica instance. |
db_instance_replica_backup_window | The backup retention period of the replica instance. |
db_instance_replica_endpoint | The connection endpoint of the replica instance. |
db_instance_replica_engine_version_actual | The running version of the replica instance. |
db_instance_replica_identifier | The replica instance identifier. |
db_instance_replica_maintenance_window | The maintenance window of the replica instance. |
db_instance_replica_resource_id | The Resource ID of the replica instance. |
db_instance_replica_status | The status of the replica instance. |
db_instance_resource_id | The Resource ID of the RDS instance. |
db_instance_status | The status of the RDS instance. |
db_multi_replica_address | The address of the replica instance (Simple mode). |
db_multi_replica_arn | The ARN of the replica instance (Simple mode). |
db_multi_replica_availability_zone | The availability zone of the replica instance (Simple mode). |
db_multi_replica_backup_retention_period | The backup window of the replica instance (Simple mode). |
db_multi_replica_backup_window | The backup retention period of the replica instance (Simple mode). |
db_multi_replica_endpoint | The connection endpoint of the replica instance (Simple mode). |
db_multi_replica_engine_version_actual | The running version of the replica instance (Simple mode). |
db_multi_replica_identifier | The replica instance identifier (Simple mode). |
db_multi_replica_maintenance_window | The maintenance window of the replica instance (Simple mode). |
db_multi_replica_resource_id | The Resource ID of the replica instance (Simple mode). |
db_multi_replica_status | The status of the replica instance (Simple mode). |
parameter_group_id | The ID of the DB parameter group. |
subnet_group_id | The ID of the DB subnet Group. |
Do you want to see how the module works? See all the usage examples.
The list of related modules (if present).
If you are interested in contributing to the project, see see our guide.
If you have a problem with the module or want to propose a new feature, you can report it via the project's (Github) issue tracker.
If you want to discuss something in person, you can join our community on Slack.