main.tf 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. provider "azurerm" {
  10. subscription_id = "9bc1ad3f-3401-42a3-99cd-7faeeb51e059"
  11. features {
  12. resource_group {
  13. prevent_deletion_if_contains_resources = false
  14. }
  15. key_vault {
  16. purge_soft_delete_on_destroy = true
  17. recover_soft_deleted_key_vaults = false
  18. }
  19. }
  20. }
  21. provider "kubernetes" {
  22. host = module.materialize.kube_config[0].host
  23. client_certificate = base64decode(module.materialize.kube_config[0].client_certificate)
  24. client_key = base64decode(module.materialize.kube_config[0].client_key)
  25. cluster_ca_certificate = base64decode(module.materialize.kube_config[0].cluster_ca_certificate)
  26. }
  27. provider "helm" {
  28. kubernetes {
  29. host = module.materialize.kube_config[0].host
  30. client_certificate = base64decode(module.materialize.kube_config[0].client_certificate)
  31. client_key = base64decode(module.materialize.kube_config[0].client_key)
  32. cluster_ca_certificate = base64decode(module.materialize.kube_config[0].cluster_ca_certificate)
  33. }
  34. }
  35. resource "random_password" "pass" {
  36. length = 20
  37. special = false
  38. }
  39. variable "operator_version" {
  40. type = string
  41. default = "v25.3.0-beta.1.tgz"
  42. }
  43. variable "orchestratord_version" {
  44. type = string
  45. default = null
  46. }
  47. resource "azurerm_resource_group" "materialize" {
  48. name = "mz-tf-test-rg"
  49. location = "eastus2"
  50. tags = {}
  51. }
  52. module "materialize" {
  53. source = "git::https://github.com/MaterializeInc/terraform-azurerm-materialize.git?ref=v0.4.6"
  54. resource_group_name = azurerm_resource_group.materialize.name
  55. location = "eastus2"
  56. prefix = "mz-tf-test"
  57. install_materialize_operator = true
  58. use_local_chart = true
  59. helm_chart = "materialize-operator-v25.3.0-beta.1.tgz"
  60. operator_version = var.operator_version
  61. orchestratord_version = var.orchestratord_version
  62. install_cert_manager = false
  63. use_self_signed_cluster_issuer = false
  64. materialize_instances = var.materialize_instances
  65. database_config = {
  66. sku_name = "GP_Standard_D2s_v3"
  67. version = "15"
  68. password = random_password.pass.result
  69. }
  70. network_config = {
  71. vnet_address_space = "10.0.0.0/16"
  72. subnet_cidr = "10.0.0.0/20"
  73. postgres_subnet_cidr = "10.0.16.0/24"
  74. service_cidr = "10.1.0.0/16"
  75. docker_bridge_cidr = "172.17.0.1/16"
  76. }
  77. tags = {
  78. environment = "dev"
  79. managed_by = "terraform"
  80. }
  81. providers = {
  82. azurerm = azurerm
  83. kubernetes = kubernetes
  84. helm = helm
  85. }
  86. }
  87. variable "location" {
  88. description = "Azure region"
  89. type = string
  90. default = "eastus2"
  91. }
  92. variable "tags" {
  93. description = "Tags to apply to resources"
  94. type = map(string)
  95. default = {}
  96. }
  97. variable "materialize_instances" {
  98. description = "Configuration for Materialize instances"
  99. type = list(object({
  100. name = string
  101. namespace = optional(string)
  102. database_name = string
  103. cpu_request = optional(string, "1")
  104. memory_request = optional(string, "1Gi")
  105. memory_limit = optional(string, "1Gi")
  106. create_database = optional(bool, true)
  107. in_place_rollout = optional(bool, false)
  108. request_rollout = optional(string)
  109. force_rollout = optional(string)
  110. }))
  111. default = []
  112. }
  113. # Output the Materialize instance details
  114. output "aks_cluster" {
  115. description = "AKS cluster details"
  116. value = module.materialize.aks_cluster
  117. sensitive = true
  118. }
  119. output "connection_strings" {
  120. description = "Connection strings for Materialize"
  121. value = module.materialize.connection_strings
  122. sensitive = true
  123. }
  124. output "kube_config" {
  125. description = "The kube_config for the AKS cluster"
  126. value = module.materialize.kube_config
  127. sensitive = true
  128. }
  129. output "resource_group_name" {
  130. value = azurerm_resource_group.materialize.name
  131. }