Skip to main content
GCP

Creating a GCP lab in Vocareum

K
Written by Kevin Wesley
Updated over a week ago

A GCP lab creates a GCP project for students to work on.

Assignment Setup:

From your course page select the 'Edit Labs' tab and then navigate to and select the 'New Lab' tab.

Enter the name of your lab and select 'Save and Continue'

Now you have created your first Part. From this page you can access the Part Settings by selecting Part 1. You can open Configure Workspace to begin populating your lab. And Student View to emulate the student experience during development.

Creating a GCP lab:

  1. From the Part settings toggle 'Enable Cloud'

  2. Select GCP as Cloud Vendor

    NOTE: Always select 'Save Part' before moving on to a different section of settings

  3. Set Total Spend Budget

  4. Enable Start Button in Interface

Customizing a GCP lab:

Custom Roles:

Custom roles can be created so that students have limited permissions when working on a project. Some examples of permissions are compute.instanceGroups.create, storage.buckets.get, cloudfunctions.functions.call. Custom role creation is an org-level operation, and custom role assignment is a part-level operation.

Adding a custom role:​

  1. Go to GCP Labs section in Edit Org page

  2. Click on the three dots to Add/Edit/Delete a custom role

  3. Add your Custom Role Name, Custom Role ID and Permissions.

  4. Once you have added your custom role, select Save and return to the Part and Resource settings of your GCP lab. Select your custom role from the dropdown and select 'Save Part'.

Organization Policies:

GCP's organization policies provide more fine-grained permission control for a GCP service. The difference between a GCP permission and a GCP org policy is that permissions define what actions are allowed and org policies define rules that those actions are limited to.

Creating an org policy:

  1. Go to GCP Labs section in Edit Org page

  2. Click on the three dots to Add/Edit/Delete an org policy

  3. An example of a constraint is gcp.resourceLocations

  4. The spec must be in JSON. An example of a spec is:

{ "rules": [ { "values": { "deniedValues": [ "us-west1" ] } } ] }

Lab Setup Script:

A custom script can be defined to set things up for a project. VOC_GCP_PROJECT_ID and VOC_GCP_EMAIL are supplied as environment variables. gcloud is installed on Vocareum's Visual Studio Code v1.13 image, so if the script requires the usage of gcloud, then the part's labtype must be Visual Studio Code.

  1. Go to the GCP Lab page in your Org settings. Navigate to 'GCP Lab Setup Script' and select 'Edit'.

  2. An example is enabling an API for that project.

This script is run on every start lab.

Did this answer your question?