Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
169 changes: 86 additions & 83 deletions README.md

Large diffs are not rendered by default.

48 changes: 48 additions & 0 deletions example/complete/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
## PostgreSQL Example
![squareops_avatar]

[squareops_avatar]: https://squareops.com/wp-content/uploads/2022/12/squareops-logo.png

### [SquareOps Technologies](https://squareops.com/) Your DevOps Partner for Accelerating cloud journey.
<br>

This example will be very useful for users who are new to a module and want to quickly learn how to use it. By reviewing the examples, users can gain a better understanding of how the module works, what features it supports, and how to customize it to their specific needs.

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.43.0 |

## Providers

No providers.

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_rds-pg"></a> [rds-pg](#module\_rds-pg) | git@github.com:sq-ia/terraform-aws-rds-postgresql.git | n/a |

## Resources

No resources.

## Inputs

No inputs.

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_instance_endpoint"></a> [instance\_endpoint](#output\_instance\_endpoint) | Connection endpoint of the RDS instance. |
| <a name="output_instance_name"></a> [instance\_name](#output\_instance\_name) | Name of the database instance. |
| <a name="output_instance_password"></a> [instance\_password](#output\_instance\_password) | Password for accessing the database (Note: Terraform does not track this password after initial creation). |
| <a name="output_instance_username"></a> [instance\_username](#output\_instance\_username) | Master username for accessing the database. |
| <a name="output_parameter_group_id"></a> [parameter\_group\_id](#output\_parameter\_group\_id) | ID of the parameter group associated with the RDS instance. |
| <a name="output_security_group"></a> [security\_group](#output\_security\_group) | ID of the security group associated with the RDS instance. |
| <a name="output_subnet_group_id"></a> [subnet\_group\_id](#output\_subnet\_group\_id) | ID of the subnet group associated with the RDS instance. |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
65 changes: 30 additions & 35 deletions example/complete/main.tf
Original file line number Diff line number Diff line change
@@ -1,41 +1,36 @@
locals {
region = "us-east-2"
name = "skaf"
environment = "production"
engine_version = "13"
instance_class = "db.m5.large"
region = "us-east-2"
name = "skaf"
vpc_id = "vpc-00ae5511ee10671c1"
family = "postgres15"
subnet_ids = ["subnet-0d9a81939c6dd2a6e","subnet-0fd26f0d73dc9e73d"]
environment = "prod"
kms_key_arn = "arn:aws:kms:us-east-2:271251951598:key/73ff9e84-83e1-4097-b388-fe29623338a9"
engine_version = "15.2"
instance_class = "db.m5d.large"
allowed_security_groups = ["sg-0a680184e11eafd35"]
}

module "rds-pg" {
source = "../../"
engine = "postgres"
engine_version = local.engine_version
instance_class = local.instance_class
allocated_storage = "20"
storage_encrypted = true
kms_key_arn = "arn:aws:kms:us-east-2:271251951598:key/7fa600be-9c08-4502-a67a-ed7e8bc332cb"
publicly_accessible = false
replicate_source_db = null
db_name = "postgres"
master_username = "pguser"
port = "5432"
multi_az = "false"
subnet_ids = ["subnet-0dd83181b1c69eee8","subnet-095b80a737aea6d0f"]
skip_final_snapshot = false
final_snapshot_identifier_prefix = "final"
maintenance_window = "Mon:00:00-Mon:03:00"
source = "git@github.com:sq-ia/terraform-aws-rds-postgresql.git"
name = local.name
db_name = "postgres"
multi_az = "true"
family = local.family
vpc_id = local.vpc_id
subnet_ids = local.subnet_ids ## db subnets
environment = local.environment
kms_key_arn = local.kms_key_arn
engine_version = local.engine_version
instance_class = local.instance_class
master_username = "pguser"
allocated_storage = "20"
publicly_accessible = false
skip_final_snapshot = true
backup_window = "03:00-06:00"
backup_retention_period = 1
apply_immediately = true
random_password_length = 10
create_random_password = true
allowed_security_groups = ["sg-03472c1a5f35c026d"]
allowed_cidr_blocks = []
vpc_id = "vpc-06db5c1d1b2ec66f8"
family = "postgres13"
major_engine_version = "13"
deletion_protection = true
maintenance_window = "Mon:00:00-Mon:03:00"
final_snapshot_identifier_prefix = "final"
allowed_security_groups = local.allowed_security_groups
major_engine_version = local.engine_version
deletion_protection = false
}



16 changes: 8 additions & 8 deletions example/complete/output.tf
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
output "instance_endpoint" {
description = "The connection endpoint"
description = "Connection endpoint of the RDS instance."
value = module.rds-pg.db_instance_endpoint
}

output "instance_name" {
description = "The database name"
description = "Name of the database instance."
value = module.rds-pg.db_instance_name
}

output "instance_username" {
description = "The master username for the database"
description = "Master username for accessing the database."
value = module.rds-pg.db_instance_username
}

output "instance_password" {
description = "The database password (this password may be old, because Terraform doesn't track it after initial creation)"
description = "Password for accessing the database (Note: Terraform does not track this password after initial creation)."
value = module.rds-pg.db_instance_password
}

output "security_group" {
description = "The security group ID of the cluster"
description = "ID of the security group associated with the RDS instance."
value = module.rds-pg.rds_dedicated_security_group
}

output "parameter_group_id" {
description = "The db parameter group id"
description = "ID of the parameter group associated with the RDS instance."
value = module.rds-pg.db_parameter_group_id
}

output "subnet_group_id" {
description = "The db subnet group name"
description = "ID of the subnet group associated with the RDS instance."
value = module.rds-pg.db_subnet_group_id
}
}
2 changes: 1 addition & 1 deletion example/complete/provider.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
provider "aws" {
region = local.region
}
}
37 changes: 18 additions & 19 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ locals {
}

module "db" {
source = "terraform-aws-modules/rds/aws"
version = "~> 3.0"
identifier = format("%s-%s", var.environment, var.rds_instance_name)
engine = var.engine
engine_version = var.engine_version
instance_class = var.instance_class
allocated_storage = var.allocated_storage
storage_encrypted = var.storage_encrypted
kms_key_id = var.kms_key_arn
publicly_accessible = var.publicly_accessible
replicate_source_db = var.replicate_source_db
source = "terraform-aws-modules/rds/aws"
version = "~> 3.0"
identifier = format("%s-%s", var.environment, var.name)
engine = var.engine
engine_version = var.engine_version
instance_class = var.instance_class
allocated_storage = var.allocated_storage
storage_encrypted = var.storage_encrypted
kms_key_id = var.kms_key_arn
publicly_accessible = var.publicly_accessible
replicate_source_db = var.replicate_source_db
name = var.db_name
username = var.master_username
port = var.port
Expand All @@ -35,13 +35,12 @@ module "db" {
apply_immediately = var.apply_immediately
random_password_length = var.random_password_length
create_random_password = var.create_random_password
monitoring_interval = "30"
monitoring_role_name = format("%s-%s-MyRDSMonitoringRole", var.rds_instance_name, var.environment)
create_monitoring_role = true
enabled_cloudwatch_logs_exports = ["postgresql"]

monitoring_interval = "30"
monitoring_role_name = format("%s-%s-RDSPostgresql", var.name, var.environment)
create_monitoring_role = true
enabled_cloudwatch_logs_exports = ["postgresql"]
tags = merge(
{ "Name" = format("%s-%s", var.environment, var.rds_instance_name) },
{ "Name" = format("%s-%s", var.environment, var.name) },
local.tags,
)

Expand Down Expand Up @@ -85,7 +84,7 @@ module "security_group_rds" {
source = "terraform-aws-modules/security-group/aws"
version = "~> 4"
create = var.create_security_group
name = format("%s-%s-%s", var.environment, var.rds_instance_name, "rds-sg")
name = format("%s-%s-%s", var.environment, var.name, "rds-sg")
description = "Complete PostgreSQL example security group"
vpc_id = var.vpc_id

Expand All @@ -99,7 +98,7 @@ module "security_group_rds" {
]

tags = merge(
{ "Name" = format("%s-%s-%s", var.environment, var.rds_instance_name, "rds-sg") },
{ "Name" = format("%s-%s-%s", var.environment, var.name, "rds-sg") },
local.tags,
)
}
16 changes: 8 additions & 8 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
output "db_instance_endpoint" {
description = "The connection endpoint"
description = "Connection endpoint of the RDS instance."
value = module.db.db_instance_endpoint
}

output "db_instance_name" {
description = "The database name"
description = "Name of the database instance"
value = module.db.db_instance_name
}

output "db_instance_username" {
description = "The master username for the database"
description = "Master username for accessing the database."
value = nonsensitive(module.db.db_instance_username)
}

output "db_instance_password" {
description = "The database password (this password may be old, because Terraform doesn't track it after initial creation)"
description = "Password for accessing the database (Note: Terraform does not track this password after initial creation)."
value = nonsensitive(module.db.db_instance_password)
}

output "rds_dedicated_security_group" {
description = "The security group ID of the cluster"
description = "ID of the security group associated with the RDS instance."
value = module.security_group_rds.security_group_id
}

output "db_parameter_group_id" {
description = "The db parameter group id"
description = "ID of the parameter group associated with the RDS instance."
value = module.db.db_parameter_group_id
}

output "db_subnet_group_id" {
description = "The db subnet group name"
description = "ID of the subnet group associated with the RDS instance."
value = module.db.db_subnet_group_id
}
}
Loading