On Windows, in the VSCode Terminal (which I believe is Powershell), I am attempting to work with the aws cli, and as part of that, I need to setup and refer to a profile that has credentials to connect to my AWS account. A month or so ago, I was using a profile named xxxx_AWSAdministratorAccess (where xxxx is my AWS account number), and all was working as expected. Today, I want to use different credentials, so I setup a new profile named CICD. If I set my profile using the aws configure
command, it will work for that session. However if I create a new Terminal session, or start a new instance of VSCode, it reverts back to the xxxx_AWSAdministratorAccess profile.
I noticed in the Terminal there is an environment variable named AWS_PROFILE and this is set to xxxx_AWSAdministratorAccess. I have changed this using $env:AWS_PROFILE = 'CICD'
as well as [System.Environment]::SetEnvironmentVariable('AWS_PROFILE','CICD')
. Both work as they set the environment variable to CICD, and the latter command is supposed to persist the value according to what I read. It sort of works as I can open up a PowerShell session away from VSCode and it will also report the correct AWS profile, but as soon as I close the VSCode Terminal and re-open it reverts back to the xxxx_AWSAdministratorAccess value. It appears VSCode or an extension or something is caching this value, but I can't figure out where. Thoughts?
CodePudding user response:
Per the comment from @rioV8 above, I opened a new Powershell window, set the AWS_PROFILE to CICD, and then launched VSCode from there. When I launched a new Terminal window inside VSCode, and ran dir env:
the AWS_PROFILE variable was still set to CICD, so that is interesting. I then went to the Environment Variables in Control Panel and deleted AWS_PROFILE. I then re-launched VSCode and the environment variable is no longer there, and the aws configure
command works as expected to update the profile.
So...long story short, I am not sure where that AWS_PROFILE environment variable came from, but deleting it as opposed to updating the value to something else, seems to have resolved my issue. Thanks for the suggestion!