From the course: Learning Terraform

Unlock the full course today

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

Terraform style

Terraform style

- [Instructor] Let's take a minute to review some of the Terraform coding style conventions. There are just a few rules and they're also well documented on the Terraform website. Here's an example from the Terraform docs. We'll walk through it to illustrate some of the style suggestions. The proper indentation in a Terraform file is two spaces rather than a tab. Some editors will let you set that as a default for Terraform files. This first line of the resource also has what's called a meta argument, which we haven't talked about yet. A standard argument defines something that Terraform will ultimately pass along to AWS or whatever provider you're using. A meta argument defines how you want Terraform to interpret your code. In this case, Terraform will deploy two instances based on this meta argument. Another common use of meta arguments is to explicitly define a dependency relationship between two resources so that Terraform knows to provision one before the other. Speaking of meta…

Contents