Skip to content

GCP PS1 Prompt Support for GCP Accounts and Projects #926

@RoseSecurity

Description

@RoseSecurity

Feature Request

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:

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

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 = [[email protected]](mailto:[email protected])
project = projectexample

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions