How to use different env for different projects?
<p>I have two projects running on a server. I'm storing AWS_SECRET in env.</p>

<p>I set those env in my ~/.bash_profile. How do I make sure that one project gets the correct key? Can I set env only on project scope?</p>

<p>Thanks.</p>

<p>For the AWS CLI (<code>aws</code>) specifically, you can use "<a href="http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-multiple-profiles" rel="nofollow">profiles</a>", which you can select with the <code>--profile</code> argument. For example, in your <code>~/.aws/credentials</code>:</p>

<pre><code>[default]
aws_access_key_id=AKIAIOSFODNN7EXAMPLE
aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

[user2]
aws_access_key_id=AKIAI44QH8DHBEXAMPLE
aws_secret_access_key=je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY
</code></pre>

<p>Then use <code>aws --profile user2</code> to select the non-default profile as a one-off, or set the environment variable <code>AWS_DEFAULT_PROFILE=user2</code> in your shell to make it permanent. This might be easier than setting <code>AWS_SECRET</code> directly, because profile names are actually something you can remember :)</p>

<p>Besides credentials, profiles also let you switch other settings, like <code>region</code>.</p>

python unix