Git Product home page Git Product logo

tfenv's Introduction

Build Status

tfenv

Terraform version manager inspired by rbenv

Support

Currently tfenv supports the following OSes

  • Mac OS X (64bit)
  • Linux
  • 64bit
  • Arm
  • Windows (64bit) - only tested in git-bash

Installation

Automatic

Install via Homebrew

$ brew install tfenv

Install via puppet

Using puppet module sergk-tfenv

include ::tfenv

Manual

  1. Check out tfenv into any path (here is ${HOME}/.tfenv)
$ git clone https://github.com/kamatama41/tfenv.git ~/.tfenv
  1. Add ~/.tfenv/bin to your $PATH any way you like
$ echo 'export PATH="$HOME/.tfenv/bin:$PATH"' >> ~/.bash_profile

OR you can make symlinks for tfenv/bin/* scripts into a path that is already added to your $PATH (e.g. /usr/local/bin) OSX/Linux Only!

$ ln -s ~/.tfenv/bin/* /usr/local/bin

On Ubuntu/Debian touching /usr/local/bin might require sudo access, but you can create ${HOME}/bin or ${HOME}/.local/bin and on next login it will get added to the session $PATH or by running . ${HOME}/.profile it will get added to the current shell session's $PATH.

$ mkdir -p ~/.local/bin/
$ . ~/.profile
$ ln -s ~/.tfenv/bin/* ~/.local/bin
$ which tfenv

Usage

tfenv install [version]

Install a specific version of Terraform. Available options for version:

  • i.j.k exact version to install
  • latest is a syntax to install latest version
  • latest:<regex> is a syntax to install latest version matching regex (used by grep -e)
  • min-required is a syntax to recursively scan your Terraform files to detect which version is minimally required. See required_version docs. Also see min-required section below.
$ tfenv install 0.7.0
$ tfenv install latest
$ tfenv install latest:^0.8
$ tfenv install min-required
$ tfenv install

If shasum is present in the path, tfenv will verify the download against Hashicorp's published sha256 hash. If keybase is available in the path it will also verify the signature for those published hashes using hashicorp's published public key.

.terraform-version

If you use .terraform-version, tfenv install (no argument) will install the version written in it.

min-required

Please note that we don't do semantic version range parsing but use first ever found version as the candidate for minimally required one. It is up to the user to keep the definition reasonable. I.e.

// this will detect 0.12.3
terraform {
  required_version  = "<0.12.3, >= 0.10.0"
}
// this will detect 0.10.0
terraform {
  required_version  = ">= 0.10.0, <0.12.3"
}

Specify architecture

Architecture other than the default amd64 can be specified with the TFENV_ARCH environment variable

TFENV_ARCH=arm tfenv install 0.7.9

tfenv use <version>

Switch a version to use

latest is a syntax to use the latest installed version

latest:<regex> is a syntax to use latest installed version matching regex (used by grep -e)

min-required will switch to the version minimally required by your terraform sources (see above tfenv install)

$ tfenv use min-required
$ tfenv use 0.7.0
$ tfenv use latest
$ tfenv use latest:^0.8

tfenv uninstall <version>

Uninstall a specific version of Terraform latest is a syntax to uninstall latest version latest:<regex> is a syntax to uninstall latest version matching regex (used by grep -e)

$ tfenv uninstall 0.7.0
$ tfenv uninstall latest
$ tfenv uninstall latest:^0.8

tfenv list

List installed versions

% tfenv list
* 0.10.7 (set by /opt/tfenv/version)
  0.9.0-beta2
  0.8.8
  0.8.4
  0.7.0
  0.7.0-rc4
  0.6.16
  0.6.2
  0.6.1

tfenv list-remote

List installable versions

% tfenv list-remote
0.9.0-beta2
0.9.0-beta1
0.8.8
0.8.7
0.8.6
0.8.5
0.8.4
0.8.3
0.8.2
0.8.1
0.8.0
0.8.0-rc3
0.8.0-rc2
0.8.0-rc1
0.8.0-beta2
0.8.0-beta1
0.7.13
0.7.12
...

.terraform-version

If you put .terraform-version file on your project root, or in your home directory, tfenv detects it and use the version written in it. If the version is latest or latest:<regex>, the latest matching version currently installed will be selected.

$ cat .terraform-version
0.6.16

$ terraform --version
Terraform v0.6.16

Your version of Terraform is out of date! The latest version
is 0.7.3. You can update by downloading from www.terraform.io

$ echo 0.7.3 > .terraform-version

$ terraform --version
Terraform v0.7.3

$ echo latest:^0.8 > .terraform-version

$ terraform --version
Terraform v0.8.8

Upgrading

$ git --git-dir=~/.tfenv/.git pull

Uninstalling

$ rm -rf /some/path/to/tfenv

LICENSE

tfenv's People

Contributors

kamatama41 avatar iamhsa avatar zordrak avatar dooreelko avatar mbainter avatar dmlemos avatar pyro2927 avatar mkielar avatar myoung34 avatar sebolabs avatar sergk avatar vikeri avatar devnev avatar dragon788 avatar yukirii avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.