Skip to content

Commit 31fb765

Browse files
Merge pull request #56 from MaterializeInc/certs_by_default
Enable TLS by default
2 parents aa276f3 + f5c82e8 commit 31fb765

File tree

5 files changed

+37
-27
lines changed

5 files changed

+37
-27
lines changed

README.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,12 @@ disk_support_config = {
168168
| <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 |
169169
| <a name="input_helm_values"></a> [helm\_values](#input\_helm\_values) | Additional Helm values to merge with defaults | `any` | `{}` | no |
170170
| <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 |
171-
| <a name="input_install_cert_manager"></a> [install\_cert\_manager](#input\_install\_cert\_manager) | Whether to install cert-manager. | `bool` | `false` | no |
171+
| <a name="input_install_cert_manager"></a> [install\_cert\_manager](#input\_install\_cert\_manager) | Whether to install cert-manager. | `bool` | `true` | no |
172172
| <a name="input_install_materialize_operator"></a> [install\_materialize\_operator](#input\_install\_materialize\_operator) | Whether to install the Materialize operator | `bool` | `true` | no |
173173
| <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 |
174174
| <a name="input_kubernetes_namespace"></a> [kubernetes\_namespace](#input\_kubernetes\_namespace) | The Kubernetes namespace for the Materialize resources | `string` | `"materialize-environment"` | no |
175175
| <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 |
176-
| <a name="input_materialize_instances"></a> [materialize\_instances](#input\_materialize\_instances) | Configuration for Materialize instances. Due to limitations in Terraform, `materialize_instances` cannot be defined on the first `terraform apply`. | <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/> enable_cross_zone_load_balancing = 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 |
176+
| <a name="input_materialize_instances"></a> [materialize\_instances](#input\_materialize\_instances) | Configuration for Materialize instances. Due to limitations in Terraform, `materialize_instances` cannot be defined on the first `terraform apply`. | <pre>list(object({<br/> name = string<br/> namespace = optional(string)<br/> database_name = string<br/> environmentd_version = optional(string)<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/> enable_cross_zone_load_balancing = 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 |
177177
| <a name="input_metrics_retention_days"></a> [metrics\_retention\_days](#input\_metrics\_retention\_days) | Number of days to retain CloudWatch metrics | `number` | `7` | no |
178178
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Namespace for all resources, usually the organization or project name | `string` | n/a | yes |
179179
| <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 |
@@ -195,7 +195,7 @@ disk_support_config = {
195195
| <a name="input_single_nat_gateway"></a> [single\_nat\_gateway](#input\_single\_nat\_gateway) | Use a single NAT Gateway for all private subnets | `bool` | `false` | no |
196196
| <a name="input_tags"></a> [tags](#input\_tags) | Default tags to apply to all resources | `map(string)` | <pre>{<br/> "Environment": "dev",<br/> "Project": "materialize",<br/> "Terraform": "true"<br/>}</pre> | no |
197197
| <a name="input_use_local_chart"></a> [use\_local\_chart](#input\_use\_local\_chart) | Whether to use a local chart instead of one from a repository | `bool` | `false` | no |
198-
| <a name="input_use_self_signed_cluster_issuer"></a> [use\_self\_signed\_cluster\_issuer](#input\_use\_self\_signed\_cluster\_issuer) | Whether to install and use a self-signed ClusterIssuer for TLS. Due to limitations in Terraform, this may not be enabled before the cert-manager CRDs are installed. | `bool` | `false` | no |
198+
| <a name="input_use_self_signed_cluster_issuer"></a> [use\_self\_signed\_cluster\_issuer](#input\_use\_self\_signed\_cluster\_issuer) | Whether to install and use a self-signed ClusterIssuer for TLS. To work around limitations in Terraform, this will be treated as `false` if no materialize instances are defined. | `bool` | `true` | no |
199199
| <a name="input_vpc_cidr"></a> [vpc\_cidr](#input\_vpc\_cidr) | CIDR block for VPC | `string` | `"10.0.0.0/16"` | no |
200200

201201
## Outputs
@@ -239,19 +239,24 @@ The DNS name and ARN for the NLBs will be in the `terraform output` as `nlb_deta
239239

240240
#### TLS support
241241

242-
For example purposes, optional TLS support is provided by using `cert-manager` and a self-signed `ClusterIssuer`.
242+
TLS support is provided by using `cert-manager` and a self-signed `ClusterIssuer`.
243243

244244
More advanced TLS support using user-provided CAs or per-Materialize `Issuer`s are out of scope for this Terraform module. Please refer to the [cert-manager documentation](https://cert-manager.io/docs/configuration/) for detailed guidance on more advanced usage.
245245

246-
###### To enable installation of `cert-manager` and configuration of the self-signed `ClusterIssuer`
247-
1. Set `install_cert_manager` to `true`.
248-
1. Run `terraform apply`.
249-
1. Set `use_self_signed_cluster_issuer` to `true`.
250-
1. Run `terraform apply`.
246+
## Upgrade Notes
251247

252-
Due to limitations in Terraform, it cannot plan Kubernetes resources using CRDs that do not exist yet. We need to first install `cert-manager` in the first `terraform apply`, before defining any `ClusterIssuer` or `Certificate` resources which get created in the second `terraform apply`.
248+
#### v0.4.0
249+
We now install `cert-manager` and configure a self-signed `ClusterIssuer` by default.
253250

254-
## Upgrade Notes
251+
Due to limitations in Terraform, it cannot plan Kubernetes resources using CRDs that do not exist yet. We have worked around this for new users by only generating the certificate resources when creating Materialize instances that use them, which also cannot be created on the first run.
252+
253+
For existing users upgrading Materialize instances not previously configured for TLS:
254+
1. Leave `install_cert_manager` at its default of `true`.
255+
2. Set `use_self_signed_cluster_issuer` to `false`.
256+
3. Run `terraform apply`. This will install cert-manager and its CRDs.
257+
4. Set `use_self_signed_cluster_issuer` back to `true` (the default).
258+
5. Update the `request_rollout` field of the Materialize instance.
259+
6. Run `terraform apply`. This will generate the certificates and configure your Materialize instance to use them.
255260

256261
#### v0.3.0
257262
We now install the AWS Load Balancer Controller and create Network Load Balancers for each Materialize instance.

docs/footer.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,24 @@ The DNS name and ARN for the NLBs will be in the `terraform output` as `nlb_deta
1919

2020
#### TLS support
2121

22-
For example purposes, optional TLS support is provided by using `cert-manager` and a self-signed `ClusterIssuer`.
22+
TLS support is provided by using `cert-manager` and a self-signed `ClusterIssuer`.
2323

2424
More advanced TLS support using user-provided CAs or per-Materialize `Issuer`s are out of scope for this Terraform module. Please refer to the [cert-manager documentation](https://cert-manager.io/docs/configuration/) for detailed guidance on more advanced usage.
2525

26-
###### To enable installation of `cert-manager` and configuration of the self-signed `ClusterIssuer`
27-
1. Set `install_cert_manager` to `true`.
28-
1. Run `terraform apply`.
29-
1. Set `use_self_signed_cluster_issuer` to `true`.
30-
1. Run `terraform apply`.
26+
## Upgrade Notes
3127

32-
Due to limitations in Terraform, it cannot plan Kubernetes resources using CRDs that do not exist yet. We need to first install `cert-manager` in the first `terraform apply`, before defining any `ClusterIssuer` or `Certificate` resources which get created in the second `terraform apply`.
28+
#### v0.4.0
29+
We now install `cert-manager` and configure a self-signed `ClusterIssuer` by default.
3330

34-
## Upgrade Notes
31+
Due to limitations in Terraform, it cannot plan Kubernetes resources using CRDs that do not exist yet. We have worked around this for new users by only generating the certificate resources when creating Materialize instances that use them, which also cannot be created on the first run.
32+
33+
For existing users upgrading Materialize instances not previously configured for TLS:
34+
1. Leave `install_cert_manager` at its default of `true`.
35+
2. Set `use_self_signed_cluster_issuer` to `false`.
36+
3. Run `terraform apply`. This will install cert-manager and its CRDs.
37+
4. Set `use_self_signed_cluster_issuer` back to `true` (the default).
38+
5. Update the `request_rollout` field of the Materialize instance.
39+
6. Run `terraform apply`. This will generate the certificates and configure your Materialize instance to use them.
3540

3641
#### v0.3.0
3742
We now install the AWS Load Balancer Controller and create Network Load Balancers for each Materialize instance.

examples/simple/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,13 @@ variable "helm_values" {
162162
variable "install_cert_manager" {
163163
description = "Whether to install cert-manager."
164164
type = bool
165-
default = false
165+
default = true
166166
}
167167

168168
variable "use_self_signed_cluster_issuer" {
169-
description = "Whether to install and use a self-signed ClusterIssuer for TLS. Due to limitations in Terraform, this may not be enabled before the cert-manager CRDs are installed."
169+
description = "Whether to install and use a self-signed ClusterIssuer for TLS. To work around limitations in Terraform, this will be treated as `false` if no materialize instances are defined."
170170
type = bool
171-
default = false
171+
default = true
172172
}
173173

174174
# Outputs

main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ module "certificates" {
113113
install_cert_manager = var.install_cert_manager
114114
cert_manager_install_timeout = var.cert_manager_install_timeout
115115
cert_manager_chart_version = var.cert_manager_chart_version
116-
use_self_signed_cluster_issuer = var.use_self_signed_cluster_issuer
116+
use_self_signed_cluster_issuer = var.use_self_signed_cluster_issuer && length(var.materialize_instances) > 0
117117
cert_manager_namespace = var.cert_manager_namespace
118118
name_prefix = local.name_prefix
119119

@@ -224,7 +224,7 @@ locals {
224224
parameters = local.disk_config.storage_class_parameters
225225
}
226226
} : {}
227-
tls = var.use_self_signed_cluster_issuer ? {
227+
tls = (var.use_self_signed_cluster_issuer && length(var.materialize_instances) > 0) ? {
228228
defaultCertificateSpecs = {
229229
balancerdExternal = {
230230
dnsNames = [

variables.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,13 +276,13 @@ variable "install_aws_load_balancer_controller" {
276276
variable "install_cert_manager" {
277277
description = "Whether to install cert-manager."
278278
type = bool
279-
default = false
279+
default = true
280280
}
281281

282282
variable "use_self_signed_cluster_issuer" {
283-
description = "Whether to install and use a self-signed ClusterIssuer for TLS. Due to limitations in Terraform, this may not be enabled before the cert-manager CRDs are installed."
283+
description = "Whether to install and use a self-signed ClusterIssuer for TLS. To work around limitations in Terraform, this will be treated as `false` if no materialize instances are defined."
284284
type = bool
285-
default = false
285+
default = true
286286
}
287287

288288
variable "cert_manager_namespace" {

0 commit comments

Comments
 (0)