From the course: Developing Infrastructure as Code with Terraform

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

About expressions in HCL

About expressions in HCL

- Okay, Terraform supports expressions in its configuration. And so those can take on a bunch of forms so we're going to go through those now. So the first one I want to point out is something called a local. And the name local is a little bit confusing. This is what you might think of in another programming language as a variable. Variable has another meaning in Terraform, and we're going to go over that in another section. But it's just a way of storing a value that you can refer to later. So in this first example, we're just storing a simple string. But we can do other things. We can store the result of an expression in a local. So you can see in this example a little bit further down, we are storing the result of this expression. And this expression has a reference. So we are referring to this first local within another local. And you can see there's a little bit of a confusing syntax here. So it's local, it's not locals. That's a very common source of errors that I make and that…

Contents