Skip to content
/ tfexe Public

Rust-powered wrapper for seamless execution of tfswitch and Terraform with version control.

License

Notifications You must be signed in to change notification settings

Ant0wan/tfexe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Logo

Rust-powered wrapper for seamless execution of tfswitch and Terraform with version control.


Table of Contents

Prerequisites

Before installing and using tfexe, you will need to have the following tools installed on your system:

  • wget: A command-line utility used for downloading files.
  • tfswitch: A tool used for switching between different versions of TensorFlow.

Installation

To install tfexe, simply run the install.sh script provided in this repository. The script will automatically download and install the necessary dependencies, and set up tfexe on your system.

wget -q -O -  https://raw.githubusercontent.com/Ant0wan/tfexe/master/install.sh | sh

Usage

  1. Install tfexe by following the installation instructions in the tfexe GitHub repository.
  2. Create a Terraform configuration file (e.g., main.tf, providers.tf...) with the following content:
terraform {
  required_version = "~> 1.3.0"
}

# Define your Terraform resources and providers here
  1. In the command line instead of using the classic Terraform binary, use tfexe to execute Terraform commands. tfexe will automatically detect the required version of Terraform specified in your Terraform configuration file (required_version in this case, which is set to "~> 1.3.0") and download and execute the appropriate Terraform binary for you. For example:
# Run Terraform init with tfexe
$ tfexe init
Reading required version from terraform file
Reading required version from constraint: ~> 1.3.0
Matched version: 1.3.9
Installing terraform at /home/antoine/bin
Switched terraform to version "1.3.9"

Initializing the backend...

Initializing provider plugins...

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.

Note: tfexe will automatically execute tfswitch internally to switch to the specified Terraform version before running the Terraform command, based on the content of the providers.tf file in your Terraform configuration directory.

If no version of Terraform is specified in tf files, it will display the same prompt as tfswitch:

$ tfexe
Use the arrow keys to navigate: ↓ ↑ → ←
? Select Terraform version:
    1.4.5 *recent
    1.3.9 *recent
    1.2.9 *recent
  ▸ 1.4.4
↓   1.4.3

Note: You can set an alias in your shell, such as Bash or Zsh, to use tfexe as a replacement for the terraform command. This can be done by adding the line to your shell profile file (e.g., .bashrc, .bash_profile, or .zshrc). Once the alias is set, you can use terraform in any script or wrapper call, and it will automatically execute tfexe with the proper Terraform version based on your configuration.

alias terraform='tfexe'

That's it! You can now use tfexe as a drop-in replacement for the classic Terraform binary to execute Terraform commands, and it will automatically manage the versioning for you based on the required_version specified in your Terraform configuration file and the content of your providers.tf file.

How it works

graph TD
    start(Start)
    TFEXE_set{TFEXE env variable set?}
    TFEXE_unset{TFEXE env variable unset?}

    start --> TFEXE_set
    start --> TFEXE_unset

    TFEXE_set -->|TFEXE value| tfexe_executes[tfexe executes TFEXE]
    TFEXE_unset -->|'tfswitch' is available| tfswitch_executes[tfexe executes tfswitch]
    TFEXE_unset -->|'tfswitch' is not available| terraform_executes[tfexe executes terraform]

    tfexe_executes -->|TFEXE set to 'tofu'| tofu_executes[tfexe executes tofu]
    tfexe_executes -->|TFEXE set to 'terraform'| terraform_executes[tfexe executes terraform]
    tfexe_executes -->|TFEXE set to 'tfswitch'| tfswitch_executes[tfexe executes tfswitch]

    tfswitch_executes -->|execute appropriate 'terraform' version| terraform_executes[tfexe executes terraform]

Loading

License

This repository is protected by the GPL3 (GNU General Public License v3.0). You can find the full text of the license in the LICENSE file. Please review and comply with the terms and conditions of the GPL3 license before using or contributing to this project.

For any questions, bug reports, or contributions, please feel free to open an issue or submit a pull request. Thank you for using tfexe!

About

Rust-powered wrapper for seamless execution of tfswitch and Terraform with version control.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks