Skip to content

ptavares/powershell-terraform-tools

Repository files navigation

PowerShell Terraform Tools

GitHub License PowerShell Gallery Version (including pre-releases) PowerShell Gallery

Description

A PowerShell module for Terraform, a tool from Hashicorp for managing infrastructure safely and efficiently.

It will install the following Terraform tools :

It also provides some useful terraform aliases for everyday use.

Table of content

⚙️ Installation

Install or update from PowerShell Gallery

  • Install
Install-Module terraform-tools -Scope CurrentUser -AllowClobber
  • Update
Install-Module terraform-tools -Scope CurrentUser -AllowClobber -Force

⚠️ If you haven't allowed script execution policy, set your script execution policy to RemoteSigned or Unrestricted.

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

🛂 Usage

You have to import the module to use terraform-tools.

Add below command into your PowerShell profile.

Import-Module terraform-tools -DisableNameChecking

Then restart your PowerShell.

  • First time : will download, install and add all Terraform tools managed by this module to your user $PATH
  • Then : will only add tools to your $PATH

Now you can use wanted tool or uses wanted aliases.

🛈 Install terraform command using tfswitch command

tfswitch

If you facing issue with current version of tfswitch, have a look at my fork


⚠️ If you don't have PowerShell profile yet, create it with below command!

New-Item -ItemType File $profile

Aliases

Here is the list of availabe aliases provides by this module :

Alias Command
tf terraform
tff tf fmt
tfv tf validate
tfi tf init
tfp tf plan
tfa tf apply
tfd tf destroy
tfo tf output
tfr tf refresh
tfs tf show
tfw tf workspace
tffr tff -recursive
tfip tfi & tfp
tfia tfi & tfa
tfid tfi & tfd
tfa! tfa -auto-approve
tfia! tfi && tfa!
tfd! tfd -auto-approve
tfid! tfi && tfd!
tfversion tf version
tfws tfw select -or-create [workspace_name]

Function

# Show all aliases available in module

Get-TerraformAliases
# Show a specific alias available in module

Get-TerraformAliases [alias_name]

Updating Terraform tools

The module comes with a PowerShell function to update all Terraform tools when you want

Update-TerraformTools

License

MIT