Created
November 7, 2017 15:33
-
-
Save cmaggiulli/2334d4fb42bf129bb3d905a80f6365ad to your computer and use it in GitHub Desktop.
AWS Key Setup for Windows CLI and Programmatic use
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
$access_key_id = $args[0] | |
$secret_access_key = $args[1] | |
$dir = Join-Path $env:userprofile "\.aws\" | |
$file = Join-Path $dir "credentials" | |
if (-NOT (Test-Path $dir)) { | |
New-Item $dir -type Directory | |
} | |
if (-NOT (Test-Path $file)) { | |
New-Item $file -type File | |
} | |
if((Get-Content $file) -eq $Null) { | |
Add-Content $file "[default]" | |
Add-Content $file "aws_access_key_id = $access_key_id" | |
Add-Content $file "aws_secret_access_key = $secret_access_key" | |
} | |
[Environment]::SetEnvironmentVariable("AWS_ACCESS_KEY_ID", $access_key_id, "User") | |
[Environment]::SetEnvironmentVariable("AWS_SECRET_ACCESS_KEY", $secret_access_key, "User") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment