I know that Geodesic tends to lean more into the A...
# geodesic
m
I know that Geodesic tends to lean more into the AWS landscape, but would y’all consider offering some GCP PS1 prompt support for GCP accounts like:
Copy code
function role_name() {
    local role_name
    # Could be a primary or assumed role. If we have assumed a role, cut off the session name.
    local current_role=$(gcloud auth list --filter=status:ACTIVE --format="value(account)" 2>/dev/null | cut -d '@' -f1)
    if [[ -z $current_role ]]; then
        unset ASSUME_ROLE
        return 0
    fi
    export ASSUME_ROLE="$current_role"
}
role_name
Looking to incorporate Geodesic into our toolbox @Jeremy G (Cloud Posse)
j
I would be willing to include GCP support (we already ship with the GCP SDK pre-installed), but I am cautious because I do not use GCP and would want to make sure anything we do does not interfere with our AWS support and that GCP users are not bogged down by our AWS support. For example, we currently display the active AWS role in the prompt. It's a rather convoluted process that accounts for the possibility that you may have changed roles in a number of ways. To do that, we check the setting of
AWS_PROFILE
on every prompt, and make further checks when it changes. The check (when it changes) takes about a second to complete, so we do not want to run any of this if you are using GCP. We have other places where we just assume that
ASSUME_ROLE
is an AWS role, and I'm not sure what, if anything, needs to be adjusted there. We have legacy support to help you switch roles via an
assume-role
command, and we would want that to work for GCP (if changing roles is a normal part of your workday under GCP) or be disabled (if not needed). If you can help me out with use cases and testing, I can add this kind of support for GCP. Otherwise, I'm not sure exactly what to do or how to test it, even though your
role_name
prompt is a good start. To start, • How fast is
gcloud auth list
? Is it just processing a local file, or does it have to make a remote API call? • Where does
gcloud
store configuration data? (AWS stores it in
$HOME/.aws/
• How do you change roles? How often do you change roles?
@Michael In addition to ☝️ , on my computer,
gcloud auth list
takes 0.3s to run. That is too long to run on every prompt. So, like we do with AWS, we will want to have some quick way to cache the results and then check if the cache needs to be invalidated. (With AWS, we check to see if
AWS_PROFILE
has changed or if the modification timestamp on the AWS Credentials file has changed.) Can you help me out by figuring out what to use to invalidate the cache for
gcloud auth list
?
m
@Jeremy G (Cloud Posse) Those are great insights and I would love to help out. Thank you for the offer to assist with this feature too. From my understanding, GCP has a few different authentication flows, but when it comes to the credentials used by SDK tools like
gcloud
or
gsutil
, they are stored in a DB file located at
~/.config/gcloud/credentials.db
. Whenever someone runs
gcloud auth login
, it appends an entry to this file. I also found credentials inside of
access_tokens.db
, and was able to extrapolate them using sqlite. When I look in
~/.config/gcloud/configurations/config_default
: I see:
[core]
account = <mailto:michael@gmail.com|michael@gmail.com>
project = projectexample
Maybe this is another starting point, because most of the gcloud commands I ran hovered around 0.22s for completion as well