Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

A variable is a special kind of value, where the value itself is not defined as part of the configuration , but is provided from an external system. This could be things like keys for Azure blob storage, which is something that needs to be different between environments, but where the underlying purpose of having a "blob storage" is the same.

...

Code Block
variable my_variable {
  type = "string"
}

The system will throw you an error if you do not have the variable in use in any resource.

Variables have to be used in the layer they are defined in. If you want to use a variable in multiple layers, you will have to add an identical variable to the other layer it should be used in. This will make the variable only show up once in the variable editor.

You may choose to define a default value. A string field with a default would appear as such:

Code Block
variable my_variable {
  type = "string"
  default = 'Some default text'
}

If you have the same variable key in multiple layers, you do have the option to have the defaults be different (if you define one, you have to define all others). It will appear as such in the variable editor.

...

Locals

Locals a are temporary values that are used internally to allow easily reusing certain values without repeating them over and over.

...