Following procedure descibes setting up Profiles in PowerShell for AWS Credentials/Accounts:
A) Obtain the AWS keys (-AccessKey and -SecretKey) from AWS IAM User Accounts
B) Run the following commands to store these keys
:> Set-AWSCredentials –AccessKey <AccessKey> –SecretKey <SecretKey> -StoredCredentials <profileName>
Repeat the above command for multiple profiles
C) Discard the current powershell and start a new one. To load the credentials into the new shell, run the same cmdlet, but this time pass the profile name you specified as the -StoredCredentials parameter:
:> Set-AWSCredentials -StoredCredentials <profileName>
D) Make Profiles added to PS Session
Right-click Windows PowerShell, and then click Run as administrator.
- At the Windows PowerShell prompt, type the following command, and then press ENTER:
:> Test-path $profile
If the results of the this command are false, go to step 2.
If the results are true, go to step 3.
- Type the following command, and then press ENTER.
:> New-item –type file –force $profile - Type the following command, and then press ENTER.
:> Notepad $profile - Add the following lines, save and exit:
Set-AWSCredentials -StoredCredentials <Profile-1>
Set-AWSCredentials -StoredCredentials <Profile-2>
Set-DefaultAWSRegion <Region Name> - Discard the current powershell and start a new one.
:> Get-AWSCredentials -ListProfiles
E) Local file of profiles are stored in - C:\Users\%username%\AppData\Local\AWSToolkit\RegisteredAccounts.json.
In case they get corrupted for some reason, rename the file and add the keys.