Created
January 18, 2020 13:57
-
-
Save rkttu/275dcd30b5824f5929aafad4695f0dfb to your computer and use it in GitHub Desktop.
Terraform Alias Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function global:Invoke-Terraform { | |
[CmdletBinding()] | |
[Alias('tf')] | |
param ( | |
[parameter(Mandatory=$False,Position=0,ValueFromRemainingArguments=$True)] | |
[Object[]] $Arguments | |
) | |
begin { | |
$PrevAwsProfile = $env:AWS_PROFILE; $env:AWS_PROFILE='saml' | |
} | |
process { | |
$Result = & terraform.exe @Arguments | |
return $Result | |
} | |
end { | |
$env:AWS_PROFILE = $PrevAwsProfile | |
} | |
} | |
# Example | |
# tf version | |
# tf init | |
# tf select workspace abc | |
# $content = tf version; $content |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment