Skip to content

Commit

Permalink
feat: Update redis reserved ip range and Add deletion protection to d…
Browse files Browse the repository at this point in the history
…atabase (#92)

* feat: Update redis reserved ip range

* update

* parameterize redis reserved ip range

* Adds instance deletion protection on cloud sql

* terraform-docs: automated action

* fix fmt

* update

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
venky-wandb and github-actions[bot] authored Dec 15, 2023
1 parent d05fc65 commit c5ec027
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 23 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ No resources.
| <a name="input_oidc_issuer"></a> [oidc\_issuer](#input\_oidc\_issuer) | A url to your Open ID Connect identity provider, i.e. https://cognito-idp.us-east-1.amazonaws.com/us-east-1_uiIFNdacd | `string` | `""` | no |
| <a name="input_oidc_secret"></a> [oidc\_secret](#input\_oidc\_secret) | The Client secret of application in your identity provider | `string` | `""` | no |
| <a name="input_other_wandb_env"></a> [other\_wandb\_env](#input\_other\_wandb\_env) | Extra environment variables for W&B | `map(string)` | `{}` | no |
| <a name="input_redis_reserved_ip_range"></a> [redis\_reserved\_ip\_range](#input\_redis\_reserved\_ip\_range) | Reserved IP range for REDIS peering connection | `string` | `"10.30.0.0/16"` | no |
| <a name="input_resource_limits"></a> [resource\_limits](#input\_resource\_limits) | Specifies the resource limits for the wandb deployment | `map(string)` | <pre>{<br> "cpu": null,<br> "memory": null<br>}</pre> | no |
| <a name="input_resource_requests"></a> [resource\_requests](#input\_resource\_requests) | Specifies the resource requests for the wandb deployment | `map(string)` | <pre>{<br> "cpu": "2000m",<br> "memory": "2G"<br>}</pre> | no |
| <a name="input_ssl"></a> [ssl](#input\_ssl) | Enable SSL certificate | `bool` | `true` | no |
Expand Down
31 changes: 16 additions & 15 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ module "app_gke" {


module "app_lb" {
source = "./modules/app_lb"
namespace = var.namespace
ssl = var.ssl
fqdn = local.fqdn
network = local.network
group = module.app_gke.instance_group_url
service_account = module.service_accounts.service_account
labels = var.labels
source = "./modules/app_lb"
namespace = var.namespace
ssl = var.ssl
fqdn = local.fqdn
network = local.network
group = module.app_gke.instance_group_url
service_account = module.service_accounts.service_account
labels = var.labels
allowed_inbound_cidrs = var.allowed_inbound_cidrs

depends_on = [module.project_factory_project_services, module.app_gke]
Expand All @@ -116,12 +116,13 @@ module "database" {
}

module "redis" {
count = var.create_redis ? 1 : 0
source = "./modules/redis"
namespace = var.namespace
memory_size_gb = 4
network = local.network
labels = var.labels
count = var.create_redis ? 1 : 0
source = "./modules/redis"
namespace = var.namespace
memory_size_gb = 4
network = local.network
reserved_ip_range = var.redis_reserved_ip_range
labels = var.labels
}

locals {
Expand Down Expand Up @@ -152,7 +153,7 @@ module "gke_app" {
oidc_secret = var.oidc_secret
local_restore = var.local_restore
other_wandb_env = merge({
"GORILLA_DISABLE_CODE_SAVING" = var.disable_code_saving,
"GORILLA_DISABLE_CODE_SAVING" = var.disable_code_saving,
"GORILLA_CUSTOMER_SECRET_STORE_SOURCE" = local.secret_store_source
}, var.other_wandb_env)

Expand Down
7 changes: 4 additions & 3 deletions modules/database/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ resource "google_sql_database_instance" "default" {
deletion_protection = var.deletion_protection

settings {
tier = var.tier
availability_type = var.availability_type
user_labels = var.labels
tier = var.tier
availability_type = var.availability_type
user_labels = var.labels
deletion_protection_enabled = var.deletion_protection

backup_configuration {
binary_log_enabled = true
Expand Down
2 changes: 1 addition & 1 deletion modules/redis/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ resource "google_redis_instance" "default" {
authorized_network = var.network.id

redis_version = "REDIS_6_X"
reserved_ip_range = "10.30.0.0/16"
reserved_ip_range = var.reserved_ip_range

transit_encryption_mode = "SERVER_AUTHENTICATION"
connect_mode = "DIRECT_PEERING"
Expand Down
5 changes: 5 additions & 0 deletions modules/redis/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,9 @@ variable "network" {
variable "memory_size_gb" {
description = "The amount of memory which will be allocated to the Redis instance; this value must be expressed in gibibytes."
type = number
}

variable "reserved_ip_range" {
description = "This defines the IP range for REDIS peering connection"
type = string
}
8 changes: 4 additions & 4 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ output "cluster_ca_certificate" {
}

output "cluster_client_certificate" {
sensitive = true
value = module.app_gke.cluster_client_certificate
sensitive = true
value = module.app_gke.cluster_client_certificate
}

output "cluster_client_key" {
sensitive = true
value = module.app_gke.cluster_client_key
sensitive = true
value = module.app_gke.cluster_client_key
}
output "cluster_endpoint" {
value = module.app_gke.cluster_endpoint
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ variable "create_redis" {
default = false
}

variable "redis_reserved_ip_range" {
type = string
description = "Reserved IP range for REDIS peering connection"
default = "10.30.0.0/16"
}

##########################################
# External Bucket #
##########################################
Expand Down

0 comments on commit c5ec027

Please sign in to comment.