Aws-vault: Pass environment variables into docker

Created on 10 Jun 2019  路  4Comments  路  Source: 99designs/aws-vault

Hi,

I've just come across aws-vault and really liking it :-) I hope this is an easy one but I just can't quite seem to get aws-vault exec to pass in the temp env variables into docker like this example:

aws-vault exec myprofile -- docker run -it --env_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID --env AWS_DEFAULT_REGION=eu-west-1 --env TERRAFORM_ENV=dev --user "$(id -u):$(id -g)" -v "$PWD:/data" alpine

Basically I have a docker image with all my tools like terraform and I'd like to use aws-vault to pass in temp creds. Any ideas how I can get this going please?

Thanks

Dan

Most helpful comment

If you want to use env vars something like

aws-vault exec myprofile -- docker run -it -e AWS_REGION -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_SESSION_TOKEN -e AWS_SECURITY_TOKEN mesosphere/aws-cli s3 ls

All 4 comments

dont do that.
instead use aws-vault exec ROLE --server
so much simpler

Thanks for the quick reply :-) i did try that but I'm running in Windows WSL and that didn't seem to work. I found a work around though, by just putting my docker command in a bash script and calling the script via exec it worked.

Thanks

Dan

If you want to use env vars something like

aws-vault exec myprofile -- docker run -it -e AWS_REGION -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_SESSION_TOKEN -e AWS_SECURITY_TOKEN mesosphere/aws-cli s3 ls

The "-e" fixed it :-)

Thanks got you help, much appreciated!

Dan

Was this page helpful?
0 / 5 - 0 ratings