Quickstart

This quickstart shows you how to get started with Spanner migration tool using Google Cloud Shell, you will:

  • Create a cloud shell in Google Cloud console and install Spanner migration tool on it.
  • Launch the web UI of Spanner migration tool.
  • Connect to a source database using IP allowlisting.
Table of contents
  1. Installing Spanner migration tool on Cloud Shell
  2. Launching the web UI for Spanner migration tool
  3. Connecting to a source database

Installing Spanner migration tool on Cloud Shell

GCP Cloud shell is an online development and operations environment accessible anywhere with your browser. You can manage your resources with its online terminal preloaded with utilities such as the gcloud command-line tool, kubectl, and more. It is free to run, and can help you get started with Spanner migration tool quickly. Follow the instructions below to get started:

  1. Login to Google Cloud console and click on the Cloud shell button on the top right corner.

    cloud shell

  2. This is launch a terminal on Cloud console. Wait for the terminal to load.

    provision

  3. Once the terminal is loaded, run the following command:

     sudo apt-get install google-cloud-sdk-spanner-migration-tool
    
  4. Wait for the installation to complete. Spanner migration tool can be accessed using the following gCloud CLI command:

     gcloud alpha spanner migrate <COMMAND>
    

Launching the web UI for Spanner migration tool

  1. In order to launch the web UI for Spanner migration tool, run the following command:

     gcloud alpha spanner migrate web
    

    You will be asked to authorize running this command by providing your Google Cloud credentials. This allows Spanner migration tool to access resources on your behalf.

  2. This is launch the web UI in the Cloud shell instance, and show the following message in the terminal logs:

     Starting Spanner migration tool UI at: http://localhost:8080
    
  3. Without exiting the Cloud shell command, click on the “Web preview” icon on the top right corner of the cloud shell terminal, and then click on “Preview on port 8080”. This will open the Spanner migration tool UI in a new tab. The web address of the UI would something like https://8080-cs-<random-string>.cs-<region>-vwey.cloudshell.dev/.

    web preview

    Keep the Cloud console tab with the cloud shell running open in the background. Do not close this tab!

Connecting to a source database

This example describes connecting to a CloudSQL source database using IP allowlisting. The list of steps here are generic and can be followed for any source instance.

  1. In a new tab on the Cloud shell terminal, run the following command to fetch the IP address of the Cloud shell instance

     curl ifconfig.me
    
  2. Copy the returned IP address. Configure the IP address in the IP allowlisting section of the CloudSQL instance. Follow this guide to configure the IP allowlisting.

  3. Go back to the Spanner Migration Tool web UI launched earlier. Follow steps in the connect to source page to connect to your source database.

The same set of steps can be followed for any database which is accessible from Cloud shell. Please note this can not be used for databases within a VPC. If you want to connect to your database from within a VPC, we recommend following this guide. Note that this approach will not use Cloud shell to run Harboourbridge. Instead, follow the installation to install Spanner migration tool on the compute instance in your VPC.