Terraform formatting does not work in VS Code

Today I’m setting up my new laptop. One of the tool I’ve been used recently is terraform. And I’d like to use VS Code as my code editor.

By using the fresh install of VS Code, it doesn’t give you the ability to format your terraform template (*.tf). BTW, the shortcut for formatting text in VS Code is option+shift+P.

After a few minutes of troubleshooting, I realised I didn’t install terraform.

brew install terraform

Once I’ve installed terraform on my laptop, I hit the option+shift+P shortcut. VS Code pops a window to download the formatting plugin.

Everything is automatically complete. Now I can enjoy the “lazy” formatting for my terraform template.