Skip to content

Commit c337564

Browse files
committed
update examples for aws and gcp
1 parent e29709f commit c337564

File tree

23 files changed

+473
-200
lines changed

23 files changed

+473
-200
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,10 @@ No requirements.
8585
|------|---------|
8686
| <a name="provider_helm"></a> [helm](#provider\_helm) | n/a |
8787
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | n/a |
88-
| <a name="provider_random"></a> [random](#provider\_random) | n/a |
8988

9089
## Modules
9190

92-
| Name | Source | Version |
93-
|------|--------|---------|
94-
| <a name="module_aws"></a> [aws](#module\_aws) | ./provider/aws | n/a |
95-
| <a name="module_gcp"></a> [gcp](#module\_gcp) | ./provider/gcp | n/a |
91+
No modules.
9692

9793
## Resources
9894

@@ -102,10 +98,6 @@ No requirements.
10298
| [helm_release.mysqldb_backup](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
10399
| [helm_release.mysqldb_restore](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
104100
| [kubernetes_namespace.mysqldb](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/namespace) | resource |
105-
| [random_password.mysqldb_custom_user_password](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | resource |
106-
| [random_password.mysqldb_exporter_user_password](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | resource |
107-
| [random_password.mysqldb_replication_user_password](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | resource |
108-
| [random_password.mysqldb_root_password](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | resource |
109101

110102
## Inputs
111103

@@ -116,17 +108,25 @@ No requirements.
116108
| <a name="input_chart_version"></a> [chart\_version](#input\_chart\_version) | Version of the Mysql chart that will be used to deploy MySQL application. | `string` | `"9.2.0"` | no |
117109
| <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 |
118110
| <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` | `true` | no |
111+
| <a name="input_custom_user_password"></a> [custom\_user\_password](#input\_custom\_user\_password) | custom user password for MongoDB | `string` | `""` | no |
112+
| <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 |
113+
| <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 |
114+
| <a name="input_metric_exporter_pasword"></a> [metric\_exporter\_pasword](#input\_metric\_exporter\_pasword) | Metric exporter password for MongoDB | `string` | `""` | no |
119115
| <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. | `any` | <pre>{<br> "bucket_uri": "",<br> "cron_for_full_backup": "",<br> "s3_bucket_region": ""<br>}</pre> | no |
120116
| <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 |
121117
| <a name="input_mysqldb_config"></a> [mysqldb\_config](#input\_mysqldb\_config) | Specify the configuration settings for MySQL, including the name, environment, storage options, replication settings, and custom YAML values. | `any` | <pre>{<br> "architecture": "",<br> "custom_user_username": "",<br> "environment": "",<br> "name": "",<br> "primary_db_volume_size": "",<br> "secondary_db_replica_count": 1,<br> "secondary_db_volume_size": "",<br> "storage_class_name": "",<br> "store_password_to_secret_manager": true,<br> "values_yaml": ""<br>}</pre> | no |
122118
| <a name="input_mysqldb_custom_credentials_config"></a> [mysqldb\_custom\_credentials\_config](#input\_mysqldb\_custom\_credentials\_config) | Specify the configuration settings for MySQL to pass custom credentials during creation | `any` | <pre>{<br> "custom_user_password": "",<br> "custom_username": "",<br> "exporter_password": "",<br> "exporter_user": "",<br> "replication_password": "",<br> "replication_user": "",<br> "root_password": "",<br> "root_user": ""<br>}</pre> | no |
123119
| <a name="input_mysqldb_custom_credentials_enabled"></a> [mysqldb\_custom\_credentials\_enabled](#input\_mysqldb\_custom\_credentials\_enabled) | Specifies whether to enable custom credentials for MySQL database. | `bool` | `false` | no |
124120
| <a name="input_mysqldb_exporter_enabled"></a> [mysqldb\_exporter\_enabled](#input\_mysqldb\_exporter\_enabled) | Specify whether or not to deploy Mysql exporter to collect Mysql metrics for monitoring in Grafana. | `bool` | `false` | no |
121+
| <a name="input_mysqldb_replication_user_password"></a> [mysqldb\_replication\_user\_password](#input\_mysqldb\_replication\_user\_password) | Replicator password for MongoDB | `string` | `""` | no |
125122
| <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 |
126123
| <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 |
127124
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Name of the Kubernetes namespace where the MYSQL deployment will be deployed. | `string` | `"mysqldb"` | no |
128125
| <a name="input_project_id"></a> [project\_id](#input\_project\_id) | Google Cloud project ID | `string` | `""` | no |
129126
| <a name="input_recovery_window_aws_secret"></a> [recovery\_window\_aws\_secret](#input\_recovery\_window\_aws\_secret) | Number of days that AWS Secrets Manager will wait before deleting a secret. This value can be set to 0 to force immediate deletion, or to a value between 7 and 30 days to allow for recovery. | `number` | `0` | no |
127+
| <a name="input_root_password"></a> [root\_password](#input\_root\_password) | Root password for MongoDB | `string` | `""` | no |
128+
| <a name="input_service_account_backup"></a> [service\_account\_backup](#input\_service\_account\_backup) | Service account for backup (GCP) | `string` | `""` | no |
129+
| <a name="input_service_account_restore"></a> [service\_account\_restore](#input\_service\_account\_restore) | Service account for restore (GCP) | `string` | `""` | no |
130130

131131
## Outputs
132132

examples/complete/aws/README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
## Mysql Example
2+
![squareops_avatar]
3+
4+
[squareops_avatar]: https://squareops.com/wp-content/uploads/2022/12/squareops-logo.png
5+
6+
### [SquareOps Technologies](https://squareops.com/) Your DevOps Partner for Accelerating cloud journey.
7+
<br>
8+
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.
9+
10+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
11+
## Requirements
12+
13+
No requirements.
14+
15+
## Providers
16+
17+
| Name | Version |
18+
|------|---------|
19+
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a |
20+
21+
## Modules
22+
23+
| Name | Source | Version |
24+
|------|--------|---------|
25+
| <a name="module_aws"></a> [aws](#module\_aws) | squareops/mysql/kubernetes//provider/aws | n/a |
26+
| <a name="module_mysql"></a> [mysql](#module\_mysql) | squareops/mysql/kubernetes | n/a |
27+
28+
## Resources
29+
30+
| Name | Type |
31+
|------|------|
32+
| [aws_eks_cluster.cluster](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eks_cluster) | data source |
33+
| [aws_eks_cluster_auth.cluster](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eks_cluster_auth) | data source |
34+
35+
## Inputs
36+
37+
No inputs.
38+
39+
## Outputs
40+
41+
| Name | Description |
42+
|------|-------------|
43+
| <a name="output_mysql_credential"></a> [mysql\_credential](#output\_mysql\_credential) | MySQL credentials used for accessing the MySQL database. |
44+
| <a name="output_mysql_endpoints"></a> [mysql\_endpoints](#output\_mysql\_endpoints) | MySQL endpoints in the Kubernetes cluster. |
45+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
File renamed without changes.

examples/complete/aws/main.tf

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
locals {
2+
name = "mysql"
3+
region = "us-east-2"
4+
environment = "prod"
5+
additional_tags = {
6+
Owner = "organization_name"
7+
Expires = "Never"
8+
Department = "Engineering"
9+
}
10+
store_password_to_secret_manager = true
11+
mysqldb_custom_credentials_enabled = false
12+
mysqldb_custom_credentials_config = {
13+
root_user = "root"
14+
root_password = "RJDRIFsYC8ZS1WQuV0ps"
15+
custom_username = "admin"
16+
custom_user_password = "NCPFUKEMd7rrWuvMAa73"
17+
replication_user = "replicator"
18+
replication_password = "nvAHhm1uGQNYWVw6ZyAH"
19+
exporter_user = "mysqld_exporter"
20+
exporter_password = "ZawhvpueAehRdKFlbjaq"
21+
}
22+
custom_user_username = "custom"
23+
}
24+
25+
module "aws" {
26+
source = "squareops/mysql/kubernetes//provider/aws"
27+
cluster_name = ""
28+
environment = local.environment
29+
name = local.name
30+
store_password_to_secret_manager = local.store_password_to_secret_manager
31+
mysqldb_custom_credentials_enabled = local.mysqldb_custom_credentials_enabled
32+
mysqldb_custom_credentials_config = local.mysqldb_custom_credentials_config
33+
custom_user_username = local.mysqldb_custom_credentials_enabled ? "" : local.custom_user_username
34+
}
35+
36+
module "mysql" {
37+
source = "squareops/mysql/kubernetes"
38+
mysqldb_config = {
39+
name = local.name
40+
values_yaml = file("./helm/values.yaml")
41+
environment = local.environment
42+
architecture = "replication"
43+
storage_class_name = "gp3"
44+
custom_user_username = local.mysqldb_custom_credentials_enabled ? "" : local.custom_user_username
45+
primary_db_volume_size = "10Gi"
46+
secondary_db_volume_size = "10Gi"
47+
secondary_db_replica_count = 2
48+
store_password_to_secret_manager = local.store_password_to_secret_manager
49+
}
50+
mysqldb_custom_credentials_enabled = local.mysqldb_custom_credentials_enabled
51+
mysqldb_custom_credentials_config = local.mysqldb_custom_credentials_config
52+
root_password = local.mysqldb_custom_credentials_enabled ? "" : module.aws.root_password
53+
metric_exporter_pasword = local.mysqldb_custom_credentials_enabled ? "" : module.aws.metric_exporter_pasword
54+
mysqldb_replication_user_password = local.mysqldb_custom_credentials_enabled ? "" : module.aws.mysqldb_replication_user_password
55+
custom_user_password = local.mysqldb_custom_credentials_enabled ? "" : module.aws.custom_user_password
56+
bucket_provider_type = "s3"
57+
iam_role_arn_backup = module.aws.iam_role_arn_backup
58+
mysqldb_backup_enabled = true
59+
mysqldb_backup_config = {
60+
bucket_uri = "s3://bucket_name"
61+
s3_bucket_region = ""
62+
cron_for_full_backup = "*/5 * * * *"
63+
}
64+
mysqldb_restore_enabled = true
65+
iam_role_arn_restore = module.aws.iam_role_arn_restore
66+
mysqldb_restore_config = {
67+
bucket_uri = "s3://bucket_name/mysqldump_20230710_120501.zip"
68+
file_name = "mysqldump_20230710_120501.zip"
69+
s3_bucket_region = ""
70+
}
71+
mysqldb_exporter_enabled = true
72+
}
File renamed without changes.

examples/complete/provider-aws.tf renamed to examples/complete/aws/provider.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
provider "s3" {
1+
provider "aws" {
22
region = local.region
33
default_tags {
44
tags = local.additional_tags

examples/complete/README.md renamed to examples/complete/gcp/README.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@
77
<br>
88
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.
99

10-
## Usage
11-
12-
Use the provider file as per your need.
13-
- If deploying into AWS EKS use `provider-aws.tf` file and remove `provider-gcp.tf` file.
14-
- If deploying into Google GKE use `provider-gcp.tf` file and remove `provider-aws.tf` file.
1510
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
1611
## Requirements
1712

@@ -21,21 +16,19 @@ No requirements.
2116

2217
| Name | Version |
2318
|------|---------|
24-
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a |
2519
| <a name="provider_google"></a> [google](#provider\_google) | n/a |
2620

2721
## Modules
2822

2923
| Name | Source | Version |
3024
|------|--------|---------|
25+
| <a name="module_gcp"></a> [gcp](#module\_gcp) | squareops/mysql/kubernetes//provider/gcp | n/a |
3126
| <a name="module_mysql"></a> [mysql](#module\_mysql) | squareops/mysql/kubernetes | n/a |
3227

3328
## Resources
3429

3530
| Name | Type |
3631
|------|------|
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 |
3932
| [google_client_config.default](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/client_config) | data source |
4033
| [google_container_cluster.primary](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/container_cluster) | data source |
4134

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
primary:
2+
affinity:
3+
nodeAffinity:
4+
requiredDuringSchedulingIgnoredDuringExecution:
5+
nodeSelectorTerms:
6+
- matchExpressions:
7+
- key: "Infra-Services"
8+
operator: In
9+
values:
10+
- "true"
11+
12+
secondary:
13+
affinity:
14+
nodeAffinity:
15+
requiredDuringSchedulingIgnoredDuringExecution:
16+
nodeSelectorTerms:
17+
- matchExpressions:
18+
- key: "Infra-Services"
19+
operator: In
20+
values:
21+
- "true"

examples/complete/gcp/main.tf

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
locals {
2+
name = "mysql"
3+
region = "us-east-2"
4+
environment = "prod"
5+
additional_tags = {
6+
Owner = "organization_name"
7+
Expires = "Never"
8+
Department = "Engineering"
9+
}
10+
store_password_to_secret_manager = true
11+
mysqldb_custom_credentials_enabled = false
12+
mysqldb_custom_credentials_config = {
13+
root_user = "root"
14+
root_password = "RJDRIFsYC8ZS1WQuV0ps"
15+
custom_username = "admin"
16+
custom_user_password = "NCPFUKEMd7rrWuvMAa73"
17+
replication_user = "replicator"
18+
replication_password = "nvAHhm1uGQNYWVw6ZyAH"
19+
exporter_user = "mysqld_exporter"
20+
exporter_password = "ZawhvpueAehRdKFlbjaq"
21+
}
22+
custom_user_username = "custom"
23+
}
24+
25+
module "gcp" {
26+
source = "squareops/mysql/kubernetes//provider/gcp"
27+
project_id = "fresh-sanctuary-387476" #for gcp
28+
environment = local.environment
29+
name = local.name
30+
store_password_to_secret_manager = local.store_password_to_secret_manager
31+
mysqldb_custom_credentials_enabled = local.mysqldb_custom_credentials_enabled
32+
mysqldb_custom_credentials_config = local.mysqldb_custom_credentials_config
33+
custom_user_username = local.mysqldb_custom_credentials_enabled ? "" : local.custom_user_username
34+
}
35+
36+
module "mysql" {
37+
source = "squareops/mysql/kubernetes"
38+
mysqldb_config = {
39+
name = local.name
40+
values_yaml = file("./helm/values.yaml")
41+
environment = local.environment
42+
architecture = "replication"
43+
storage_class_name = "standard"
44+
custom_user_username = local.mysqldb_custom_credentials_enabled ? "" : local.custom_user_username
45+
primary_db_volume_size = "10Gi"
46+
secondary_db_volume_size = "10Gi"
47+
secondary_db_replica_count = 2
48+
store_password_to_secret_manager = local.store_password_to_secret_manager
49+
}
50+
mysqldb_custom_credentials_enabled = local.mysqldb_custom_credentials_enabled
51+
mysqldb_custom_credentials_config = local.mysqldb_custom_credentials_config
52+
root_password = local.mysqldb_custom_credentials_enabled ? "" : module.gcp.root_password
53+
metric_exporter_pasword = local.mysqldb_custom_credentials_enabled ? "" : module.gcp.metric_exporter_pasword
54+
mysqldb_replication_user_password = local.mysqldb_custom_credentials_enabled ? "" : module.gcp.mysqldb_replication_user_password
55+
custom_user_password = local.mysqldb_custom_credentials_enabled ? "" : module.gcp.custom_user_password
56+
bucket_provider_type = "gcs"
57+
service_account_backup = module.gcp.service_account_backup
58+
service_account_restore = module.gcp.service_account_restore
59+
mysqldb_backup_enabled = true
60+
mysqldb_backup_config = {
61+
bucket_uri = "gs://mysql-backup-skaf"
62+
s3_bucket_region = ""
63+
cron_for_full_backup = "*/5 * * * *"
64+
}
65+
mysqldb_restore_enabled = true
66+
mysqldb_restore_config = {
67+
bucket_uri = "gs://mysql-backup-skaf/mysqldump_20230710_120501.zip"
68+
file_name = "mysqldump_20230710_120501.zip"
69+
s3_bucket_region = ""
70+
}
71+
mysqldb_exporter_enabled = true
72+
}

examples/complete/gcp/output.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
output "mysql_endpoints" {
2+
value = module.mysql.mysqldb_endpoints
3+
description = "MySQL endpoints in the Kubernetes cluster."
4+
}
5+
6+
output "mysql_credential" {
7+
value = local.store_password_to_secret_manager ? null : module.mysql.mysqldb_credential
8+
description = "MySQL credentials used for accessing the MySQL database."
9+
}

0 commit comments

Comments
 (0)