Skip to content

Small tweaks #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ The module has been tested with:
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_database_config"></a> [database\_config](#input\_database\_config) | Cloud SQL configuration | <pre>object({<br/> tier = optional(string, "db-custom-2-4096")<br/> version = optional(string, "POSTGRES_15")<br/> password = string<br/> username = optional(string, "materialize")<br/> db_name = optional(string, "materialize")<br/> })</pre> | n/a | yes |
| <a name="input_gke_config"></a> [gke\_config](#input\_gke\_config) | GKE cluster configuration. Make sure to use large enough machine types for your Materialize instances. | <pre>object({<br/> node_count = number<br/> machine_type = string<br/> disk_size_gb = number<br/> min_nodes = number<br/> max_nodes = number<br/> node_locations = list(string)<br/> })</pre> | <pre>{<br/> "disk_size_gb": 50,<br/> "machine_type": "e2-standard-4",<br/> "max_nodes": 2,<br/> "min_nodes": 1,<br/> "node_count": 1,<br/> "node_locations": []<br/>}</pre> | no |
| <a name="input_gke_config"></a> [gke\_config](#input\_gke\_config) | GKE cluster configuration. Make sure to use large enough machine types for your Materialize instances. | <pre>object({<br/> node_count = number<br/> machine_type = string<br/> disk_size_gb = number<br/> min_nodes = number<br/> max_nodes = number<br/> })</pre> | <pre>{<br/> "disk_size_gb": 50,<br/> "machine_type": "e2-standard-4",<br/> "max_nodes": 2,<br/> "min_nodes": 1,<br/> "node_count": 1<br/>}</pre> | no |
| <a name="input_helm_chart"></a> [helm\_chart](#input\_helm\_chart) | Chart name from repository or local path to chart. For local charts, set the path to the chart directory. | `string` | `"materialize-operator"` | no |
| <a name="input_helm_values"></a> [helm\_values](#input\_helm\_values) | Values to pass to the Helm chart | `any` | `{}` | no |
| <a name="input_install_materialize_operator"></a> [install\_materialize\_operator](#input\_install\_materialize\_operator) | Whether to install the Materialize operator | `bool` | `true` | no |
Expand Down
12 changes: 8 additions & 4 deletions examples/simple/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,27 +98,31 @@ Access the `examples/simple` directory and follow these steps:
```bash
terraform plan \
-var project_id="your-project-id" \
-var database_password="your-secure-password"
-var prefix="your-resource-prefix" \
-var region="us-central1"
```

Alternatively, you can set these variables in a `terraform.tfvars` file:
```bash
project_id = "your-project-id"
database_password = "your-secure-password"
prefix = "your-resource-prefix"
region="your-region"
```

3. Apply the changes:
```bash
terraform apply \
-var project_id="your-project-id" \
-var database_password="your-secure-password"
-var prefix="your-resource-prefix" \
-var region="us-central1"
```

4. When you're done, clean up:
```bash
terraform destroy \
-var project_id="your-project-id" \
-var database_password="your-secure-password"
-var prefix="your-resource-prefix" \
-var region="us-central1"
```

5. The `connection_strings` output will provide you with the connection strings for metadata and persistence backends.
Expand Down
21 changes: 15 additions & 6 deletions examples/simple/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ terraform {
source = "hashicorp/google"
version = ">= 6.0"
}
random = {
source = "hashicorp/random"
version = "~> 3.0"
}
}
}

Expand All @@ -23,12 +27,12 @@ module "materialize" {

project_id = var.project_id
region = var.region
prefix = "mz-simple"
prefix = var.prefix

database_config = {
tier = "db-custom-2-4096"
version = "POSTGRES_15"
password = var.database_password
password = random_password.pass.result
}

labels = {
Expand All @@ -53,11 +57,16 @@ variable "region" {
default = "us-central1"
}

variable "database_password" {
description = "Password for Cloud SQL database user"
default = "your-strong-password"
variable "prefix" {
description = "Used to prefix the names of the resources"
type = string
sensitive = true
default = "mz-simple"
}


resource "random_password" "pass" {
length = 20
special = false
}

output "gke_cluster" {
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/terraform.tfvars.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project_id = "enter-your-gcp-project-id"
database_password = "enter-secure-password"
prefix = "enter-a-prefix" // e.g., mz-simple, my-mz-demo
region = "us-central1"

# Once the operator is installed, you can define your Materialize instances here.
Expand Down
8 changes: 7 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ locals {
})
}


provider "google" {
project = var.project_id
region = var.region
}

module "gke" {
source = "./modules/gke"

Expand Down Expand Up @@ -125,7 +131,7 @@ locals {
metadata_backend_url = format(
"postgres://%s:%s@%s:5432/%s?sslmode=disable",
var.database_config.username,
var.database_config.password,
urlencode(var.database_config.password),
module.database.private_ip,
coalesce(instance.database_name, instance.name)
)
Expand Down
2 changes: 1 addition & 1 deletion terraform.tfvars.example
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace = "materialize"

# Resource Labels
labels = {
environment = "production"
environment = "test"
team = "data-platform"
managed_by = "terraform"
cost_center = "12345"
Expand Down
22 changes: 10 additions & 12 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,18 @@ variable "network_config" {
variable "gke_config" {
description = "GKE cluster configuration. Make sure to use large enough machine types for your Materialize instances."
type = object({
node_count = number
machine_type = string
disk_size_gb = number
min_nodes = number
max_nodes = number
node_locations = list(string)
node_count = number
machine_type = string
disk_size_gb = number
min_nodes = number
max_nodes = number
})
default = {
node_count = 1
machine_type = "e2-standard-4"
disk_size_gb = 50
min_nodes = 1
max_nodes = 2
node_locations = []
node_count = 1
machine_type = "e2-standard-4"
disk_size_gb = 50
min_nodes = 1
max_nodes = 2
}
}

Expand Down