Direnv with multiple AWS Accounts
source link: https://zoph.me/posts/2017-01-10-direnv-with-aws/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Direnv with multiple AWS Accounts
If you are working closely with AWS, with multiple customers, multiple accounts, you will love this app : Direnv.
Direnv will let you switch environment variables depending on the current folder you are browsing. It will be especially useful when you are using multi-customers AWS CLI ACCESS_KEY
variables. Then you don’t need to run aws configure
each time you need to switch credentials.
When you leave the path, direnv will unload variables, then you avoid any mistakes.
First, install direnv (macOS in my case):
brew install direnv
Available, on Linux, Windows (Cigwin).
Second, you need to create a .envrc file:
In the target directory, for example, the name of your customer, organize one folder per customer. create the .envrc
file.
- AWS
-- Customer1
-- Customer2
-- Customer3
Fill it with your AWS_ACCESS_KEY
and SECRET_ACCESS_KEY
, and don’t forget to `chmod 600 at least.
cd /path/to/your/customer/folder
vim .envrc
export AWS_ACCESS_KEY_ID=YOU_AWSOME_ACCESS_ID
export AWS_SECRET_ACCESS_KEY=YOU_AWSOME_SECRET_ACCESS_KEY
Third, install the hook:
In your .bash_profile
file, add the following.
eval "$(direnv hook bash)"
Fourth, allow your directory:
cd /path/to/your/customer/folder
direnv allow .
for the child folders, just create .envrc
with:
source_env ..
and so on…
That’s all folks!
zoph.
192 Words
2017-01-10 20:31 +0000
Recommend
-
119
direnv -- unclutter your .profile direnv is an extension for your shell. It augments existing shells with a new feature that can load and unload environment variables depending on the current directory. Use cases...
-
28
README.rst emacs-direnv
-
42
Reading Time : 1 minuteSo if you have multiple git accounts, for example, one from the company and one is your personal, then how will you manage them on the […]
-
35
README.md direnv.vim - yup This plugin aim is to integrate Direnv and Vim. Because Vim ca...
-
13
Simplify Your AWS Billing for Multiple Accounts Using AWS Organizations📅 November 20, 2018 – Kyle GalbraithGeneral best practices say that we should isolate our development environments from our production environments. In ter...
-
24
Employee Experience
-
4
Working with multiple AWS accounts Using multiple AWS accounts under an Organization umbrella can be useful even at a personal level, for learning AWS features and self-training, it helps keep various projects partitioned. H...
-
11
Per-project Postgres with asdf and direnv Jul 23, 2021 • Ylan Segal •...
-
38
direnv on Windows Overview In JavaScript projects, I used to use dotenv so that I could put local environment variables in a .env file for local deve...
-
8
Asdf, Direnv Together Dec 1, 2022 • Ylan Segal •
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK