Skip to content

Commit 205d9cf

Browse files
authored
Merge pull request #20 from amanravi-squareops/release-v1.1.5
Release v1.1.8
2 parents 0790544 + 367ac41 commit 205d9cf

File tree

15 files changed

+98
-58
lines changed

15 files changed

+98
-58
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ Security scanning is graciously provided by Prowler. Proowler is the leading ful
116116

117117
| Name | Source | Version |
118118
|------|--------|---------|
119+
| <a name="module_backup_restore"></a> [backup\_restore](#module\_backup\_restore) | ./modules/db-backup-restore | n/a |
119120
| <a name="module_cw_sns_slack"></a> [cw\_sns\_slack](#module\_cw\_sns\_slack) | ./lambda | n/a |
120121
| <a name="module_db"></a> [db](#module\_db) | terraform-aws-modules/rds/aws | 6.1.0 |
121122
| <a name="module_db_replica"></a> [db\_replica](#module\_db\_replica) | terraform-aws-modules/rds/aws | 6.1.0 |
@@ -152,9 +153,12 @@ Security scanning is graciously provided by Prowler. Proowler is the leading ful
152153
| <a name="input_availability_zone"></a> [availability\_zone](#input\_availability\_zone) | The Availability Zone of the RDS instance | `string` | `null` | no |
153154
| <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 |
154155
| <a name="input_backup_window"></a> [backup\_window](#input\_backup\_window) | The time window during which database backups are performed | `string` | `"03:00-06:00"` | no |
156+
| <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 |
155157
| <a name="input_cloudwatch_log_group_retention_in_days"></a> [cloudwatch\_log\_group\_retention\_in\_days](#input\_cloudwatch\_log\_group\_retention\_in\_days) | The number of days to retain CloudWatch logs for the database instance | `number` | `7` | no |
156158
| <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 |
159+
| <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 |
157160
| <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 |
161+
| <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 |
158162
| <a name="input_create_random_password"></a> [create\_random\_password](#input\_create\_random\_password) | Whether to create a random password for the primary database cluster | `bool` | `false` | no |
159163
| <a name="input_custom_user_password"></a> [custom\_user\_password](#input\_custom\_user\_password) | Custom password for the RDS master user | `string` | `""` | no |
160164
| <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 |
@@ -177,7 +181,12 @@ Security scanning is graciously provided by Prowler. Proowler is the leading ful
177181
| <a name="input_master_username"></a> [master\_username](#input\_master\_username) | The username for the RDS primary cluster | `string` | `""` | no |
178182
| <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 |
179183
| <a name="input_multi_az"></a> [multi\_az](#input\_multi\_az) | Enables multi-AZ for disaster recovery | `bool` | `false` | no |
184+
| <a name="input_mysqldb_backup_config"></a> [mysqldb\_backup\_config](#input\_mysqldb\_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/> "mysql_database_name": "",<br/> "s3_bucket_region": ""<br/>}</pre> | no |
185+
| <a name="input_mysqldb_backup_enabled"></a> [mysqldb\_backup\_enabled](#input\_mysqldb\_backup\_enabled) | Specifies whether to enable backups for MySQL database. | `bool` | `false` | no |
186+
| <a name="input_mysqldb_restore_config"></a> [mysqldb\_restore\_config](#input\_mysqldb\_restore\_config) | Configuration options for restoring dump to the MySQL database. | `any` | <pre>{<br/> "bucket_uri": "",<br/> "file_name": "",<br/> "s3_bucket_region": ""<br/>}</pre> | no |
187+
| <a name="input_mysqldb_restore_enabled"></a> [mysqldb\_restore\_enabled](#input\_mysqldb\_restore\_enabled) | Specifies whether to enable restoring dump to the MySQL database. | `bool` | `false` | no |
180188
| <a name="input_name"></a> [name](#input\_name) | The name of the RDS instance | `string` | `""` | no |
189+
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Name of the Kubernetes namespace where the MYSQL deployment will be deployed. | `string` | `"mysqldb"` | no |
181190
| <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 |
182191
| <a name="input_port"></a> [port](#input\_port) | The port for the database | `number` | `3306` | no |
183192
| <a name="input_publicly_accessible"></a> [publicly\_accessible](#input\_publicly\_accessible) | Specifies whether the database is publicly accessible over the internet | `bool` | `false` | no |

examples/complete-mysql/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,16 @@ This example will be very useful for users who are new to a module and want to q
2626
| Name | Source | Version |
2727
|------|--------|---------|
2828
| <a name="module_kms"></a> [kms](#module\_kms) | terraform-aws-modules/kms/aws | n/a |
29-
| <a name="module_rds-mysql"></a> [rds-mysql](#module\_rds-mysql) | terraform-aws-modules/rds/aws | n/a |
29+
| <a name="module_rds-mysql"></a> [rds-mysql](#module\_rds-mysql) | squareops/rds-mysql/aws | n/a |
3030
| <a name="module_vpc"></a> [vpc](#module\_vpc) | squareops/vpc/aws | n/a |
3131

3232
## Resources
3333

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

3941
## Inputs

examples/complete-mysql/helm/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ restorejob:
4545
cpu: 50m
4646
limits:
4747
memory: 200Mi
48-
cpu: 100m
48+
cpu: 100m

examples/complete-mysql/main.tf

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ locals {
44
availability_zone = "us-east-1a"
55
family = "mysql8.0"
66
environment = "prod"
7+
cluster_name = ""
78
create_namespace = true
89
namespace = "mysql"
910
mysql_instance_class = "db.t3.micro"
@@ -101,6 +102,7 @@ module "vpc" {
101102

102103
module "rds-mysql" {
103104
source = "squareops/rds-mysql/aws"
105+
version = "1.1.8"
104106
name = local.name
105107
vpc_id = module.vpc.vpc_id
106108
family = local.family
@@ -134,21 +136,18 @@ module "rds-mysql" {
134136
slack_channel = "mysql-notification"
135137
slack_webhook_url = "https://hooks/xxxxxxxx"
136138
custom_user_password = local.custom_user_password
137-
cluster_name = "" # cluster name
139+
cluster_name = local.cluster_name # cluster name
138140
namespace = local.namespace
139141
create_namespace = local.create_namespace
140142
mysqldb_backup_enabled = false
141-
bucket_provider_type = "s3"
142143
mysqldb_backup_config = {
143-
mysql_database_name = ""
144-
s3_bucket_region = "us-west-1"
145-
cron_for_full_backup = "0 */6 * * *"
146-
bucket_uri = "s3://mysql-rds-backup-store/"
144+
mysql_database_name = "" # specify the database name to backup or leave it empty to backup all databases
145+
cron_for_full_backup = "0 */6 * * *" # cron expression for full backup
146+
bucket_uri = "s3://atmosly-rds-backup-test/" # s3 bucket uri with / at the end
147147
}
148148
mysqldb_restore_enabled = false
149149
mysqldb_restore_config = {
150-
bucket_uri = "s3://mysql-rds-backup-store/mysqldump_20240723_074237.zip"
151-
file_name = "mysqldump_20240723_074237.zip"
152-
s3_bucket_region = "us-west-1"
150+
bucket_uri = "s3://atmosly-rds-backup-test/" # s3 bucket uri with / at the end
151+
file_name = "mysqldump_20250312_145032.zip" # file name to restore , provide only .sql or .zip file
153152
}
154153
}

examples/complete-mysql/provider.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ provider "aws" {
66
}
77

88
data "aws_eks_cluster" "cluster" {
9-
name = ""
9+
name = local.cluster_name
1010

1111
}
1212
data "aws_eks_cluster_auth" "cluster" {
13-
name = ""
13+
name = local.cluster_name
1414
}
1515

1616
provider "kubernetes" {

helm/values/backup/values.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
## Enable Full backup
22
backup:
33
bucket_uri: ${bucket_uri}
4-
aws_default_region: ${s3_bucket_region}
54
cron_for_full_backup: "${cron_for_full_backup}"
65
database_name: "${mysql_database_name}"
76
database_endpoint: "${db_endpoint}"
87
database_password: "${db_password}"
98
database_user: "${db_username}"
10-
provider: "${bucket_provider_type}"
9+
1110

1211

1312
annotations:
@@ -16,7 +15,6 @@ annotations:
1615
auth:
1716
username: "${custom_user_username}"
1817

19-
bucket_provider_type: ${bucket_provider_type}
2018

2119
affinity:
2220
nodeAffinity:

helm/values/restore/values.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
restore:
22
file_name: ${file_name}
33
bucket_uri: ${bucket_uri}
4-
aws_default_region: ${s3_bucket_region}
5-
bucket_provider : ${bucket_provider_type}
64
database_endpoint: "${db_endpoint}"
75
database_password: "${db_password}"
86
database_user: "${db_username}"
@@ -13,7 +11,6 @@ auth:
1311
annotations:
1412
${annotations}
1513

16-
bucket_provider_type: ${bucket_provider_type}
1714

1815
affinity:
1916
nodeAffinity:

main.tf

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -327,19 +327,17 @@ module "backup_restore" {
327327
db_username = module.db.db_instance_username
328328
db_password = var.custom_user_password != "" ? var.custom_user_password : nonsensitive(random_password.master[0].result)
329329
mysql_database_name = var.mysqldb_backup_config.mysql_database_name
330-
s3_bucket_region = var.mysqldb_backup_config.s3_bucket_region
331330
cron_for_full_backup = var.mysqldb_backup_config.cron_for_full_backup
332331
bucket_uri = var.mysqldb_backup_config.bucket_uri
333332
db_endpoint = replace(module.db.db_instance_endpoint, ":3306", "")
334333
}
335334

336335
mysqldb_restore_enabled = var.mysqldb_restore_enabled
337336
mysqldb_restore_config = {
338-
db_endpoint = replace(module.db.db_instance_endpoint, ":3306", "")
339-
db_username = module.db.db_instance_username
340-
db_password = var.custom_user_password != "" ? var.custom_user_password : nonsensitive(random_password.master[0].result)
341-
bucket_uri = var.mysqldb_restore_config.bucket_uri
342-
file_name = var.mysqldb_restore_config.file_name
343-
s3_bucket_region = var.mysqldb_restore_config.s3_bucket_region
337+
db_endpoint = replace(module.db.db_instance_endpoint, ":3306", "")
338+
db_username = module.db.db_instance_username
339+
db_password = var.custom_user_password != "" ? var.custom_user_password : nonsensitive(random_password.master[0].result)
340+
bucket_uri = var.mysqldb_restore_config.bucket_uri
341+
file_name = var.mysqldb_restore_config.file_name
344342
}
345343
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# db-backup-restore
2+
3+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
4+
## Requirements
5+
6+
No requirements.
7+
8+
## Providers
9+
10+
| Name | Version |
11+
|------|---------|
12+
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a |
13+
| <a name="provider_helm"></a> [helm](#provider\_helm) | n/a |
14+
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | n/a |
15+
16+
## Modules
17+
18+
No modules.
19+
20+
## Resources
21+
22+
| Name | Type |
23+
|------|------|
24+
| [aws_iam_role.mysql_backup_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
25+
| [aws_iam_role.mysql_restore_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
26+
| [helm_release.mysqldb_backup](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
27+
| [helm_release.mysqldb_restore](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
28+
| [kubernetes_namespace.mysqldb](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/namespace) | resource |
29+
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
30+
| [aws_eks_cluster.kubernetes_cluster](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eks_cluster) | data source |
31+
32+
## Inputs
33+
34+
| Name | Description | Type | Default | Required |
35+
|------|-------------|------|---------|:--------:|
36+
| <a name="input_azure_container_name"></a> [azure\_container\_name](#input\_azure\_container\_name) | Azure container name | `string` | `""` | no |
37+
| <a name="input_azure_storage_account_key"></a> [azure\_storage\_account\_key](#input\_azure\_storage\_account\_key) | Azure storage account key | `string` | `""` | no |
38+
| <a name="input_azure_storage_account_name"></a> [azure\_storage\_account\_name](#input\_azure\_storage\_account\_name) | Azure storage account name | `string` | `""` | no |
39+
| <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 |
40+
| <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 |
41+
| <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 |
42+
| <a name="input_iam_role_arn_backup"></a> [iam\_role\_arn\_backup](#input\_iam\_role\_arn\_backup) | IAM role ARN for backup (AWS) | `string` | `""` | no |
43+
| <a name="input_iam_role_arn_restore"></a> [iam\_role\_arn\_restore](#input\_iam\_role\_arn\_restore) | IAM role ARN for restore (AWS) | `string` | `""` | no |
44+
| <a name="input_mysqldb_backup_config"></a> [mysqldb\_backup\_config](#input\_mysqldb\_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/> "mysql_database_name": "",<br/> "s3_bucket_region": ""<br/>}</pre> | no |
45+
| <a name="input_mysqldb_backup_enabled"></a> [mysqldb\_backup\_enabled](#input\_mysqldb\_backup\_enabled) | Specifies whether to enable backups for MySQL database. | `bool` | `false` | no |
46+
| <a name="input_mysqldb_permission"></a> [mysqldb\_permission](#input\_mysqldb\_permission) | access | `bool` | `false` | no |
47+
| <a name="input_mysqldb_restore_config"></a> [mysqldb\_restore\_config](#input\_mysqldb\_restore\_config) | Configuration options for restoring dump to the MySQL database. | `any` | <pre>{<br/> "bucket_uri": "",<br/> "file_name": "",<br/> "s3_bucket_region": ""<br/>}</pre> | no |
48+
| <a name="input_mysqldb_restore_enabled"></a> [mysqldb\_restore\_enabled](#input\_mysqldb\_restore\_enabled) | Specifies whether to enable restoring dump to the MySQL database. | `bool` | `false` | no |
49+
| <a name="input_name"></a> [name](#input\_name) | Name identifier for module to be added as suffix to resources | `string` | `"test"` | no |
50+
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Name of the Kubernetes namespace where the MYSQL deployment will be deployed. | `string` | `"mysqldb"` | no |
51+
| <a name="input_service_account_backup"></a> [service\_account\_backup](#input\_service\_account\_backup) | Service account for backup (GCP) | `string` | `""` | no |
52+
| <a name="input_service_account_restore"></a> [service\_account\_restore](#input\_service\_account\_restore) | Service account for restore (GCP) | `string` | `""` | no |
53+
54+
## Outputs
55+
56+
No outputs.
57+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

modules/db-backup-restore/backup/templates/cronjob.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ spec:
2020
serviceAccountName: sa-mysql-backup
2121
containers:
2222
- name: backup-mysqldb
23-
image: amanmall/mysqldb-backup:v1
23+
image: squareops01/rds-mysql-backup:v2
2424
imagePullPolicy: Always
2525
env:
2626
- name: MYSQL_HOST
@@ -33,8 +33,4 @@ spec:
3333
value: {{ .Values.backup.database_password }}
3434
- name: MYSQL_BUCKET_URI
3535
value: {{ .Values.backup.bucket_uri }}
36-
- name: BUCKET_PROVIDER
37-
value: {{ .Values.backup.provider }}
38-
- name: AWS_DEFAULT_REGION
39-
value: {{ .Values.backup.aws_default_region}}
4036
resources: {{ .Values.backupjob.resources | toYaml | nindent 12 }}

0 commit comments

Comments
 (0)