Get experience configuring a cloud environment
- You'll be pairing with a new person.
- You'll work in the Console.
- There are a lot of things that can go wrong. No stress, this is a learning experience.
- Take your time. It's preferred that you read outputs carefully, understand what's going on, and explore, rather than rushing through.
You'll be User A and B, to see things from both sides. When it says User A:
, use a browser logged in as that person. Ditto for B. May be easiest to switch between laptops.
- User A: Project setup
- Create a new Project.
- Project name: Something like
<user1>-<user2>-lab-12
- Organization:
afeld.me
- Location:
SIPA Advanced Computing
- Project name: Something like
- Change the Billing Account to that person's
Billing Account for Education
. - Grant User B BigQuery Admin at the Project level.
- Create a new Project.
- User B: BigQuery setup
- Switch to the Project created above.
- Create a table in BigQuery using sample data from Lab 8 or any other CSV.
- User A: Revoke access.
- User B: Refresh the page. You should get an access error.*
- Explain to each other what's been done so far.
*Not seeing access revoked immediately? This is because "The IAM API is eventually consistent."
We're going to deploy a Cloud Run Function that lists our BigQuery datasets.
- Create a Function using the "inline editor". Set the following, leave the other defaults.
- Service name:
lab-12
- Region:
us-central1
- Runtime:
Python 3.12
- Uncheck
Use Cloud IAM to authenticate incoming requests
. - Under
Container(s), Volumes, Networking, Security
->Security
, set service account to beDefault compute service account
.
- Service name:
- It will give you some
Hello World
code. ClickSave and redeploy
. - Deployment might take a few minutes. When it's done, try visiting the
URL
. - View the Logs.
- Refresh the live
URL
a bunch of times. - View the Metrics.
- Explain to each other what happened in this section.
Edit source
, and replace the code.main.py
- Function entry point:
list_datasets
requirements.txt
- Click
Save and redeploy
. - Deployment might take a minute. When it's done, try visiting the
URL
. It should show an empty list ([]
), as it doesn't have access to any BigQuery DataSets. - Grant BigQuery Data Viewer to the default compute service account (
<project-id>[email protected]
). - Refresh the Function URL. You should see your dataset listed.
- Explain to each other what happened in this section.
Unlike when we set up Streamlit to talk to BigQuery, no key was needed. Things within Google Cloud (Functions, in this case) run as a service account, and roles can be granted to that.
Delete the Project to avoid charges.
Nothing needs to be submitted for this Lab.