From the course: Essential Terraform in AWS

Unlock this course with a free trial

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

Formatting Terraform code

Formatting Terraform code

- [Instructor] Now let's show how to format our Terraform code. So the code I've supplied you with is formatted properly right now, but let's imagine that we were typing the code line by line. Sometimes you might put in extra spaces and you might have an indent that's too far, or you might have some additional spaces over here, or maybe this curly braces got moved over, and this'll happen sometimes. Now you'll notice that this doesn't really cause an error. This code will still work. There are no red lines or anything like that. There are no error warnings here. So this code will still function, but it's not formatted to Terraform standards and conventions. So, let's show the terraform fmt command, which can clean up all of your files automatically. First, I'm going to save this with Ctrl+s. Then we'll bring the terminal back up and we'll run the terraform fmt command. FMT is short format. Watch our mistakes that we made here when we press enter. When we do so, it moves AWS over and…

Contents