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
From the course: Essential Terraform in AWS
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
-
-
-
-
(Locked)
Learning objectives2m 17s
-
(Locked)
Viewing the step-by-step instructions7m 14s
-
(Locked)
Creating a main.tf file6m 40s
-
(Locked)
Formatting Terraform code4m 40s
-
(Locked)
Initializing the working directory7m 40s
-
(Locked)
Validating Terraform code7m 34s
-
(Locked)
Viewing the Terraform plan7m 31s
-
(Locked)
Applying the infrastructure to AWS7m 27s
-
(Locked)
Analyzing the state file5m 17s
-
(Locked)
Destroying the infrastructure10m 13s
-
(Locked)
Quiz9m 24s
-
(Locked)
-
-
-
-