Do you actively use WSL/WSL2 and AWS in your day-to-day tasks?
Do you have different AWS profiles in Powershell and WSL and they’re out of sync? It’s annoying, isn’t it? Just keep reading 😉
TL;DR #
- Configure AWS profiles in Windows (e.g. by calling
aws configure
in PowerShell) - Execute in WSL:
# backup AWS profiles in WSL
mv ~/.aws ~/.aws_backup
# replace 'username' with your Windows username
ln -s /mnt/c/Users/username/.aws ~/.aws
# if everything is okay, remove the backup
rm ~/.aws_backup -r
It will create a symbolic link, so the .aws
directories’ content in Windows and WSL will be the same.
A bit of details #
Symbolic links allow us to create useful shortcuts or reuse the same files in different contexts without creating tons of duplicates.
When you create a symbolic link ~/.aws
to your Windows %homepath%/.aws
directory, the ~/.aws
in WSL will be just a pointer to the directory in Windows. So any changes you make in Windows or WSL will be applied to the same directory and files.
Also useful #
You can do the same for ~/.kube
, so your kubectl
configuration will be synchronized too:
# replace 'username' with your Windows username
ln -s /mnt/c/Users/username/.kube ~/.kube
What about Azure? If you execute ls -la
in ~
in WSL2 you’ll see that ~/.azure
is already configured this way. Microsoft cares! 😊