Skip to content

Commit

Permalink
feat: add standard for nullable/empty input variables
Browse files Browse the repository at this point in the history
  • Loading branch information
yohanb committed Oct 6, 2023
1 parent 5180a16 commit 0f87cec
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions docs/style/input-variables.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Input Variables

If an input variable needs to be defined as null or emtpy:

- prefer using a `nullable` variable with a default value of `null`
- if a `nullable` variable is not possible, use a `string` variable with a default value of `""` and add an explanation why.

Examples:

```hcl
variable "foo" {
type = string
description = "This variable is a string that can be null"
default = null
}
variable "bar" {
type = string
description = "This variable is a string that can be empty, but not null"
nullable = false
# Add an explanation why this variable is not nullable
default = ""
}
```
2 changes: 1 addition & 1 deletion docs/style/naming.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Naming

First - follow all the guidance in https://www.terraform-best-practices.com/naming
First - follow all the guidance in [https://www.terraform-best-practices.com/naming](https://www.terraform-best-practices.com/naming)

## File names

Expand Down

0 comments on commit 0f87cec

Please sign in to comment.