|
| 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 | + |
| 10 | +provider "aws" { |
| 11 | + region = "us-east-1" |
| 12 | +} |
| 13 | + |
| 14 | +resource "random_password" "db_password" { |
| 15 | + length = 32 |
| 16 | + special = false |
| 17 | +} |
| 18 | + |
| 19 | +module "materialize_infrastructure" { |
| 20 | + source = "git::https://github.com/MaterializeInc/terraform-aws-materialize.git?ref=v0.2.0" |
| 21 | + |
| 22 | + # Basic settings |
| 23 | + # The namespace and environment variables are used to construct the names of the resources |
| 24 | + # e.g. ${namespace}-${environment}-eks and etc. |
| 25 | + namespace = "aws-test" |
| 26 | + environment = "dev" |
| 27 | + install_materialize_operator = true |
| 28 | + |
| 29 | + helm_values = { |
| 30 | + defaultReplicationFactor = { |
| 31 | + system = 1 |
| 32 | + probe = 1 |
| 33 | + support = 1 |
| 34 | + analytics = 1 |
| 35 | + } |
| 36 | + } |
| 37 | + |
| 38 | + # VPC Configuration |
| 39 | + vpc_cidr = "10.0.0.0/16" |
| 40 | + availability_zones = ["us-east-1a", "us-east-1b"] |
| 41 | + private_subnet_cidrs = ["10.0.1.0/24", "10.0.2.0/24"] |
| 42 | + public_subnet_cidrs = ["10.0.101.0/24", "10.0.102.0/24"] |
| 43 | + single_nat_gateway = true |
| 44 | + |
| 45 | + # EKS Configuration |
| 46 | + cluster_version = "1.31" |
| 47 | + node_group_instance_types = ["c7a.2xlarge"] |
| 48 | + node_group_desired_size = 2 |
| 49 | + node_group_min_size = 1 |
| 50 | + node_group_max_size = 3 |
| 51 | + node_group_capacity_type = "ON_DEMAND" |
| 52 | + |
| 53 | + # Storage Configuration |
| 54 | + bucket_force_destroy = true |
| 55 | + |
| 56 | + # For testing purposes, we are disabling encryption and versioning to allow for easier cleanup |
| 57 | + # This should be enabled in production environments for security and data integrity |
| 58 | + enable_bucket_versioning = false |
| 59 | + enable_bucket_encryption = false |
| 60 | + |
| 61 | + # Database Configuration |
| 62 | + database_password = random_password.db_password.result |
| 63 | + postgres_version = "15" |
| 64 | + db_instance_class = "db.t3.micro" |
| 65 | + db_allocated_storage = 20 |
| 66 | + database_name = "materialize" |
| 67 | + database_username = "materialize" |
| 68 | + db_multi_az = false |
| 69 | + |
| 70 | + # Basic monitoring |
| 71 | + enable_monitoring = true |
| 72 | + metrics_retention_days = 7 |
| 73 | + |
| 74 | + # Tags |
| 75 | + tags = { |
| 76 | + Environment = "dev" |
| 77 | + Project = "aws-test" |
| 78 | + Terraform = "true" |
| 79 | + } |
| 80 | +} |
| 81 | + |
| 82 | +# Generate random suffix for unique S3 bucket name |
| 83 | +resource "random_id" "suffix" { |
| 84 | + byte_length = 4 |
| 85 | +} |
| 86 | + |
| 87 | +# outputs.tf |
| 88 | +output "eks_cluster_endpoint" { |
| 89 | + description = "EKS cluster endpoint" |
| 90 | + value = module.materialize_infrastructure.eks_cluster_endpoint |
| 91 | +} |
| 92 | + |
| 93 | +output "database_endpoint" { |
| 94 | + description = "RDS instance endpoint" |
| 95 | + value = module.materialize_infrastructure.database_endpoint |
| 96 | +} |
| 97 | + |
| 98 | +output "s3_bucket_name" { |
| 99 | + description = "Name of the S3 bucket" |
| 100 | + value = module.materialize_infrastructure.s3_bucket_name |
| 101 | +} |
| 102 | + |
| 103 | +output "materialize_s3_role_arn" { |
| 104 | + description = "The ARN of the IAM role for Materialize" |
| 105 | + value = module.materialize_infrastructure.materialize_s3_role_arn |
| 106 | +} |
| 107 | + |
| 108 | +output "metadata_backend_url" { |
| 109 | + description = "PostgreSQL connection URL in the format required by Materialize" |
| 110 | + value = module.materialize_infrastructure.metadata_backend_url |
| 111 | + sensitive = true |
| 112 | +} |
| 113 | + |
| 114 | +output "persist_backend_url" { |
| 115 | + description = "S3 connection URL in the format required by Materialize using IRSA" |
| 116 | + value = module.materialize_infrastructure.persist_backend_url |
| 117 | +} |
0 commit comments