Organization setup

If you set up Cloud Workstations for an organization, you can create a user workstation configuration with predownloaded and prebuilt code. This lets developers start working immediately without waiting for the build process to complete.

To create a user workstation configuration, you create an admin workstation, run the build process once, create a snapshot of the persistent disk, and then use that snapshot to create a new workstation configuration.

Create an admin workstation

Follow the steps in Launch the workstation to create and launch a single workstation. This serves as your base image.

Build the targets

On the admin workstation, download the source code and build the targets. You can either manually build the targets or automate the build using the provided script.

Manual build

Before running the build script, gain access to the code as described in Source code access. Then manually build the targets as described in Download, build, and run.

Automated build

Run the setup.sh script provided in the sdv-setup repository. This script automates cloning the Android source code and building the targets.

  1. Open a terminal on the workstation.
  2. Set your Git credentials:

    git config --global user.email "Your email address"
    git config --global user.name "Your name"
    
  3. Authenticate to partner-android.googlesource.com:

    1. Sign in to partner-android-review.googlesource.com with your Android partner account.
    2. Go to Settings, and then select Profile.
    3. Go to the HTTP Credentials section, and then click Obtain password.
    4. Follow the on-screen instructions, and then paste the authentication script into the workstation terminal. This creates the ~/.gitcookies file, which is required for access.
  4. Run the setup script by completing the following steps:

    1. Follow the authentication steps in Get access. This provides access to the setup script repository.
    2. Clone the sdv-setup repository, and then run the setup script:
    # Change directories to the home directory
    cd ~/
    
    # Clone the sdv-setup repository
    git clone https://sdv.googlesource.com/external/sdv-setup
    
    # Ensure the setup script is executable
    chmod +x sdv-setup/setup/setup.sh
    
    # Run the setup script
    ./sdv-setup/setup/setup.sh
    

The script takes several hours to complete. It clones the Android source code (approximately 30 minutes), and then builds the SDV IVI (2 hours), Media (30 minutes), and Core (10 minutes) targets.

(Optional) Set up an Android Studio for Platform project

Android Studio for Platform (ASfP) is an IDE preinstalled on the Cloud Workstation. If your developers all work on the same project, you can configure an ASfP project in the disk snapshot that everyone can use. Follow the instructions in Set up an AAOS SDV project to configure the project.

Create a disk snapshot

After the build completes, create a snapshot of the admin workstation's persistent disk.

  1. Remove your Git configuration and cookies to prevent sharing personal credentials with other users:

    rm ~/.gitcookies
    rm ~/.gitconfig
    
  2. Remove the sdv-setup repository to keep the base image clean:

    rm -rf ~/sdv-setup
    
  3. Find the admin workstation disk:

    1. Keep the admin workstation running.
    2. In the Google Cloud console, enter VM Instances in the search bar, and then click the top result.
    3. In the Filter bar, enter workstation_id:work-station. work-station should match the ID of your admin workstation. Press Enter to filter the results.
    4. Click the remaining entry.
    5. On the VM instance page, two different disks are listed in Storage. Click the disk that has a Size (GB) of 1000 and a Type of Regional SSD persistent disk. This disk contains the home directory that you want to snapshot.
  4. Stop the admin workstation:

    1. Keep the disk page open.
    2. In a new browser tab or window, open the Google Cloud console and navigate to the Cloud Workstations page. In the search bar, enter Cloud Workstations, and then click the top result.
    3. Click Workstations in the side panel.
    4. Click the admin workstation (with workstation ID work-station) in the table.
    5. Click Stop in the toolbar, and then wait for the workstation to stop.
  5. Create the disk snapshot:

    1. Switch back to the disk page, and then click Create snapshot in the toolbar.
    2. In the Name field, enter aaos-sdv-dev-snapshot.
    3. Leave the remaining fields at their default values.
    4. At the bottom of the page, click Create.

After a short time, the disk snapshot is created and ready for use.

Create the user workstation configuration

Create a new workstation configuration that uses the snapshot as a starting point:

  1. Follow the instructions in Set environment variables to launch Cloud Shell, and then set the environment variables.
  2. Apply the Terraform configuration to create the user workstation configuration:

    cd ~/dev/sdv-setup/tf/user_dev_env
    terraform init
    terraform apply -auto-approve
    

Create a user workstation

  1. In the Google Cloud console, navigate to the Cloud Workstations page. Enter Cloud Workstations into the search bar, and then click the top result.
  2. Click Workstations in the side panel.
  3. Click Create workstation in the toolbar.
  4. Enter an ID for the workstation, or leave the default.
  5. Enter a Display Name for the workstation. If you leave this blank, the ID is used.
  6. Select user-workstation-config as the Configuration.
  7. Click Create.
  8. In the workstation list, find the workstation you just created. Click Start under the Quick actions column.
  9. After the workstation starts, click Launch under the Quick actions column to start using the workstation.
  10. Open a file explorer to verify that the home directory contains the files from the disk snapshot.

Your organization can now create workstations for its developers. For more information about setting up access to Cloud Workstations, see Access control with IAM.