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

Can I print my current profile? #818

Open
ronkorving opened this issue Jan 7, 2025 · 1 comment
Open

Can I print my current profile? #818

ronkorving opened this issue Jan 7, 2025 · 1 comment

Comments

@ronkorving
Copy link

ronkorving commented Jan 7, 2025

Hello there,

I'm currently in the process of making the switch from AWS Vault to Granted. I'm loving it so far!

In some of my shell scripts, I used to check for $AWS_VAULT, to ensure I was running the script through aws-vault exec (equivalent to assume --exec), so I could:

  1. Give human friendly errors early, rather than fail with some IAM error further down the script.
  2. Print the profile name before doing a dangerous action, so the user has a final chance to abort if they accidentally assumed the wrong role.

Is there a way to do this with Granted? I noticed there's no environment variable set during --exec that contains the profile name.

I guess I could parse it out of the Arn I see when I run aws sts get-caller-identity, but that doesn't describe the account as well as the SSO profile name. It was a nice convenience that AWS Vault used to provide. Is there a simple way to see the profile name, that I'm perhaps missing?

@dannysteenman
Copy link

Put this in your granted config:

DefaultExportAllEnvVar = true

it will export your aws credentials but also your aws profile and then you can use it however you want. Example your profile will be returned like:

AWS_PROFILE='active profile name'

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

2 participants