EKS to GCP authentication via Workload Identity Federation
Project description
AWS-GCP Workload Identity Federation Auth
Minimal Python library for exchanging AWS EKS credentials for GCP credentials using Workload Identity Federation.
Installation
pip install aws-gcp-wif-auth
Usage
Auto-detect Environment (Recommended)
from aws_gcp_wif_auth import get_credentials
# Automatically uses WIF in EKS, ADC locally
credentials = get_credentials(
project_number="123456789",
pool_id="my-wif-pool",
provider_id="my-wif-provider",
service_account_email="my-sa@project.iam.gserviceaccount.com"
)
Explicit WIF
from aws_gcp_wif_auth import get_wif_credentials
credentials = get_wif_credentials(
project_number="123456789",
pool_id="my-wif-pool",
provider_id="my-wif-provider",
service_account_email="my-sa@project.iam.gserviceaccount.com",
aws_region="us-east-1"
)
Local Development (ADC)
from aws_gcp_wif_auth import get_adc_credentials
# Uses: gcloud auth application-default login
credentials = get_adc_credentials()
Authenticated Session
from aws_gcp_wif_auth import get_authed_session
# Get session with auto-refreshing credentials
session = get_authed_session(
project_number="123456789",
pool_id="my-wif-pool",
provider_id="my-wif-provider",
service_account_email="my-sa@project.iam.gserviceaccount.com"
)
# Make API requests
response = session.get("https://storage.googleapis.com/storage/v1/b")
Environment Detection
from aws_gcp_wif_auth import is_eks_environment
if is_eks_environment():
print("Running in EKS")
else:
print("Running locally")
Use with Google Cloud Libraries
from google.cloud import storage
from aws_gcp_wif_auth import get_credentials
credentials = get_credentials(
project_number="123456789",
pool_id="my-pool",
provider_id="my-provider",
service_account_email="sa@project.iam.gserviceaccount.com"
)
client = storage.Client(credentials=credentials)
buckets = list(client.list_buckets())
API Reference
get_credentials()
Auto-detect environment and return appropriate credentials.
Parameters:
project_number: GCP project number (required for WIF)pool_id: Workload Identity Pool ID (required for WIF)provider_id: Workload Identity Provider ID (required for WIF)service_account_email: GCP service account email (required for WIF)aws_region: AWS region (default: "us-east-1")scopes: OAuth scopes list (default: cloud-platform)use_adc: Force ADC instead of auto-detection (default: False)
get_wif_credentials()
Explicitly use Workload Identity Federation.
get_adc_credentials()
Explicitly use Application Default Credentials.
get_authed_session()
Get authenticated session with auto-refreshing credentials.
is_eks_environment()
Check if running in EKS environment.
Requirements
- Python 3.8+
- Running in AWS EKS with IAM role for service account (for WIF)
- GCP Workload Identity Pool configured for AWS (for WIF)
gcloud auth application-default login(for local ADC)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file eks_gcp_wif-0.1.1.tar.gz.
File metadata
- Download URL: eks_gcp_wif-0.1.1.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0eabf0d25b2622934c25606eb836da918a820d22a0a07261f56a097202245802
|
|
| MD5 |
4f22b9704ff6d0e6913b157d54ce41f3
|
|
| BLAKE2b-256 |
1b29b53159055d93b9c07bba00dc81c158a1c44821977d4fcea2aa135751e46e
|
File details
Details for the file eks_gcp_wif-0.1.1-py3-none-any.whl.
File metadata
- Download URL: eks_gcp_wif-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea7ad30d14af1b95d347a7afc90fb9c955f21f760b38b506fb1a9b4c204ab1f9
|
|
| MD5 |
f734a5b52a3b00b7aba798ea26f1e7e0
|
|
| BLAKE2b-256 |
d50e14aa75cd29ebcd8163a07ef952abb01804901131abf0c353f44c9f911b83
|