Skip to content

Commit

Permalink
fix: wrong words (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsxu authored Aug 24, 2023
1 parent f543069 commit 73acc1b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ This repository contains Terraform managed Helm charts used by StreamNative Plat
## Example Usage
The [submodules](https://github.com/streamnative/terraform-helm-charts/tree/master/modules) in this repo can be used in a standalone fashion. However, the root module (contained in the [root `main.tf` file](https://github.com/streamnative/terraform-helm-charts/blob/master/main.tf)) [composes](https://www.terraform.io/docs/language/modules/develop/composition.html) all of the submodules to be used in concert with each other, depending on your configuration needs.

Here is a simple example on how to use the root module in this repo for the common StreamNative Platform use case. It will install the Vault, Prometheus, Pulsar, and Function Mesh operators:
Here is a simple example of how to use the root module in this repo for the common StreamNative Platform use case. It will install the Vault, Prometheus, Pulsar, and Function Mesh operators:

```hcl
data "aws_eks_cluster" "cluster" {
Expand Down Expand Up @@ -61,16 +61,16 @@ terraform init && terraform apply
```

## Why are all the variable defaults null?
The submodules contained in this repo are typically composed in the root module, and as such many of a submodules variables get duplicated in the root module.
The submodules contained in this repo are typically composed in the root module, and as such many of the submodules variables get duplicated in the root module.

This introduces a problem where we don't want to also duplicate default values in both places, i.e. managing a default value in the root module _and_ in the submodule, as they are difficult to synchronize and have historically drifted away from each other.
This introduces a problem where we don't want to duplicate default values in both places, i.e. managing a default value in the root module _and_ in the submodule, as they are difficult to synchronize and have historically drifted away from each other.

In a perfect world, the approach we would like to take is:

- Have the root module's variables that map to a submodule's variables default to `null`
- Have the submodule's variables default to their expected value

However, when we do this, the root module _overrides_ the submodule's default value with `null`, rather than respect it and treat `null` as an omission. This unfortunately is [expected](https://github.com/hashicorp/terraform/issues/24142#issuecomment-646393631) behavior](https://github.com/hashicorp/terraform/issues/24142#issuecomment-646393631) in Terraform, where `null` is actually a valid value in some module configurations (instead of being "the absence of a value", like we want it to be and also like the Terraform documentation states).
However, when we do this, the root module _overrides_ the submodule's default value with `null`, rather than respect it and treat `null` as an omission. This, unfortunately, is [expected](https://github.com/hashicorp/terraform/issues/24142#issuecomment-646393631)](https://github.com/hashicorp/terraform/issues/24142#issuecomment-646393631) behavior](https://github.com/hashicorp/terraform/issues/24142#issuecomment-646393631) in Terraform, where `null` is actually a valid value in some module configurations (instead of being "the absence of a value", like we want it to be and also like the Terraform documentation states).

To work around this, we set the default values in _both_ the root module and submodules to `null`, then use a `locals()` configuration in the submodule to manage the expected default values. To illustrate, here is a simple example:

Expand Down

0 comments on commit 73acc1b

Please sign in to comment.