avatar⚗ Kevin Summersill 🔋

Summary

The article provides instructions for configuring Visual Studio Code to automatically recognize .tf files by setting up the .vscode directory and modifying the settings.json file.

Abstract

The web content outlines a solution for a common issue encountered in Visual Studio Code (VSCode) where .tf files, used for Terraform infrastructure as code, are not automatically recognized after installing the "Hashicorp Terraform" extension. The article guides readers through creating a .vscode directory if it doesn't already exist, and then editing or creating a settings.json file within that directory. The key step involves associating .tf and related file types with the Terraform plugin by adding specific entries to the files.associations setting in settings.json. The author emphasizes the ease of this process and encourages readers to subscribe for more content, while also promoting a personal "Buy Me A Coffee" page for support.

Opinions

  • The author assumes that readers have already installed the "Hashicorp Terraform" extension in VSCode.
  • The process of setting up the .vscode directory and settings.json file is presented as straightforward and user-friendly.
  • The author suggests that associating file types with the correct plugin is crucial for .tf files to be recognized and handled properly in VSCode.
  • The article is positioned as a quick and helpful guide, implying that such tips are valuable to the target audience of developers and DevOps professionals.
  • By inviting readers to subscribe and visit their "Buy Me A Coffee" page, the author indicates a desire to create a community and receive support for producing similar content.
Photo by Ryland Dean on Unsplash

Set up Terraform in VSCode to Automatically Recognize .TF files

Hashicorp | Visual Studio Code | Settings | Extensions | DevOps

So there are times that after installing the extension that .tf files are not automatically recognized in Visual Studio Code. For this reason, I am going to write a quick article on how to do this with ease. This article does assume that you have already installed the Extention called “Hashicorp Terraform”.

Step 1. Create a .vscode directory

Now if you have made any setting changes in VSCode then you probably already have a directory called .vscode. When in that directory there should be a settings.json file. Of course, if there is not a settings.json file then create the file.

Step 2. Setup settings.json file to read .tf files

Add the following to the settings.json file.

{
"files.associations": {
        "terragrunt.hcl": "terraform",
        "*.tfvars": "terraform",
        "*.tf": "terraform",
        "*.tf.override": "terraform",
    }
}

The main thing to add is in the file. associations the extension types and which type of plugin will be associated with it.

Save the file after modifying it. That's It! You should now be able to see that the .tf files are automatically updated.

This was a quick article and if you like more of these then please subscribe. Thanks!

DevOps
Programming
Development
Coding
Marketing
Recommended from ReadMedium