main.tf 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. terraform {
  10. required_version = ">= 1.0"
  11. required_providers {
  12. google = {
  13. source = "hashicorp/google"
  14. version = ">= 6.0"
  15. }
  16. kubernetes = {
  17. source = "hashicorp/kubernetes"
  18. version = "~> 2.0"
  19. }
  20. helm = {
  21. source = "hashicorp/helm"
  22. version = "~> 2.0"
  23. }
  24. }
  25. }
  26. provider "google" {
  27. project = var.project_id
  28. region = var.region
  29. }
  30. data "google_client_config" "default" {}
  31. provider "kubernetes" {
  32. host = "https://${module.materialize.gke_cluster.endpoint}"
  33. token = data.google_client_config.default.access_token
  34. cluster_ca_certificate = base64decode(module.materialize.gke_cluster.ca_certificate)
  35. }
  36. provider "helm" {
  37. kubernetes {
  38. host = "https://${module.materialize.gke_cluster.endpoint}"
  39. token = data.google_client_config.default.access_token
  40. cluster_ca_certificate = base64decode(module.materialize.gke_cluster.ca_certificate)
  41. }
  42. }
  43. module "materialize" {
  44. source = "github.com/MaterializeInc/terraform-google-materialize?ref=v0.4.3"
  45. project_id = var.project_id
  46. region = var.region
  47. prefix = "tf-gcp-test"
  48. database_config = {
  49. tier = "db-custom-2-4096"
  50. version = "POSTGRES_15"
  51. password = var.database_password
  52. }
  53. network_config = {
  54. subnet_cidr = "10.0.0.0/20"
  55. pods_cidr = "10.48.0.0/14"
  56. services_cidr = "10.52.0.0/20"
  57. }
  58. labels = {
  59. environment = "simple"
  60. example = "true"
  61. }
  62. install_materialize_operator = true
  63. use_local_chart = true
  64. helm_chart = "materialize-operator-v25.3.0-beta.1.tgz"
  65. operator_version = var.operator_version
  66. orchestratord_version = var.orchestratord_version
  67. install_cert_manager = false
  68. use_self_signed_cluster_issuer = false
  69. helm_values = {
  70. clusters = {
  71. defaultReplicationFactor = {
  72. system = 1
  73. probe = 1
  74. support = 1
  75. analytics = 1
  76. }
  77. }
  78. }
  79. providers = {
  80. google = google
  81. kubernetes = kubernetes
  82. helm = helm
  83. }
  84. }
  85. variable "project_id" {
  86. description = "GCP Project ID"
  87. type = string
  88. default = "materialize-ci"
  89. }
  90. variable "region" {
  91. description = "GCP Region"
  92. type = string
  93. default = "us-east1"
  94. }
  95. variable "database_password" {
  96. description = "Password for Cloud SQL database user"
  97. default = "your-strong-password"
  98. type = string
  99. sensitive = true
  100. }
  101. variable "operator_version" {
  102. type = string
  103. default = "v25.3.0-beta.1.tgz"
  104. }
  105. variable "orchestratord_version" {
  106. type = string
  107. default = null
  108. }
  109. output "gke_cluster" {
  110. description = "GKE cluster details"
  111. value = module.materialize.gke_cluster
  112. sensitive = true
  113. }
  114. output "service_accounts" {
  115. description = "Service account details"
  116. value = module.materialize.service_accounts
  117. }
  118. output "connection_strings" {
  119. description = "Connection strings for metadata and persistence backends"
  120. value = module.materialize.connection_strings
  121. sensitive = true
  122. }