The `google-cloud-iam` client library provides access to the Google Cloud IAM API, primarily focusing on Workload Identity Federation (WIF) resources like Workload Identity Pools and Providers. It allows programmatic management of these resources. The current version is 2.22.0, and it follows the rapid release cadence typical of Google Cloud client libraries, with updates often coinciding with API changes.
pip install google-cloud-iamVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the `IAMClient` and list Workload Identity Pools within a Google Cloud Organization. It requires `GCP_ORGANIZATION_ID` to be set as an environment variable and relies on Application Default Credentials for authentication. It highlights the library's focus on Workload Identity Federation.
For general IAM policy management, install `google-cloud-iam-admin` (`pip install google-cloud-iam-admin`) and use `from google.cloud import iam_admin_v1`. For resource-specific policies, use the respective service client library.
Ensure Application Default Credentials (ADC) are configured. Use `gcloud auth application-default login` for local development, or set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable to a service account key file path. For production, use managed identities like Service Accounts or Workload Identity.
Consult the API documentation for the exact resource name format required for each method. Use helper methods provided by the client (e.g., `client.common_location_path`) where available to construct correct paths.
Ensure all required environment variables for the quickstart or example are properly configured. Consult the example's source code or README for specific requirements.
Ensure the `google-cloud-iam` library is correctly installed using `pip install google-cloud-iam` within your active Python environment. If necessary, consider uninstalling potentially conflicting or deprecated `google-cloud` packages first (e.g., `pip uninstall google-cloud`).
Identify the exact permission required for the operation (which is often detailed in the full error message) and grant an appropriate IAM role containing that permission to the principal at the correct resource hierarchy level (e.g., project, folder, organization, or specific resource).
Review the Google Cloud IAM roles and permissions documentation for the specific resource type you are targeting, and select a predefined or custom role that is valid and appropriate for that resource. For example, a role meant for Compute Engine might not be applicable to a service account.
Collaborate with your IdP administrator to reduce the number of attributes or the size of attribute values being emitted by the IdP, ensuring only essential attributes are sent for federation with Google Cloud.
No dependency data recorded yet.