Skip to content

Instantly share code, notes, and snippets.

@JamesWoolfenden
Created June 21, 2016 08:57
Show Gist options
  • Save JamesWoolfenden/8183b6d3e7c676073a304bf154823253 to your computer and use it in GitHub Desktop.
Save JamesWoolfenden/8183b6d3e7c676073a304bf154823253 to your computer and use it in GitHub Desktop.
#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