main.tf 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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 "aws" {
  10. region = "us-east-1"
  11. }
  12. provider "kubernetes" {
  13. host = module.materialize_infrastructure.eks_cluster_endpoint
  14. cluster_ca_certificate = base64decode(module.materialize_infrastructure.cluster_certificate_authority_data)
  15. exec {
  16. api_version = "client.authentication.k8s.io/v1beta1"
  17. command = "aws"
  18. args = ["eks", "get-token", "--cluster-name", module.materialize_infrastructure.eks_cluster_name]
  19. }
  20. }
  21. provider "helm" {
  22. kubernetes {
  23. host = module.materialize_infrastructure.eks_cluster_endpoint
  24. cluster_ca_certificate = base64decode(module.materialize_infrastructure.cluster_certificate_authority_data)
  25. exec {
  26. api_version = "client.authentication.k8s.io/v1beta1"
  27. command = "aws"
  28. args = ["eks", "get-token", "--cluster-name", module.materialize_infrastructure.eks_cluster_name]
  29. }
  30. }
  31. }
  32. resource "random_password" "db_password" {
  33. length = 32
  34. special = false
  35. }
  36. variable "operator_version" {
  37. type = string
  38. default = "v25.3.0-beta.1.tgz"
  39. }
  40. variable "orchestratord_version" {
  41. type = string
  42. default = null
  43. }
  44. module "materialize_infrastructure" {
  45. source = "git::https://github.com/MaterializeInc/terraform-aws-materialize.git?ref=v0.4.9"
  46. providers = {
  47. aws = aws
  48. kubernetes = kubernetes
  49. helm = helm
  50. }
  51. # Basic settings
  52. # The namespace and environment variables are used to construct the names of the resources
  53. # e.g. ${namespace}-${environment}-eks and etc.
  54. namespace = "aws-test"
  55. environment = "dev"
  56. install_materialize_operator = true
  57. use_local_chart = true
  58. helm_chart = "materialize-operator-v25.3.0-beta.1.tgz"
  59. operator_version = var.operator_version
  60. orchestratord_version = var.orchestratord_version
  61. install_cert_manager = false
  62. use_self_signed_cluster_issuer = false
  63. # TODO: Doesn't seem to work yet
  64. # helm_values = {
  65. # operator = {
  66. # clusters = {
  67. # defaultReplicationFactor = {
  68. # system = 1
  69. # probe = 1
  70. # support = 1
  71. # analytics = 1
  72. # }
  73. # }
  74. # }
  75. # }
  76. # VPC Configuration
  77. vpc_cidr = "10.0.0.0/16"
  78. availability_zones = ["us-east-1a", "us-east-1b"]
  79. private_subnet_cidrs = ["10.0.1.0/24", "10.0.2.0/24"]
  80. public_subnet_cidrs = ["10.0.101.0/24", "10.0.102.0/24"]
  81. single_nat_gateway = true
  82. # EKS Configuration
  83. cluster_version = "1.32"
  84. node_group_instance_types = ["r7gd.2xlarge"]
  85. node_group_desired_size = 2
  86. node_group_min_size = 1
  87. node_group_max_size = 3
  88. node_group_capacity_type = "ON_DEMAND"
  89. # Storage Configuration
  90. bucket_force_destroy = true
  91. # For testing purposes, we are disabling encryption and versioning to allow for easier cleanup
  92. # This should be enabled in production environments for security and data integrity
  93. enable_bucket_versioning = false
  94. enable_bucket_encryption = false
  95. # Database Configuration
  96. database_password = random_password.db_password.result
  97. postgres_version = "15"
  98. db_instance_class = "db.t3.micro"
  99. db_allocated_storage = 20
  100. database_name = "materialize"
  101. database_username = "materialize"
  102. db_multi_az = false
  103. # Basic monitoring
  104. enable_monitoring = true
  105. metrics_retention_days = 7
  106. # Tags
  107. tags = {
  108. Environment = "dev"
  109. Project = "aws-test"
  110. Terraform = "true"
  111. }
  112. }
  113. # Generate random suffix for unique S3 bucket name
  114. resource "random_id" "suffix" {
  115. byte_length = 4
  116. }
  117. # outputs.tf
  118. output "eks_cluster_endpoint" {
  119. description = "EKS cluster endpoint"
  120. value = module.materialize_infrastructure.eks_cluster_endpoint
  121. }
  122. output "database_endpoint" {
  123. description = "RDS instance endpoint"
  124. value = module.materialize_infrastructure.database_endpoint
  125. }
  126. output "s3_bucket_name" {
  127. description = "Name of the S3 bucket"
  128. value = module.materialize_infrastructure.s3_bucket_name
  129. }
  130. output "materialize_s3_role_arn" {
  131. description = "The ARN of the IAM role for Materialize"
  132. value = module.materialize_infrastructure.materialize_s3_role_arn
  133. }
  134. output "metadata_backend_url" {
  135. description = "PostgreSQL connection URL in the format required by Materialize"
  136. value = module.materialize_infrastructure.metadata_backend_url
  137. sensitive = true
  138. }
  139. output "persist_backend_url" {
  140. description = "S3 connection URL in the format required by Materialize using IRSA"
  141. value = module.materialize_infrastructure.persist_backend_url
  142. }