Created
August 19, 2024 16:30
-
-
Save Intelrunner/020dd81cd27a7389254d2512306355e0 to your computer and use it in GitHub Desktop.
To provide $USER view access to your BQ Admin Project ($PROJECT_ID) for reviewing Recommendation Engine reccs. View Only.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ensure these environment variables are set before running the script: | |
# export PROJECT_ID=<your-project-id> | |
# export USER_EMAIL=<user-email> | |
# export EXPIRATION_DATE=<expiration-date> # Format: YYYY-MM-DD | |
# Creates the custom role for BigQuery Reservations Viewer | |
gcloud iam roles create bigqueryReservationsViewer \ | |
--project="$PROJECT_ID" \ | |
--title="BigQuery Reservations Viewer" \ | |
--permissions="bigquery.reservations.list,bigquery.reservationAssignments.list,bigquery.capacityCommitments.list" \ | |
--stage="GA" | |
# Assigns the custom role to the specified user | |
gcloud projects add-iam-policy-binding "$PROJECT_ID" \ | |
--member="user:$USER_EMAIL" \ | |
--role="projects/$PROJECT_ID/roles/bigqueryReservationsViewer" \ | |
--condition="expression=request.time < timestamp('$EXPIRATION_DATET23:59:00Z'), title='Temporary Access', description='Access expires on $EXPIRATION_DATE'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment