Homebrew Terraform



This is a quick guide to getting started with Kitchen-Terraform. It provides instructions for installing dependencies, creating a new Terraform module, and writing InSpec tests.

Homebrew-terraforms - Homebrew Casks for all Terraform versions. This repository includes Homebrew Casks to install multiple (or even all!) Terraform versions at the same time. It also includes Homebrew Formula for chtf, a Terraform version switcher. Terraform-docs is available on Linux, macOS, Windows, and FreeBSD platforms. If you are a macOS user, you can use Homebrew. Brew install terraform-docs Windows#. If you are a Windows user: Scoop#. You can use Scoop. »Terraform CLI Documentation Hands-on: Try the Terraform: Get Started collection on HashiCorp Learn. This is the documentation for Terraform CLI. It is relevant to anyone working with Terraform's CLI-based workflows; this includes people who use Terraform CLI by itself, as well as those who use Terraform CLI in conjunction with Terraform Cloud or Terraform Enterprise.

General Methods:

Install Terraform: https://www.terraform.io/downloads.html
Install Ruby: https://www.ruby-lang.org/en/documentation/installation/ Homebrew

Platform Methods

Mac OS (homebrew):

Useful Dependency Managers

tfenv
rbenv
Create module and folder structure by running these commands:
Create the

Gemfile

to install our dependencies.
Install Kitchen-Terraform and other rubygems, install bundler if not installed yet.
Create the Test Kitchen configuration file,

.kitchen.yml

and configure the kitchen-terraform plugins to associate the fixture Terraform module with the InSpec profile.
Please refer back to this file as we continue to move on, take special note of the root_module_directory (test/fixtures/tf_module), control name under verifier (file_check), and the suite name (kt_suite). Each of these correspond to a folder structure and Inspec control test. Create this file

main.tf

and add the block of code into it.
Create Terraform fixture code that will call the null_resource from above. This helps simulate calling the Terraform code as a module.
Create this file

test/fixtures/tf_module/main.tf

and add the block of code into it.
Apply the fixture Terraform module configuration with Test Kitchen.
With the Terraform code created, it's now time to create the Inspec control tests. Please see the Inspec documentation to learn more about profiles and controls.
Create a default profile

test/integration/kt_suite/inspec.yml

Homebrew Terraform 12


Create Inspec control test file

test/integration/kt_suite/controls/basic.rb


Run Inspec control tests with Test-Kitchen.
Kitchen-Terraform with the help of Test-Kitchen and Inspec have validated the results of running the Terraform code! Please take a peek at our documentation and tutorials for additional information.
  • 3Homebrew (Option 1)
  • 5Verify Install

Purpose

Terraform

This article gives a couple options on how to install or setup Terraform on a macOS Sierra system. The first optional way is to use HomeBrew. Which simplifies the install process and makes updating easy too.


Prerequisites

  • Homebrew (IF going Homebrew way instead of downloading zip.)


Homebrew (Option 1)

The easiest and quickest way to install Terraform is using Homebrew.

Install Example


A symlink will be created for the binary /usr/local/bin/terraform -> ../Cellar/terraform/0.9.1/bin/terraform

Upgrading


Manually (Option 2)

The versions seem to be bottled up very quickly with HomeBrew so I see little reason why to do a manual install, but this is how you do it.

  1. Download binary zip from HashiCorp
    https://www.terraform.io/downloads.html
  2. Unzip
  3. Copy binary to a place in the path such as /usr/local/bin/terraform


Verify Install

A simple test that the binary is in the path and such is to call the version.

Example


Homebrew Terraform 0.11

Sources

Homebrew Cask Terraform

Retrieved from 'https://www.bonusbits.com/index.php?title=HowTo:Install_Terraform_on_macOS&oldid=9579'