This document outlines the structure of the Beam project control of infrastructure permissions and provides instructions on how to manage a user or role's permissions.
To manage user roles, edit the users.yml file. Add or modify entries under the users section to reflect the desired roles for each user. Remember to follow the YAML format:
users: - username: <username> email: <email> member_type: <user|serviceAccount|group> permissions: - role: <role> title: <title> (optional) description: <description> (optional) expiry_date: <expiry_date> (optional, format: YYYY-MM-DD) - role: <role> (optional, for multiple roles)
Note:
role/ownerroles are handled separately, adding them to theusers.ymlfile will be ignored.
After modifying the users.yml file, open a Pull Request (PR) to the infra/iam directory. The changes will be reviewed and when approved, they will be merged into the main branch.
Once the PR is merged, the GitHub Actions workflow will automatically trigger and apply the changes to the IAM policies in the GCP project using Terraform.
This will update the IAM policies in the GCP project based on the changes made in the users.yml file.
users.yml file to associate users with their respective roles.The Beam project uses custom IAM roles to provide granular permissions for different levels of access to GCP resources. These roles follow a hierarchical structure where higher-level roles inherit permissions from lower-level roles.
The custom roles are structured in the following hierarchy:
beam_viewer < beam_writer < beam_infra_manager < beam_admin
beam_viewer permissions plus additional permissions for:beam_writer permissions plus:Custom roles are defined and managed through configuration files in the roles/ directory:
To modify custom roles:
roles_config.yaml file to update role definitionsgenerate_roles.py to regenerate the role YAML filesFor detailed information about custom roles management, see the roles directory README.
The migrate_roles.py script helps migrate existing GCP project IAM policies to the new custom roles structure. This is useful when transitioning from standard GCP roles to the custom Beam roles.
The script applies the following hierarchical migration rules:
beam_admin (includes all lower roles)beam_infra_manager (includes writer and viewer)beam_writer (includes viewer)beam_viewerPrerequisites:
pip install -r requirements.txt)Export and migrate IAM policies:
python migrate_roles.py <PROJECT_ID>
This generates two files:
<PROJECT_ID>.original-roles.yaml: Current IAM policy export<PROJECT_ID>.migrated-roles.yaml: Proposed migration to custom rolesAnalyze permission differences for a specific user:
python migrate_roles.py <PROJECT_ID> --difference <USER_EMAIL>
This generates:
<PROJECT_ID>.permission-differences.yaml: Detailed comparison of permissions before and after migrationExample workflow:
# Export current IAM policies and generate migration python migrate_roles.py apache-beam-testing # Check permission differences for a specific user python migrate_roles.py apache-beam-testing --difference user@example.com # Review the generated files before applying changes # Then apply via Terraform or manual IAM policy updates
The migration script helps ensure a smooth transition to the custom roles while maintaining appropriate access levels for all users.