Skip to content

Commit ae509d1

Browse files
Merge pull request #42 from MaterializeInc/aws_nlb
NLB ingress
2 parents d0c9d14 + ce84efb commit ae509d1

File tree

15 files changed

+752
-24
lines changed

15 files changed

+752
-24
lines changed

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@ export AWS_PROFILE=your-profile-name
7575

7676
| Name | Source | Version |
7777
|------|--------|---------|
78+
| <a name="module_aws_lbc"></a> [aws\_lbc](#module\_aws\_lbc) | ./modules/aws-lbc | n/a |
7879
| <a name="module_database"></a> [database](#module\_database) | ./modules/database | n/a |
7980
| <a name="module_eks"></a> [eks](#module\_eks) | ./modules/eks | n/a |
8081
| <a name="module_networking"></a> [networking](#module\_networking) | ./modules/networking | n/a |
81-
| <a name="module_operator"></a> [operator](#module\_operator) | github.com/MaterializeInc/terraform-helm-materialize | v0.1.7 |
82+
| <a name="module_nlb"></a> [nlb](#module\_nlb) | ./modules/nlb | n/a |
83+
| <a name="module_operator"></a> [operator](#module\_operator) | github.com/MaterializeInc/terraform-helm-materialize | v0.1.8 |
8284
| <a name="module_storage"></a> [storage](#module\_storage) | ./modules/storage | n/a |
8385

8486
## Resources
@@ -118,15 +120,17 @@ export AWS_PROFILE=your-profile-name
118120
| <a name="input_environment"></a> [environment](#input\_environment) | Environment name (e.g., prod, staging, dev) | `string` | n/a | yes |
119121
| <a name="input_helm_chart"></a> [helm\_chart](#input\_helm\_chart) | Chart name from repository or local path to chart. For local charts, set the path to the chart directory. | `string` | `"materialize-operator"` | no |
120122
| <a name="input_helm_values"></a> [helm\_values](#input\_helm\_values) | Additional Helm values to merge with defaults | `any` | `{}` | no |
123+
| <a name="input_install_aws_load_balancer_controller"></a> [install\_aws\_load\_balancer\_controller](#input\_install\_aws\_load\_balancer\_controller) | Whether to install the AWS Load Balancer Controller | `bool` | `true` | no |
121124
| <a name="input_install_materialize_operator"></a> [install\_materialize\_operator](#input\_install\_materialize\_operator) | Whether to install the Materialize operator | `bool` | `true` | no |
122125
| <a name="input_install_metrics_server"></a> [install\_metrics\_server](#input\_install\_metrics\_server) | Whether to install the metrics-server for the Materialize Console | `bool` | `true` | no |
123126
| <a name="input_kubernetes_namespace"></a> [kubernetes\_namespace](#input\_kubernetes\_namespace) | The Kubernetes namespace for the Materialize resources | `string` | `"materialize-environment"` | no |
124127
| <a name="input_log_group_name_prefix"></a> [log\_group\_name\_prefix](#input\_log\_group\_name\_prefix) | Prefix for the CloudWatch log group name (will be combined with environment name) | `string` | `"materialize"` | no |
125-
| <a name="input_materialize_instances"></a> [materialize\_instances](#input\_materialize\_instances) | Configuration for Materialize instances | <pre>list(object({<br/> name = string<br/> namespace = optional(string)<br/> database_name = string<br/> environmentd_version = optional(string, "v0.130.4")<br/> cpu_request = optional(string, "1")<br/> memory_request = optional(string, "1Gi")<br/> memory_limit = optional(string, "1Gi")<br/> create_database = optional(bool, true)<br/> in_place_rollout = optional(bool, false)<br/> request_rollout = optional(string)<br/> force_rollout = optional(string)<br/> balancer_memory_request = optional(string, "256Mi")<br/> balancer_memory_limit = optional(string, "256Mi")<br/> balancer_cpu_request = optional(string, "100m")<br/> }))</pre> | `[]` | no |
128+
| <a name="input_materialize_instances"></a> [materialize\_instances](#input\_materialize\_instances) | Configuration for Materialize instances | <pre>list(object({<br/> name = string<br/> namespace = optional(string)<br/> database_name = string<br/> environmentd_version = optional(string, "v0.130.4")<br/> cpu_request = optional(string, "1")<br/> memory_request = optional(string, "1Gi")<br/> memory_limit = optional(string, "1Gi")<br/> create_database = optional(bool, true)<br/> create_nlb = optional(bool, true)<br/> internal_nlb = optional(bool, true)<br/> in_place_rollout = optional(bool, false)<br/> request_rollout = optional(string)<br/> force_rollout = optional(string)<br/> balancer_memory_request = optional(string, "256Mi")<br/> balancer_memory_limit = optional(string, "256Mi")<br/> balancer_cpu_request = optional(string, "100m")<br/> }))</pre> | `[]` | no |
126129
| <a name="input_metrics_retention_days"></a> [metrics\_retention\_days](#input\_metrics\_retention\_days) | Number of days to retain CloudWatch metrics | `number` | `7` | no |
127130
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Namespace for all resources, usually the organization or project name | `string` | n/a | yes |
128131
| <a name="input_network_id"></a> [network\_id](#input\_network\_id) | The ID of the VPC in which resources will be deployed. Only used if create\_vpc is false. | `string` | `""` | no |
129132
| <a name="input_network_private_subnet_ids"></a> [network\_private\_subnet\_ids](#input\_network\_private\_subnet\_ids) | A list of private subnet IDs in the VPC. Only used if create\_vpc is false. | `list(string)` | `[]` | no |
133+
| <a name="input_network_public_subnet_ids"></a> [network\_public\_subnet\_ids](#input\_network\_public\_subnet\_ids) | A list of public subnet IDs in the VPC. Only used if create\_vpc is false. | `list(string)` | `[]` | no |
130134
| <a name="input_node_group_ami_type"></a> [node\_group\_ami\_type](#input\_node\_group\_ami\_type) | AMI type for the node group | `string` | `"AL2023_ARM_64_STANDARD"` | no |
131135
| <a name="input_node_group_capacity_type"></a> [node\_group\_capacity\_type](#input\_node\_group\_capacity\_type) | Capacity type for worker nodes (ON\_DEMAND or SPOT) | `string` | `"ON_DEMAND"` | no |
132136
| <a name="input_node_group_desired_size"></a> [node\_group\_desired\_size](#input\_node\_group\_desired\_size) | Desired number of worker nodes | `number` | `2` | no |
@@ -150,6 +154,7 @@ export AWS_PROFILE=your-profile-name
150154
| Name | Description |
151155
|------|-------------|
152156
| <a name="output_cluster_certificate_authority_data"></a> [cluster\_certificate\_authority\_data](#output\_cluster\_certificate\_authority\_data) | Base64 encoded certificate data required to communicate with the cluster |
157+
| <a name="output_cluster_oidc_issuer_url"></a> [cluster\_oidc\_issuer\_url](#output\_cluster\_oidc\_issuer\_url) | The URL on the EKS cluster for the OpenID Connect identity provider |
153158
| <a name="output_database_endpoint"></a> [database\_endpoint](#output\_database\_endpoint) | RDS instance endpoint |
154159
| <a name="output_eks_cluster_endpoint"></a> [eks\_cluster\_endpoint](#output\_eks\_cluster\_endpoint) | EKS cluster endpoint |
155160
| <a name="output_eks_cluster_name"></a> [eks\_cluster\_name](#output\_eks\_cluster\_name) | EKS cluster name |
@@ -158,6 +163,8 @@ export AWS_PROFILE=your-profile-name
158163
| <a name="output_oidc_provider_arn"></a> [oidc\_provider\_arn](#output\_oidc\_provider\_arn) | The ARN of the OIDC Provider |
159164
| <a name="output_operator_details"></a> [operator\_details](#output\_operator\_details) | Details of the installed Materialize operator |
160165
| <a name="output_persist_backend_url"></a> [persist\_backend\_url](#output\_persist\_backend\_url) | S3 connection URL in the format required by Materialize using IRSA |
166+
| <a name="output_private_subnet_ids"></a> [private\_subnet\_ids](#output\_private\_subnet\_ids) | List of private subnet IDs |
167+
| <a name="output_public_subnet_ids"></a> [public\_subnet\_ids](#output\_public\_subnet\_ids) | List of public subnet IDs |
161168
| <a name="output_s3_bucket_name"></a> [s3\_bucket\_name](#output\_s3\_bucket\_name) | Name of the S3 bucket |
162169
| <a name="output_vpc_id"></a> [vpc\_id](#output\_vpc\_id) | VPC ID |
163170

examples/simple/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,14 @@ variable "materialize_instances" {
135135
memory_request = string
136136
memory_limit = string
137137
create_database = optional(bool)
138+
create_nlb = optional(bool)
139+
internal_nlb = optional(bool)
138140
in_place_rollout = optional(bool, false)
139141
request_rollout = optional(string)
140142
force_rollout = optional(string)
141143
balancer_memory_request = optional(string, "256Mi")
142144
balancer_memory_limit = optional(string, "256Mi")
143145
balancer_cpu_request = optional(string, "100m")
144-
145146
}))
146147
default = []
147148
}

main.tf

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,25 @@ module "eks" {
3636
enable_cluster_creator_admin_permissions = var.enable_cluster_creator_admin_permissions
3737

3838
tags = local.common_tags
39+
40+
depends_on = [
41+
module.networking,
42+
]
43+
}
44+
45+
module "aws_lbc" {
46+
source = "./modules/aws-lbc"
47+
count = var.install_aws_load_balancer_controller ? 1 : 0
48+
49+
eks_cluster_name = module.eks.cluster_name
50+
oidc_provider_arn = module.eks.oidc_provider_arn
51+
oidc_issuer_url = module.eks.cluster_oidc_issuer_url
52+
vpc_id = module.networking.vpc_id
53+
region = data.aws_region.current.name
54+
55+
depends_on = [
56+
module.eks,
57+
]
3958
}
4059

4160
module "storage" {
@@ -76,10 +95,14 @@ module "database" {
7695
database_password = var.database_password
7796

7897
tags = local.common_tags
98+
99+
depends_on = [
100+
module.networking,
101+
]
79102
}
80103

81104
module "operator" {
82-
source = "github.com/MaterializeInc/terraform-helm-materialize?ref=v0.1.7"
105+
source = "github.com/MaterializeInc/terraform-helm-materialize?ref=v0.1.8"
83106

84107
count = var.install_materialize_operator ? 1 : 0
85108

@@ -88,7 +111,8 @@ module "operator" {
88111
depends_on = [
89112
module.eks,
90113
module.database,
91-
module.storage
114+
module.storage,
115+
module.networking,
92116
]
93117

94118
namespace = var.namespace
@@ -109,9 +133,30 @@ module "operator" {
109133
}
110134
}
111135

136+
module "nlb" {
137+
source = "./modules/nlb"
138+
139+
for_each = { for idx, instance in local.instances : instance.name => instance if lookup(instance, "create_nlb", true) }
140+
141+
name_prefix = each.value.name
142+
namespace = each.value.namespace
143+
internal = each.value.internal_nlb
144+
subnet_ids = each.value.internal_nlb ? local.network_private_subnet_ids : local.network_public_subnet_ids
145+
enable_cross_zone_load_balancing = each.value.enable_cross_zone_load_balancing
146+
vpc_id = local.network_id
147+
mz_resource_id = module.operator[0].materialize_instance_resource_ids[each.value.name]
148+
149+
depends_on = [
150+
module.aws_lbc,
151+
module.operator,
152+
module.eks,
153+
]
154+
}
155+
112156
locals {
113157
network_id = var.create_vpc ? module.networking.vpc_id : var.network_id
114158
network_private_subnet_ids = var.create_vpc ? module.networking.private_subnet_ids : var.network_private_subnet_ids
159+
network_public_subnet_ids = var.create_vpc ? module.networking.public_subnet_ids : var.network_public_subnet_ids
115160

116161
default_helm_values = {
117162
observability = {
@@ -145,11 +190,14 @@ locals {
145190

146191
instances = [
147192
for instance in var.materialize_instances : {
148-
name = instance.name
149-
namespace = instance.namespace
150-
database_name = instance.database_name
151-
create_database = instance.create_database
152-
environmentd_version = instance.environmentd_version
193+
name = instance.name
194+
namespace = instance.namespace
195+
database_name = instance.database_name
196+
create_database = instance.create_database
197+
environmentd_version = instance.environmentd_version
198+
create_nlb = instance.create_nlb
199+
internal_nlb = instance.internal_nlb
200+
enable_cross_zone_load_balancing = instance.enable_cross_zone_load_balancing
153201

154202
metadata_backend_url = format(
155203
"postgres://%s:%s@%s/%s?sslmode=require",

0 commit comments

Comments
 (0)