Skip to content

Commit

Permalink
Add urlencode for the db password
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbyiliev committed Feb 27, 2025
1 parent 0f506ea commit f4574ef
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
14 changes: 6 additions & 8 deletions examples/simple/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module "materialize_infrastructure" {
enable_bucket_encryption = false

# Database Configuration
database_password = var.database_password
database_password = random_password.pass.result
postgres_version = "15"
db_instance_class = "db.t3.large"
db_allocated_storage = 20
Expand All @@ -63,6 +63,11 @@ module "materialize_infrastructure" {
}
}

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

variable "namespace" {
description = "Namespace for the resources. Used to prefix the names of the resources"
type = string
Expand All @@ -75,13 +80,6 @@ variable "environment" {
default = "dev"
}

variable "database_password" {
description = "Password for the database (should be provided via tfvars or environment variable)"
default = "your-secure-password"
type = string
sensitive = true
}

variable "materialize_instances" {
description = "List of Materialize instances to be created."
type = list(object({
Expand Down
1 change: 0 additions & 1 deletion examples/simple/terraform.tfvars.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace = "mz-self-mngd" // maximum 12 characters, starts with a letter, lowercase alphanumeric and hyphens
environment = "dev" // maximum 8 characters, lowercase alphanumeric only (e.g., dev, test)
database_password = "your-secret-password"

# Once the operator is installed, you can define your Materialize instances here.
# Uncomment the following block (or provide your own instances) to configure them:
Expand Down
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ locals {
metadata_backend_url = format(
"postgres://%s:%s@%s/%s?sslmode=require",
var.database_username,
var.database_password,
urlencode(var.database_password),
module.database.db_instance_endpoint,
coalesce(instance.database_name, instance.name)
)
Expand Down

0 comments on commit f4574ef

Please sign in to comment.