Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove use of old env vars #1143

Merged
merged 1 commit into from
Feb 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,17 @@ AWS Vault then exposes the temporary credentials to the sub-process in one of tw
```shell
$ aws-vault exec jonsmith -- env | grep AWS
AWS_VAULT=jonsmith
AWS_DEFAULT_REGION=us-east-1
AWS_REGION=us-east-1
AWS_ACCESS_KEY_ID=%%%
AWS_SECRET_ACCESS_KEY=%%%
AWS_SESSION_TOKEN=%%%
AWS_SECURITY_TOKEN=%%%
AWS_CREDENTIAL_EXPIRATION=2020-04-16T11:16:27Z
AWS_SESSION_EXPIRATION=2020-04-16T11:16:27Z
```
2. **Local metadata server** is started. This approach has the advantage that anything that uses Amazon's SDKs will automatically refresh credentials as needed, so session times can be as short as possible.
```shell
$ aws-vault exec --server jonsmith -- env | grep AWS
aws-vault: Starting an ECS credential server; your app\'s AWS sdk must support AWS_CONTAINER_CREDENTIALS_FULL_URI.
AWS_VAULT=jonsmith
AWS_DEFAULT_REGION=us-east-1
AWS_REGION=us-east-1
AWS_CONTAINER_CREDENTIALS_FULL_URI=%%%
AWS_CONTAINER_AUTHORIZATION_TOKEN=%%%
Expand Down
9 changes: 3 additions & 6 deletions cli/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ func updateEnvForAwsVault(env environ, profileName string, region string) enviro
env.Set("AWS_VAULT", profileName)

if region != "" {
log.Printf("Setting subprocess env: AWS_DEFAULT_REGION=%s, AWS_REGION=%s", region, region)
env.Set("AWS_DEFAULT_REGION", region)
log.Printf("Setting subprocess env: AWS_REGION=%s", region)
env.Set("AWS_REGION", region)
}

Expand Down Expand Up @@ -260,14 +259,12 @@ func execEnvironment(input ExecCommandInput, config *vault.Config, credsProvider
env.Set("AWS_SECRET_ACCESS_KEY", creds.SecretAccessKey)

if creds.SessionToken != "" {
log.Println("Setting subprocess env: AWS_SESSION_TOKEN, AWS_SECURITY_TOKEN")
log.Println("Setting subprocess env: AWS_SESSION_TOKEN")
env.Set("AWS_SESSION_TOKEN", creds.SessionToken)
env.Set("AWS_SECURITY_TOKEN", creds.SessionToken)
}
if creds.CanExpire {
log.Println("Setting subprocess env: AWS_CREDENTIAL_EXPIRATION, AWS_SESSION_EXPIRATION")
log.Println("Setting subprocess env: AWS_CREDENTIAL_EXPIRATION")
env.Set("AWS_CREDENTIAL_EXPIRATION", iso8601.Format(creds.Expires))
env.Set("AWS_SESSION_EXPIRATION", iso8601.Format(creds.Expires))
}

if !supportsExecSyscall() {
Expand Down