Terraform Locals vs Variables

I am learning how to use terraform locals. I am trying to follow so examples from this article.

What are the differente locals and variables?

Could you rephrase you question?

The Terraform documentation about Local Values includes the following summary as an attempt to differentiate the three kinds of “named values” by analogy to concepts in popular general-purpose programming languages:

If you’re familiar with traditional programming languages, it can be useful to compare Terraform modules to function definitions:

  • Input variables are like function arguments.
  • Output values are like function return values.
  • Local values are like a function’s temporary local variables.

Hopefully that analogy is helpful to you! If not, perhaps you have some more specific questions which we could use to move the discussion forward.