diff --git a/README.md b/README.md index 7d2f0eb..9e6c230 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,7 @@ No providers. | [kms](#module\_kms) | ./modules/kms | n/a | | [networking](#module\_networking) | ./modules/networking | n/a | | [project\_factory\_project\_services](#module\_project\_factory\_project\_services) | terraform-google-modules/project-factory/google//modules/project_services | ~> 11.3 | +| [redis](#module\_redis) | ./modules/redis | n/a | | [service\_accounts](#module\_service\_accounts) | ./modules/service_accounts | n/a | ## Resources @@ -95,6 +96,7 @@ No resources. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| +| [create\_redis](#input\_create\_redis) | Boolean indicating whether to provision an redis instance (true) or not (false). | `bool` | `false` | no | | [database\_version](#input\_database\_version) | Version for MySQL | `string` | `"MYSQL_8_0"` | no | | [deletion\_protection](#input\_deletion\_protection) | If the instance should have deletion protection enabled. The database / Bucket can't be deleted when this value is set to `true`. | `bool` | `true` | no | | [domain\_name](#input\_domain\_name) | Domain for accessing the Weights & Biases UI. | `string` | `null` | no | diff --git a/examples/public-dns-with-cloud-dns/main.tf b/examples/public-dns-with-cloud-dns/main.tf index 5851308..46fa576 100644 --- a/examples/public-dns-with-cloud-dns/main.tf +++ b/examples/public-dns-with-cloud-dns/main.tf @@ -27,6 +27,12 @@ module "wandb" { domain_name = var.domain subdomain = var.subdomain + wandb_version = var.wandb_version + wandb_image = var.wandb_image + + create_redis = true + use_internal_queue = true + deletion_protection = false } @@ -38,4 +44,4 @@ output "url" { output "address" { value = module.wandb.address -} \ No newline at end of file +} diff --git a/examples/public-dns-with-cloud-dns/variables.tf b/examples/public-dns-with-cloud-dns/variables.tf index 427d2ae..34d82bc 100644 --- a/examples/public-dns-with-cloud-dns/variables.tf +++ b/examples/public-dns-with-cloud-dns/variables.tf @@ -33,4 +33,16 @@ variable "subdomain" { variable "license" { type = string -} \ No newline at end of file +} + +variable "wandb_version" { + description = "The version of Weights & Biases local to deploy." + type = string + default = "latest" +} + +variable "wandb_image" { + description = "Docker repository of to pull the wandb image from." + type = string + default = "wandb/local" +} diff --git a/main.tf b/main.tf index 31d5bb8..8e6e478 100644 --- a/main.tf +++ b/main.tf @@ -84,6 +84,19 @@ module "database" { depends_on = [module.project_factory_project_services] } +module "redis" { + count = var.create_redis ? 1 : 0 + source = "./modules/redis" + namespace = var.namespace + memory_size_gb = 4 + network = module.networking.network + +} + +locals { + redis_connection_string = var.create_redis ? "redis://${module.redis.0.connection_string}?tls=true&ttlInSeconds=60" : null +} + module "gke_app" { source = "wandb/wandb/kubernetes" version = "1.0.2" @@ -94,6 +107,8 @@ module "gke_app" { bucket = "gs://${module.file_storage.bucket_name}" bucket_queue = "pubsub:/${module.file_storage.bucket_queue_name}" database_connection_string = "mysql://${module.database.connection_string}" + redis_connection_string = local.redis_connection_string + oidc_client_id = var.oidc_client_id oidc_issuer = var.oidc_issuer @@ -106,6 +121,7 @@ module "gke_app" { # still spinning up depends_on = [ module.database, + module.redis, module.file_storage, module.app_gke ] diff --git a/modules/redis/main.tf b/modules/redis/main.tf index 95a2aae..120759f 100644 --- a/modules/redis/main.tf +++ b/modules/redis/main.tf @@ -6,18 +6,17 @@ resource "google_redis_instance" "default" { display_name = "${var.namespace} W&B Instance" tier = "STANDARD_HA" memory_size_gb = var.memory_size_gb - auth_enabled = true - location_id = google_compute_zones.available.names.0 - alternative_location_id = google_compute_zones.available.names.1 + location_id = data.google_compute_zones.available.names.0 + alternative_location_id = data.google_compute_zones.available.names.1 authorized_network = var.network.id redis_version = "REDIS_6_X" - reserved_ip_range = "10.10.30.0/24" + reserved_ip_range = "10.30.0.0/16" transit_encryption_mode = "SERVER_AUTHENTICATION" connect_mode = "DIRECT_PEERING" labels = var.labels -} \ No newline at end of file +} diff --git a/modules/redis/outputs.tf b/modules/redis/outputs.tf new file mode 100644 index 0000000..97ecbc9 --- /dev/null +++ b/modules/redis/outputs.tf @@ -0,0 +1,3 @@ +output "connection_string" { + value = "${google_redis_instance.default.host}:${google_redis_instance.default.port}" +} diff --git a/variables.tf b/variables.tf index a6c1242..d57635f 100644 --- a/variables.tf +++ b/variables.tf @@ -97,3 +97,12 @@ variable "database_version" { error_message = "We only support MySQL: \"MYSQL_5_7\"; \"MYSQL_8_0\"." } } + +########################################## +# Redis # +########################################## +variable "create_redis" { + type = bool + description = "Boolean indicating whether to provision an redis instance (true) or not (false)." + default = false +} \ No newline at end of file