Created
June 21, 2016 08:57
-
-
Save JamesWoolfenden/8183b6d3e7c676073a304bf154823253 to your computer and use it in GitHub Desktop.
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
#this script assume your using dev and sets it too the prod aws cred | |
Param( | |
[Parameter(Mandatory=$true)] | |
[string]$awsprofile) | |
$exists="$(aws configure get aws_access_key_id --profile $awsprofile)" | |
if ($exists) | |
{ | |
[Environment]::SetEnvironmentVariable("AWS_DEFAULT_PROFILE","$awsprofile","machine") | |
$env:AWS_DEFAULT_PROFILE=$awsprofile | |
[Environment]::SetEnvironmentVariable("AWS_PROFILE","$awsprofile","machine") | |
$env:AWS_PROFILE=$awsprofile | |
[Environment]::SetEnvironmentVariable("AWS_REGION","$(aws configure get region --profile $awsprofile)","machine") | |
$env:AWS_REGION=$(aws configure get region --profile $awsprofile) | |
Write-Host "Switched to AWS Profile: $awsprofile" | |
aws configure list | |
} | |
else | |
{ | |
Write-Error "Profile: $awsprofile not found" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment