rkoval / alfred-aws-console-services-workflow

A powerful workflow for quickly opening up AWS Console Services in your browser or searching for entities within them.
MIT License
312 stars 54 forks source link

How to set the profile #24

Closed dinnouti closed 3 years ago

dinnouti commented 3 years ago

Hi Ryan, great Alfred workflow. I work with several profiles and would be helpful to be able to change profiles. Is it possible to set the AWS profile using the Alfred workflow environment variables?

rkoval commented 3 years ago

hey @dinnouti - yes, you should be able to set the AWS_PROFILE environment variable in the workflow config page to target any other named profiles you have in your ~/.aws/config file.

as a sidenote: this workflow uses the AWS SDK for Go under-the-hood, so any env vars you set in that Alfred config page should be respected by the underlying library. see this page for more details (the README for this workflow also has references to these links for future reference). you can search the page for AWS_PROFILE to see examples for you specific usage here

please let me know if that answers your question or this isn't working for some reason

dinnouti commented 3 years ago

I work with several profiles and this will solution will help. Thank you!

rkoval commented 3 years ago

for what it's worth, this workflow doesn't yet support switching profiles/env vars on the fly, but can potentially just install multiple versions of it with different prefixes that have different env vars configured (though i have not tested this; you may run into issues with caching). i think that can get you a more seamless way to query different profiles at any given time, if you have the need to actively switch between the profiles (though there will be overhead of maintaining/updating all of them when new releases are pushed)

dinnouti commented 3 years ago

If the Go script is allowed to read the ~/aws/ files, that would be a easy approach to pick a different profile.

hoium commented 3 years ago

I just tested installing multiple versions and configuring the prefixes for different profiles; and it's working great.

Only issue I ran into alfred_workflow_bundleid is copied not over when duplicating; since you can't have two Bundle Ids named the same. After you duplicate the Workflow; double click on it to Edit Details, and set the Bundle Id.

Example Bundle Id: com.ryankoval.aws$Profile-Name