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

AWS-Vault clear does not clear AWS_VAULT environmental variable #905

Closed
hunttom opened this issue Mar 30, 2022 · 4 comments
Closed

AWS-Vault clear does not clear AWS_VAULT environmental variable #905

hunttom opened this issue Mar 30, 2022 · 4 comments

Comments

@hunttom
Copy link

hunttom commented Mar 30, 2022

  • [ x] I am using the latest release of AWS Vault
  • [N] I have provided my .aws/config (redacted if necessary)
  • [N] I have provided the debug output using aws-vault --debug (redacted if necessary)

Running aws-vault clear does not clear out the AWS_VAULT environmental variable.

Steps to reproduce:

  1. Run aws-vault exec <PROFILE> --ecs-server
  2. Run echo $AWS_VAULT to see <PROFILE>
  3. Run aws-vault clear
  4. Run echo $AWS_VAULT (<PROFILE> is still set)
  5. Validate profile is still set by running aws-vault exec <PROFILE> --ecs-server
  6. Still get warning: aws-vault: error: exec: aws-vault sessions should be nested with care, unset AWS_VAULT to force

Recommend adding to the clear function:

	if os.Getenv("AWS_VAULT") != "" {
		err = os.Unsetenv("AWS_VAULT")
		if err != nil {
			return fmt.Errorf("Unable to unset environmental variable: 'AWS_VAULT'")
		}
	}
@stale
Copy link

stale bot commented Nov 2, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 2, 2022
@ivankovnatsky
Copy link

I used this piece of nonsense to workaround it:

set | rg AWS_ | rg -v AWS_VAULT_BACKEND | rg -v ZLE | sed 's/=.*//' | while read i; do unset $i; done

@stale stale bot removed the stale label Feb 11, 2023
@acolominas
Copy link

acolominas commented Feb 17, 2023

Same error for me.
Everytime I need to switch between profiles I need to execute "unset AWS_VAULT" after command "aws-vault clear"

@mtibben
Copy link
Member

mtibben commented Feb 17, 2023

When a command isn't specified, aws-vault creates a "subshell" by running $SHELL. The latest pre-release makes this clearer. You don't need to clear env vars. Instead, exit out of the subshell.

Fixed in #1136

@mtibben mtibben closed this as completed Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants