Why env0
Solutions
Infrastructure as Code (IaC) Automation Teams and GovernanceManaged Self-Service env0 for the Enterprise
DocumentationPricing
Resources
Case StudiesIn the NewsVideosWebinars
Blog
Login
Get a Demo
FREE TRIALContact us
Feb 16, 2022

TFLint with Custom Flows

Andrew Way
Director of Sales Engineering

Developers have compilers and linters to help catch errors while they’re coding. DevOps engineers have something similar for Terraform through TFLint.  Our DevOps Advocate, Tim, recently featured it in his Quick Tech series here (check out the 2.5-minute video for a quick demo of TFLint standalone).

So what’s TFLint? It’s an open-source project for Terraform, and it allows you to catch common errors, warn about deprecated syntax, and enforce best practices.

This post will show you how one of our community members integrated TFLint into their env0 deployment process using our Custom Flows feature.

Sample code can be found here.  Special shout out to Matt McLane (DocNetwork) for contributing this example.

Integrating TFLint with env0 -- What’s in it for you?

First, why should we integratie TFLint?  Similar to any developer tool, linting helps us check that we’re following best practices, catching mistakes early, and enforcing basic style guidelines.  By catching mistakes earlier, we’re “shifting-left” and giving the DevOps engineer a quicker heads-up to possible issues  in the deployment lifecycle.  By integrating TFLint into env0, we ensure greater consistency with additional safety in our deployments!

The Setup

In order to get TFLint running in your env0 deployment, you need to utilize env0’s Custom Flows feature.  This simply means adding an `env0.yml` in the repo where your Terraform files reside.

Here are the contents of the `env0.yml`

version: 1

deploy:
   steps:
     setupVariables:
         after:
            - curl -L https://github.com/terraform-linters/tflint/releases/download/v0.32.1/tflint_linux_amd64.zip -o tflint.zip && unzip tflint.zip -d /opt && rm tflint.zip
            - tflint --version
            - cp ../../.tflint.hcl . # Change this path to be reflect to your repository.
            - tflint --init

   
      terraformInit:
         after:
            - tflint 1>&2

This Custom Flow will download the tflint binary, copy the tflint.hcl which contains the plugins configuration (like which cloud provider) for tflint, and lastly, perform a tflint init to download the plugins for tflint.

Note: “1>&2” is an I/O redirection to help env0 display errors at the top of the deployment UI.

In Action

Here is a complete example of the tflint integration in action: GitHub Repo.

For demonstration purposes, we will purposefully set an unsupported instance size for EC2 to “t1000.xxlarge”


Interested in learning more about env0?
Request a Demo
SHARE
You may also like
Recommendations for Migrating from Terraform Cloud
Infrastructure as Code is a Creative Job
How to integrate Azure DevOps with env0
Go back to blog
CNCF Member Badge
Company
About UsIn the NewsPress ReleasesCase StudiesAdditional ResourcesCareers
Developer and DevOps
APITerraform ProviderTerratag Open Source
Terraform Cloud AlternativeDIY AlternativeAtlantis Alternative
FREE TRIAL
Follow Us
Terms of ServicePrivacy PolicySecuritySystem Status
© Copyright env0 2023
This website uses cookies. We use cookies to ensure that we give you the best experience on our website. Learn More
PreferencesDenyAccept
Privacy Preference Center
When you visit websites, they may store or retrieve data in your browser. This storage is often necessary for the basic functionality of the website. The storage may be used for marketing, analytics, and personalization of the site, such as storing your preferences. Privacy is important to us, so you have the option of disabling certain types of storage that may not be necessary for the basic functioning of the website. Blocking categories may impact your experience on the website.
Reject all cookiesAllow all cookies
Manage Consent Preferences by Category
Essential
Always Active
These items are required to enable basic website functionality.
Marketing
These items are used to deliver advertising that is more relevant to you and your interests. They may also be used to limit the number of times you see an advertisement and measure the effectiveness of advertising campaigns. Advertising networks usually place them with the website operator’s permission.
Personalization
These items allow the website to remember choices you make (such as your user name, language, or the region you are in) and provide enhanced, more personal features. For example, a website may provide you with local weather reports or traffic news by storing data about your current location.
Analytics
These items help the website operator understand how its website performs, how visitors interact with the site, and whether there may be technical issues. This storage type usually doesn’t collect information that identifies a visitor.
Confirm my preferences and close