main.tf 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. resource "random_password" "db_password" {
  13. length = 32
  14. special = false
  15. }
  16. variable "operator_version" {
  17. type = string
  18. default = "v25.3.0-beta.1.tgz"
  19. }
  20. variable "orchestratord_version" {
  21. type = string
  22. default = null
  23. }
  24. module "materialize_infrastructure" {
  25. source = "git::https://github.com/MaterializeInc/terraform-aws-materialize.git?ref=v0.4.9"
  26. # Basic settings
  27. namespace = "aws-persistent"
  28. environment = "dev"
  29. install_materialize_operator = true
  30. use_local_chart = true
  31. helm_chart = "materialize-operator-v25.3.0-beta.1.tgz"
  32. operator_version = var.operator_version
  33. orchestratord_version = var.orchestratord_version
  34. # VPC Configuration
  35. vpc_cidr = "10.0.0.0/16"
  36. availability_zones = ["us-east-1a", "us-east-1b"]
  37. private_subnet_cidrs = ["10.0.1.0/24", "10.0.2.0/24"]
  38. public_subnet_cidrs = ["10.0.101.0/24", "10.0.102.0/24"]
  39. single_nat_gateway = true
  40. # EKS Configuration
  41. cluster_version = "1.31"
  42. node_group_instance_types = ["r8g.2xlarge"]
  43. node_group_desired_size = 2
  44. node_group_min_size = 1
  45. node_group_max_size = 3
  46. node_group_capacity_type = "ON_DEMAND"
  47. # Storage Configuration
  48. bucket_force_destroy = true
  49. # For testing purposes, we are disabling encryption and versioning to allow for easier cleanup
  50. # This should be enabled in production environments for security and data integrity
  51. enable_bucket_versioning = false
  52. enable_bucket_encryption = false
  53. # Database Configuration
  54. database_password = random_password.db_password.result
  55. postgres_version = "15"
  56. db_instance_class = "db.t3.micro"
  57. db_allocated_storage = 20
  58. database_name = "materialize"
  59. database_username = "materialize"
  60. db_multi_az = false
  61. # Basic monitoring
  62. enable_monitoring = true
  63. metrics_retention_days = 30
  64. # Tags
  65. tags = {
  66. Environment = "dev"
  67. Project = "aws-persistent"
  68. Terraform = "true"
  69. }
  70. }
  71. # Generate random suffix for unique S3 bucket name
  72. resource "random_id" "suffix" {
  73. byte_length = 4
  74. }
  75. # outputs.tf
  76. output "eks_cluster_endpoint" {
  77. description = "EKS cluster endpoint"
  78. value = module.materialize_infrastructure.eks_cluster_endpoint
  79. }
  80. output "database_endpoint" {
  81. description = "RDS instance endpoint"
  82. value = module.materialize_infrastructure.database_endpoint
  83. }
  84. output "s3_bucket_name" {
  85. description = "Name of the S3 bucket"
  86. value = module.materialize_infrastructure.s3_bucket_name
  87. }
  88. output "materialize_s3_role_arn" {
  89. description = "The ARN of the IAM role for Materialize"
  90. value = module.materialize_infrastructure.materialize_s3_role_arn
  91. }
  92. output "metadata_backend_url" {
  93. description = "PostgreSQL connection URL in the format required by Materialize"
  94. value = module.materialize_infrastructure.metadata_backend_url
  95. sensitive = true
  96. }
  97. output "persist_backend_url" {
  98. description = "S3 connection URL in the format required by Materialize using IRSA"
  99. value = module.materialize_infrastructure.persist_backend_url
  100. }