Mount AWS Credentials on VSCode Devcontainers
A guide to install, configure and run selenium in Jupyter Notebook on WSL2 or Ubuntu
On this page
I’ve written in past about my preference of using VSCode’s devcontainers for developing Python applications.
While I work extensively with Python & AWS, one of the problems I’ve faced is that everytime I create a new devcontainer or rebuild one, I need to enter my AWS credentials again.
So I set about fixing this problem. I explored the idea of creating environmental variables and loading them directly into the container. I thought about copying the credentials file itself onto the container during build. But of of them weren’t clean ideas and had their own problems.
Turns out all it requires is a simple statement on devcontainer.json file.
How to mount AWS credentials on VSCode Devcontainers
Edit the .devcontainer/devcontainer.json file, add the following line after build instructions:
"mounts": [
"source=${localEnv:HOME}/.aws,target=/home/vscode/.aws,type=bind,consistency=cached"
],
This will only work if you’re using WSL2-backed devcontainers.
If you are using pure Windows based devcontainers, the above instructions may not work as I discovered after following this guide.
Need help?
Start a discussion on GitHub if you’ve got questions or improvements. Open discussions →