Skip to content

Commit a728d7f

Browse files
authored
Merge pull request #19 from squareops/release-2.0.0
Release 2.0.0
2 parents 1b0d849 + 7588fb3 commit a728d7f

File tree

25 files changed

+729
-46
lines changed

25 files changed

+729
-46
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
*.tfvars
77
*.pem
88
vars
9+
.helmignore

README.md

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ module "rds-pg" {
2727
name = "postgresql"
2828
db_name = "proddb"
2929
vpc_id = "vpc-047eb8acfb73"
30-
multi_az = "true"
30+
multi_az = false
3131
subnet_ids = ["subnet-b39cfc", "subnet-090b8d8"]
3232
environment = "prod"
33+
create_namespace = true
3334
storage_type = "gp3"
35+
cluster_name = ""
3436
replica_enable = false
3537
replica_count = 1
3638
kms_key_arn = "arn:aws:kms:region:2222222222:key/f8c8d802-a34b"
@@ -54,6 +56,20 @@ module "rds-pg" {
5456
slack_channel = "skaf-dev"
5557
slack_webhook_url = "https://hooks/xxxxxxxx"
5658
custom_user_password = "postgresqlpasswd"
59+
cluster_name = ""
60+
namespace = local.namespace
61+
create_namespace = local.create_namespace
62+
postgresdb_backup_enabled = false
63+
postgresdb_backup_config = {
64+
postgres_database_name = "" # Specify the database name or Leave empty if you wish to backup all databases
65+
cron_for_full_backup = "*/2 * * * *" # set cronjob for backup
66+
bucket_uri = "s3://mongodb-backups-atmosly" # s3 bucket uri
67+
}
68+
postgresdb_restore_enabled = false
69+
postgresdb_restore_config = {
70+
bucket_uri = "s3://mongodb-backups-atmosly" #S3 bucket URI (without a trailing slash /) containing the backup dump file.
71+
backup_file_name = "db5_20241114111607.sql" #Give .sql or .zip file for restore
72+
}
5773
}
5874
```
5975
Refer [examples](https://github.com/squareops/terraform-aws-rds-postgresql/tree/main/examples) for more details.
@@ -66,51 +82,52 @@ The required IAM permissions to create resources from this module can be found [
6682

6783
| Name | Version |
6884
|------|---------|
69-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13 |
70-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | 5.13.1 |
85+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
86+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.0.0 |
7187

7288
## Providers
7389

7490
| Name | Version |
7591
|------|---------|
7692
| <a name="provider_archive"></a> [archive](#provider\_archive) | n/a |
77-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.13.1 |
93+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.0.0 |
7894
| <a name="provider_random"></a> [random](#provider\_random) | n/a |
7995

8096
## Modules
8197

8298
| Name | Source | Version |
8399
|------|--------|---------|
100+
| <a name="module_backup_restore"></a> [backup\_restore](#module\_backup\_restore) | ./modules/db-backup-restore | n/a |
84101
| <a name="module_cw_sns_slack"></a> [cw\_sns\_slack](#module\_cw\_sns\_slack) | ./lambda | n/a |
85102
| <a name="module_db"></a> [db](#module\_db) | terraform-aws-modules/rds/aws | 6.1.0 |
86103
| <a name="module_db_replica"></a> [db\_replica](#module\_db\_replica) | terraform-aws-modules/rds/aws | 6.1.0 |
87-
| <a name="module_security_group_rds"></a> [security\_group\_rds](#module\_security\_group\_rds) | terraform-aws-modules/security-group/aws | ~> 4 |
104+
| <a name="module_security_group_rds"></a> [security\_group\_rds](#module\_security\_group\_rds) | terraform-aws-modules/security-group/aws | ~> 5.0 |
88105

89106
## Resources
90107

91108
| Name | Type |
92109
|------|------|
93-
| [aws_cloudwatch_metric_alarm.cache_cpu](https://registry.terraform.io/providers/hashicorp/aws/5.13.1/docs/resources/cloudwatch_metric_alarm) | resource |
94-
| [aws_cloudwatch_metric_alarm.disk_free_storage_space_too_low](https://registry.terraform.io/providers/hashicorp/aws/5.13.1/docs/resources/cloudwatch_metric_alarm) | resource |
95-
| [aws_kms_ciphertext.slack_url](https://registry.terraform.io/providers/hashicorp/aws/5.13.1/docs/resources/kms_ciphertext) | resource |
96-
| [aws_kms_key.this](https://registry.terraform.io/providers/hashicorp/aws/5.13.1/docs/resources/kms_key) | resource |
97-
| [aws_lambda_permission.sns_lambda_slack_invoke](https://registry.terraform.io/providers/hashicorp/aws/5.13.1/docs/resources/lambda_permission) | resource |
98-
| [aws_secretsmanager_secret.secret_master_db](https://registry.terraform.io/providers/hashicorp/aws/5.13.1/docs/resources/secretsmanager_secret) | resource |
99-
| [aws_secretsmanager_secret_version.rds_credentials](https://registry.terraform.io/providers/hashicorp/aws/5.13.1/docs/resources/secretsmanager_secret_version) | resource |
100-
| [aws_security_group_rule.cidr_ingress](https://registry.terraform.io/providers/hashicorp/aws/5.13.1/docs/resources/security_group_rule) | resource |
101-
| [aws_security_group_rule.default_ingress](https://registry.terraform.io/providers/hashicorp/aws/5.13.1/docs/resources/security_group_rule) | resource |
102-
| [aws_sns_topic.slack_topic](https://registry.terraform.io/providers/hashicorp/aws/5.13.1/docs/resources/sns_topic) | resource |
103-
| [aws_sns_topic_subscription.slack-endpoint](https://registry.terraform.io/providers/hashicorp/aws/5.13.1/docs/resources/sns_topic_subscription) | resource |
110+
| [aws_cloudwatch_metric_alarm.cache_cpu](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_metric_alarm) | resource |
111+
| [aws_cloudwatch_metric_alarm.disk_free_storage_space_too_low](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_metric_alarm) | resource |
112+
| [aws_kms_ciphertext.slack_url](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_ciphertext) | resource |
113+
| [aws_kms_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_key) | resource |
114+
| [aws_lambda_permission.sns_lambda_slack_invoke](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_permission) | resource |
115+
| [aws_secretsmanager_secret.secret_master_db](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/secretsmanager_secret) | resource |
116+
| [aws_secretsmanager_secret_version.rds_credentials](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/secretsmanager_secret_version) | resource |
117+
| [aws_security_group_rule.cidr_ingress](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
118+
| [aws_security_group_rule.default_ingress](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
119+
| [aws_sns_topic.slack_topic](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sns_topic) | resource |
120+
| [aws_sns_topic_subscription.slack-endpoint](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sns_topic_subscription) | resource |
104121
| [random_password.master](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | resource |
105122
| [archive_file.lambdazip](https://registry.terraform.io/providers/hashicorp/archive/latest/docs/data-sources/file) | data source |
106-
| [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/5.13.1/docs/data-sources/availability_zones) | data source |
107-
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/5.13.1/docs/data-sources/region) | data source |
123+
| [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source |
124+
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
108125

109126
## Inputs
110127

111128
| Name | Description | Type | Default | Required |
112129
|------|-------------|------|---------|:--------:|
113-
| <a name="input_additional_tags"></a> [additional\_tags](#input\_additional\_tags) | A map of additional tags to apply to the AWS resources | `map(string)` | <pre>{<br> "automation": "true"<br>}</pre> | no |
130+
| <a name="input_additional_tags"></a> [additional\_tags](#input\_additional\_tags) | A map of additional tags to apply to the AWS resources | `map(string)` | <pre>{<br/> "automation": "true"<br/>}</pre> | no |
114131
| <a name="input_alarm_actions"></a> [alarm\_actions](#input\_alarm\_actions) | Alarm action list | `list(string)` | `[]` | no |
115132
| <a name="input_alarm_cpu_threshold_percent"></a> [alarm\_cpu\_threshold\_percent](#input\_alarm\_cpu\_threshold\_percent) | CPU threshold alarm level | `number` | `75` | no |
116133
| <a name="input_allocated_storage"></a> [allocated\_storage](#input\_allocated\_storage) | The allocated storage capacity for the database in gibibytes (GiB) | `number` | `20` | no |
@@ -119,8 +136,11 @@ The required IAM permissions to create resources from this module can be found [
119136
| <a name="input_apply_immediately"></a> [apply\_immediately](#input\_apply\_immediately) | Specifies whether any cluster modifications are applied immediately or during the next maintenance window | `bool` | `false` | no |
120137
| <a name="input_backup_retention_period"></a> [backup\_retention\_period](#input\_backup\_retention\_period) | The number of days to retain backups for | `number` | `5` | no |
121138
| <a name="input_backup_window"></a> [backup\_window](#input\_backup\_window) | The preferred window for taking automated backups of the database | `string` | `"03:00-06:00"` | no |
139+
| <a name="input_bucket_provider_type"></a> [bucket\_provider\_type](#input\_bucket\_provider\_type) | Choose what type of provider you want (s3, gcs) | `string` | `"s3"` | no |
122140
| <a name="input_cloudwatch_metric_alarms_enabled"></a> [cloudwatch\_metric\_alarms\_enabled](#input\_cloudwatch\_metric\_alarms\_enabled) | Boolean flag to enable/disable CloudWatch metrics alarms | `bool` | `false` | no |
141+
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | Specifies the name of the EKS cluster to deploy the MySQL application on. | `string` | `""` | no |
123142
| <a name="input_create_db_subnet_group"></a> [create\_db\_subnet\_group](#input\_create\_db\_subnet\_group) | Whether to create a database subnet group | `bool` | `true` | no |
143+
| <a name="input_create_namespace"></a> [create\_namespace](#input\_create\_namespace) | Specify whether or not to create the namespace if it does not already exist. Set it to true to create the namespace. | `string` | `false` | no |
124144
| <a name="input_create_security_group"></a> [create\_security\_group](#input\_create\_security\_group) | Whether to create a security group for the database | `bool` | `true` | no |
125145
| <a name="input_custom_user_password"></a> [custom\_user\_password](#input\_custom\_user\_password) | Custom password for the RDS master user | `string` | `""` | no |
126146
| <a name="input_cw_sns_topic_arn"></a> [cw\_sns\_topic\_arn](#input\_cw\_sns\_topic\_arn) | The username to use when sending notifications to Slack. | `string` | `""` | no |
@@ -143,10 +163,15 @@ The required IAM permissions to create resources from this module can be found [
143163
| <a name="input_max_allocated_storage"></a> [max\_allocated\_storage](#input\_max\_allocated\_storage) | The Maximum storage capacity for the database value after autoscaling | `number` | `null` | no |
144164
| <a name="input_multi_az"></a> [multi\_az](#input\_multi\_az) | Enable multi-AZ for disaster recovery | `bool` | `false` | no |
145165
| <a name="input_name"></a> [name](#input\_name) | The name of the RDS instance | `string` | `""` | no |
166+
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Name of the Kubernetes namespace where the MYSQL deployment will be deployed. | `string` | `"postgresdb"` | no |
146167
| <a name="input_ok_actions"></a> [ok\_actions](#input\_ok\_actions) | The list of actions to execute when this alarm transitions into an OK state from any other state. Each action is specified as an Amazon Resource Number (ARN) | `list(string)` | `[]` | no |
147168
| <a name="input_performance_insights_enabled"></a> [performance\_insights\_enabled](#input\_performance\_insights\_enabled) | Specifies whether Performance Insights are enabled | `bool` | `false` | no |
148169
| <a name="input_performance_insights_retention_period"></a> [performance\_insights\_retention\_period](#input\_performance\_insights\_retention\_period) | The amount of time in days to retain Performance Insights data. Valid values are `7`, `731` (2 years) or a multiple of `31` | `number` | `7` | no |
149170
| <a name="input_port"></a> [port](#input\_port) | The port number for the database | `number` | `5432` | no |
171+
| <a name="input_postgresdb_backup_config"></a> [postgresdb\_backup\_config](#input\_postgresdb\_backup\_config) | configuration options for MySQL database backups. It includes properties such as the S3 bucket URI, the S3 bucket region, and the cron expression for full backups. | `map(string)` | <pre>{<br/> "bucket_uri": "",<br/> "cron_for_full_backup": "",<br/> "postgres_database_name": ""<br/>}</pre> | no |
172+
| <a name="input_postgresdb_backup_enabled"></a> [postgresdb\_backup\_enabled](#input\_postgresdb\_backup\_enabled) | Specifies whether to enable backups for MySQL database. | `bool` | `false` | no |
173+
| <a name="input_postgresdb_restore_config"></a> [postgresdb\_restore\_config](#input\_postgresdb\_restore\_config) | Configuration options for restoring dump to the MySQL database. | `any` | <pre>{<br/> "bucket_uri": "",<br/> "file_name": ""<br/>}</pre> | no |
174+
| <a name="input_postgresdb_restore_enabled"></a> [postgresdb\_restore\_enabled](#input\_postgresdb\_restore\_enabled) | Specifies whether to enable restoring dump to the MySQL database. | `bool` | `false` | no |
150175
| <a name="input_publicly_accessible"></a> [publicly\_accessible](#input\_publicly\_accessible) | Specifies whether the RDS instance is publicly accessible over the internet | `bool` | `false` | no |
151176
| <a name="input_random_password_length"></a> [random\_password\_length](#input\_random\_password\_length) | The length of the randomly generated password for the RDS primary cluster (default: 16) | `number` | `16` | no |
152177
| <a name="input_replica_count"></a> [replica\_count](#input\_replica\_count) | The number of replica instance | `number` | `1` | no |
@@ -171,6 +196,7 @@ The required IAM permissions to create resources from this module can be found [
171196
| <a name="output_db_instance_name"></a> [db\_instance\_name](#output\_db\_instance\_name) | Name of the database instance |
172197
| <a name="output_db_instance_password"></a> [db\_instance\_password](#output\_db\_instance\_password) | Password for accessing the database. |
173198
| <a name="output_db_instance_username"></a> [db\_instance\_username](#output\_db\_instance\_username) | Master username for accessing the database. |
199+
| <a name="output_db_name"></a> [db\_name](#output\_db\_name) | The database name used in the RDS module |
174200
| <a name="output_db_parameter_group_id"></a> [db\_parameter\_group\_id](#output\_db\_parameter\_group\_id) | ID of the parameter group associated with the RDS instance. |
175201
| <a name="output_db_subnet_group_id"></a> [db\_subnet\_group\_id](#output\_db\_subnet\_group\_id) | ID of the subnet group associated with the RDS instance. |
176202
| <a name="output_master_credential_secret_arn"></a> [master\_credential\_secret\_arn](#output\_master\_credential\_secret\_arn) | The ARN of the master user secret (Only available when manage\_master\_user\_password is set to true) |

examples/complete-psql-replica/main.tf

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ locals {
44
family = "postgres15"
55
vpc_cidr = "10.20.0.0/16"
66
environment = "prod"
7+
create_namespace = true
8+
namespace = "postgres"
79
storage_type = "gp3"
810
engine_version = "15.2"
911
instance_class = "db.m5d.large"
@@ -113,4 +115,23 @@ module "rds-pg" {
113115
slack_channel = "postgresql-notification"
114116
slack_webhook_url = "https://hooks/xxxxxxxx"
115117
custom_user_password = local.custom_user_password
118+
#if you want backup and restore then you have to create your cluster with rds vpc , subnet, key_arn.
119+
#And allow cluster security group in rds security group
120+
# cluster_name = "cluster-name"
121+
# namespace = local.namespace
122+
# create_namespace = local.create_namespace
123+
# postgresdb_backup_enabled = false
124+
# postgresdb_backup_config = {
125+
# postgres_database_name = "" # which database backup you want
126+
# s3_bucket_region = "" #s3 bucket region
127+
# cron_for_full_backup = "*/3 * * * *"
128+
# bucket_uri = "s3://xyz" #s3 bucket uri
129+
# }
130+
# postgresdb_restore_enabled = false
131+
# postgresdb_restore_config = {
132+
# bucket_uri = "s3://xyz" #s3 bucket uri which have dackup dump file
133+
# backup_file_name = "abc.dump" #Give only .sql or .zip file for restore
134+
# s3_bucket_region = "" # bucket region
135+
# DB_NAME = "" # which db to restore backup file
136+
# }
116137
}

examples/complete/README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,29 @@ This example will be very useful for users who are new to a module and want to q
1414
| Name | Version |
1515
|------|---------|
1616
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
17-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.43.0 |
17+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.0.0 |
1818

1919
## Providers
2020

2121
| Name | Version |
2222
|------|---------|
23-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.43.0 |
23+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.0.0 |
2424

2525
## Modules
2626

2727
| Name | Source | Version |
2828
|------|--------|---------|
29-
| <a name="module_kms"></a> [kms](#module\_kms) | terraform-aws-modules/kms/aws | n/a |
30-
| <a name="module_rds-pg"></a> [rds-pg](#module\_rds-pg) | ../../ | n/a |
29+
| <a name="module_kms"></a> [kms](#module\_kms) | terraform-aws-modules/kms/aws | ~> 1.0 |
30+
| <a name="module_rds-pg"></a> [rds-pg](#module\_rds-pg) | squareops/rds-postgresql/aws | 2.0.0 |
3131
| <a name="module_vpc"></a> [vpc](#module\_vpc) | squareops/vpc/aws | n/a |
3232

3333
## Resources
3434

3535
| Name | Type |
3636
|------|------|
3737
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
38+
| [aws_eks_cluster.cluster](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eks_cluster) | data source |
39+
| [aws_eks_cluster_auth.cluster](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eks_cluster_auth) | data source |
3840
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
3941

4042
## Inputs
@@ -45,6 +47,7 @@ No inputs.
4547

4648
| Name | Description |
4749
|------|-------------|
50+
| <a name="output_db_name"></a> [db\_name](#output\_db\_name) | Database name |
4851
| <a name="output_instance_endpoint"></a> [instance\_endpoint](#output\_instance\_endpoint) | Connection endpoint of the RDS instance. |
4952
| <a name="output_instance_name"></a> [instance\_name](#output\_instance\_name) | Name of the database instance. |
5053
| <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). |

0 commit comments

Comments
 (0)