Intro
I’ve been finding myself editing automation code for tools like Terraform (A platform agnostic infrastructure provisioning tool) more frequently in the past few months.
No longer satisfied with using vim (Sorry fans!) I decided to make the switch to Atom.
So far things have been going smoothly but I knew the tool could help me write better Terraform code with a few more tweaks (or more importantly, plugins).
The Plugins
The following plugins helped provide me with basic completion, syntax highlighting, linting, and automatic formatting for all my Terraform .tf files.
atom-beautify
linter
linter-terraform-syntax
language-terraform
Instead of writing a lengthy article on about how totally awesome all this is, I’ve decided to help you get started as quickly as possible.
Get Started Quickly
Assuming you already have terraform
in your PATH, the following code is install and forget (minus one change I’ll mention after the code snippet).
Just copy and paste into your terminal of choice.
apm install atom-beautify linter linter-terraform-syntax language-terraform
A Small Note
If you’d like terraform fmt
to occur on each save, you’ll need to make a small change to atom-beautify.
- Go to the packages menu (Edit>Preferences>Packages)
- Click the “Settings” tab on atom-beautify
- Find and click Terraform to expand it (List is in alphabetical order)
- Make sure the “Beautify On Save” checkbox is ticked.
- ???
- PROFIT!
In Closing
While this article is rather short, it should help you quickly setup Atom for easily editing Terraform .tf files.
If you have any questions, feel free to comment below.
Happy automating!
Hey Robert,
Thanks for the advice on these atom packages for maintaining Terraform modules.
Saw multiple statements and thought I might ask if you’ve noticed that you can install multiple packages inline as you can with yum/apt/pip?
apm install atom-beautify linter linter-terraform-syntax language-terraform
Cool article!
Hey Ryan,
No problem! I had not tried and so wasn’t aware.
Knowing is half the battle (The other half was updating the article with your suggestion)
Thanks for the tip 😀
~RT
Thank you for this article. I used it to install and set up my environment to develop Terraform code.
I was wondering if there is a plugin that actually “understand” terraform like the fabulous plugin to Intellij? You get context sensitive help and auto completion on the structure. Does anything in Atom support that?
Hey Christian,
As far as I know, I’m not sure if there is anything in Atom that will provide completion as full fledged as something in Intellij.
If you happen to find something though, let me know! I’d certainly be interested 🙂
~RT
What do you guys use to comment out multiple lines of terraform code?
–> cmd + / doesn’t work on .tf extension
There is an open bug with atom-beautify which is failing for .tf files in terraform version 0.12. Were you able to use terraform fmt in atom with the latest version of terraform?
https://github.com/Glavin001/atom-beautify/issues/2348
Hey Vignesh! Unfortunately, I no longer utilize Atom for Terraform development. That particular bug was part of the reason I switched over to VSCode.
While 0.12 support is still a work in progress in VSCode as well, the support is generally much better.
If you’re open to a switch it may be worth giving VSCode a try.
You can see the plugin that handles things in VSCode below.
https://github.com/mauve/vscode-terraform