AWS Relational Database Service (RDS) Terraform Module
Terraform module to provision Relational Database Service
on AWS.
Usage
Simple setup
Create a simple RDS with default configurations.
module "rds" {
source = "app.terraform.io/ncodelibrary/rds/aws"
version = "0.2.1"
rds_parameter_group_family = "postgres11"
rds_engine_version = "11.6"
rds_instance_class = "db.t2.small"
security_groups = ["sg-xxxxxxxxxxxxx"]
identifier = "example"
subnets = ["subnet-xxxxxxxxxxxx", "subnet-xxxxxxxxxxxx"]
vpc_id = "vpc-xxxxxxxxxxx"
engine = "postgres"
tags = {
Owner = "sysops"
env = "dev"
Cost_Center = "XYZ"
}
}
For more details on a working example, please visit examples/simple
Advanced Setup
If you want to create RDS with enhanced configuration e.g mutli-az etc., you can use the module like this:
module "rds" {
source = "app.terraform.io/ncodelibrary/rds/aws"
version = "0.2.1"
rds_parameter_group_family = "postgres11"
rds_engine_version = "11.6"
rds_instance_class = "db.t2.small"
rds_database_name = "example_db"
rds_master_username = "example_root"
multi_az = true
rds_allocated_storage = 30
backup_retention_period = 14
storage_type = "gp2"
allow_major_version_upgrade = true
auto_minor_version_upgrade = true
publicly_accessible = false
skip_final_snapshot = true
security_groups = ["sg-xxxxxxxxxxxxx"]
identifier = "example"
subnets = ["subnet-xxxxxxxxxxxx", "subnet-xxxxxxxxxxx"]
vpc_id = "vpc-000fe2b5ddba6bb64"
engine = "postgres"
tags = {
Owner = "sysops"
env = "dev"
Cost_Center = "XYZ"
}
}
For more options refer to a working example at examples/advanced
Examples
Here are some working examples of using this module:
Requirements
Name | Version |
---|---|
terraform | >= 0.12 |
Providers
Name | Version |
---|---|
aws | n/a |
random | n/a |
Modules
No Modules.
Resources
Name |
---|
aws_db_instance |
aws_db_parameter_group |
aws_db_subnet_group |
aws_ssm_parameter |
random_password |
Inputs
Name | Description | Type | Default | Required |
---|---|---|---|---|
allow_major_version_upgrade | Indicates that major version upgrades are allowed | bool |
false |
no |
append_workspace | Appends the terraform workspace at the end of resource names, |
bool |
true |
no |
auto_minor_version_upgrade | Indicates that minor engine upgrades will be applied automatically to the DB instance during the maintenance window | bool |
true |
no |
backup_retention_period | Backup retention period | number |
7 |
no |
encryption | (Optional) Specifies whether the DB instance is encrypted. Note that if you are creating a cross-region read replica this field is ignored and you should instead declare kms_key_id with a valid ARN | bool |
true |
no |
engine | Define the engine for the database | string |
n/a | yes |
identifier | The name for the resources | string |
n/a | yes |
multi_az | Set to ‘true’ to deploy the rds instance as multi-az | bool |
false |
no |
password | RDS DB password. If not set, random password will be used and stored in SSM | string |
null |
no |
publicly_accessible | Bool to control if instance is publicly accessible | bool |
false |
no |
rds_allocated_storage | Allocated storage | number |
21 |
no |
rds_database_name | Name of the database | string |
"default_database" |
no |
rds_engine_version | Engine version for the db | string |
n/a | yes |
rds_instance_class | Instance class for the database | string |
n/a | yes |
rds_master_username | Master username for the database | string |
"root" |
no |
rds_parameter_group_family | Parameter group family for the instance | string |
n/a | yes |
security_groups | Security group | list(string) |
n/a | yes |
skip_final_snapshot | Determines whether a final DB snapshot is created before the DB instance is deleted | bool |
true |
no |
storage_type | Storage type for the db | string |
"gp2" |
no |
subnets | A list of VPC subnet IDs | list(string) |
n/a | yes |
tags | Tags to be applied to the resource | map |
{} |
no |
vpc_id | VPC id for the resources | string |
n/a | yes |
Outputs
Name | Description |
---|---|
output | n/a |
Contributing
If you want to contribute to this repository check all the guidelines specified here before submitting a new PR.