Skip to main content

GCP Impersonation wrapper

The gcp-impersonation-wrapper is a small util used to impersonate service accounts using service account. We pass the main credentials, list service accounts we can impersonate and then actually impersonate like so:

#!/usr/bin/env python3
from src.service_account import ServiceAccount


if __name__ == "__main__":
    # Insert credentials here
    credentials = None

    service_account = ServiceAccount(
        project_id="your-project-id",
        impersonator_credentials=credentials
    )

    # Can be used in a with statement
    with service_account.impersonate(
        service_account_email="your-service-account-email",
        target_scopes=["https://www.googleapis.com/auth/cloud-platform"],
        service="iam",
        version="v1"
    ) as impersonated_service_account:
        # do something with the impersonated service account
        service_accounts_the_impersonated_sacc_can_see = impersonated_service_account.service.projects(
        ).serviceAccounts().list().execute()
        print(service_accounts_the_impersonated_sacc_can_see)

    # Or as a variable
    impersonated_service_account = service_account.impersonate(
        service_account_email="your-service-account-email",
        target_scopes=["https://www.googleapis.com/auth/cloud-platform"],
        service="iam",
        version="v1"
    )
    service_accounts_the_impersonated_sacc_can_see = impersonated_service_account.service.projects(
    ).serviceAccounts().list().execute()

To list the impersonatable service accounts we do:

#!/usr/bin/env python3
from src.service_account import ServiceAccount


if __name__ == "__main__":
    # Insert credentials here
    credentials = None

    service_account = ServiceAccount(
        project_id="your-project-id",
        impersonator_credentials=credentials
    )

    # This returns a list of email like ["john@doe.com", "jane@doe.com", ....]
    service_account_emails_we_can_impersonate = service_account.list_all_impersonatable_service_account_emails() 

Metadata

Release files for gcp-impersonation-wrapper 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gcp-impersonation-wrapper 0.0.6
File Size Uploaded Provenance Actions
gcp-impersonation-wrapper-0.0.6.tar.gz 2.8 kB Without provenance Details for gcp-impersonation-wrapper-0.0.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gcp-impersonation-wrapper 0.0.6
File Interpreter ABI Platform Actions
gcp_impersonation_wrapper-0.0.6-py3-none-any.whl Python 3 none any Details for gcp_impersonation_wrapper-0.0.6-py3-none-any.whl

Total release size: 6.5 kB

Release files / gcp-impersonation-wrapper-0.0.6.tar.gz

Download URL gcp-impersonation-wrapper-0.0.6.tar.gz
Size 2.8 kB
Tags Source
SHA-256 checksum
How to use checksums
659702e2970c5aa24b97e8624d7047a7755582292667df1184727cea525652a3
BLAKE2b-256 checksum
How to use checksums
f7f55cd4fae8c6434c1259a2d2267f4239ae911a2ada709cc09271b2238ff785
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.15

Release files / gcp_impersonation_wrapper-0.0.6-py3-none-any.whl

Download URL gcp_impersonation_wrapper-0.0.6-py3-none-any.whl
Size 3.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
52a7d34dbd6a910592632aa230ce50e46eb7c563922984c5aebb61e2bcb40c7a
BLAKE2b-256 checksum
How to use checksums
b027591fd30473d35c6bfc8af8d1ff24f718cc3cfc2b23fa4a347119cf42e448
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.15

Security for gcp-impersonation-wrapper 0.0.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page