Create a Spanner free trial instance and sample application

This quickstart shows you how to use a Spanner free trial instance and sample application. For more information, see the Spanner free trial instances overview .

Get started with a free trial instance

A Spanner 90-day free trial instance is available to anyone with a Google Account who has Cloud Billing enabled in their project. You aren't charged unless you choose to upgrade your free trial instance to a paid instance.

You can create a free trial instance using the Google Cloud console or Google Cloud CLI.

Before you begin

Google Cloud console

  1. In the Google Cloud console, go to the Spannerpage.

    Go to Spanner

  2. Select or create a Google Cloud project if you haven't done so already.

  3. If Cloud Billing is already enabled for your project, proceed to Create free trial instance in the next section.

    If Cloud Billing is not enabled for your project, link an existing Cloud Billing account or create a new Cloud Billing account. Google uses this payment information to verify your identity. We don't charge your Spanner instance unless you explicitly upgrade your Cloud Billing account to a paid account , and you upgrade your Spanner free trial instance to a paid instance .

    a. Click Go to billing.

    Screenshot of the Enable billing to keep using Spanner dialog, highlighting the Go to billing button.

    b. Then, click Link a billing account.

    Screenshot of a page showing This project has no billing account, highlighting Link a billing account button.

    c. Follow the steps to Create billing account, and then link it to your project.

    d. After you enable Cloud Billing for your project, go to the Spannerpage.

    Go to Spanner

    e. Click Create free instance, and proceed to Create free trial instance in the next section.

  4. Optional: If you have created a Spanner instance in the project before, you see the following Spanner Instancespage.

    Click Create free instance.

    Screenshot of the Spanner instances page, highlighting Create free instance.

gcloud

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. Install the Google Cloud CLI.

  3. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity .

  4. To initialize the gcloud CLI, run the following command:

    gcloud  
    init
  5. Create or select a Google Cloud project .

    • Create a Google Cloud project:

      gcloud projects create PROJECT_ID 
      

      Replace PROJECT_ID with a name for the Google Cloud project you are creating.

    • Select the Google Cloud project that you created:

      gcloud config set project PROJECT_ID 
      

      Replace PROJECT_ID with your Google Cloud project name.

  6. Verify that billing is enabled for your Google Cloud project .

  7. If you're using a local shell, then create local authentication credentials for your user account:

    gcloud  
    auth  
    application-default  
    login

    You don't need to do this if you're using Cloud Shell.

    If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity .

  8. Install the Google Cloud CLI.

  9. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity .

  10. To initialize the gcloud CLI, run the following command:

    gcloud  
    init
  11. Create or select a Google Cloud project .

    • Create a Google Cloud project:

      gcloud projects create PROJECT_ID 
      

      Replace PROJECT_ID with a name for the Google Cloud project you are creating.

    • Select the Google Cloud project that you created:

      gcloud config set project PROJECT_ID 
      

      Replace PROJECT_ID with your Google Cloud project name.

  12. Verify that billing is enabled for your Google Cloud project .

  13. If you're using a local shell, then create local authentication credentials for your user account:

    gcloud  
    auth  
    application-default  
    login

    You don't need to do this if you're using Cloud Shell.

    If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity .

Create a free trial instance

Google Cloud console

The following steps explain how to create a free trial instance using the Google Cloud console.

On the Create your free trial instancepage, do the following:

  1. Enter the Instance nameto display in the Google Cloud console. The instance must be unique within your Google Cloud project.
  2. Enter the Instance IDto permanantly identify your instance. The instance ID must also be unique within your Google Cloud project. You can't change the instance ID later.
  3. Select a configuration location from the Regiondrop-down menu.

    Your instance configuration determines the geographic location where your instance is stored and replicated. You can create a free trial instance in any of the Spanner regional instance configurations . For a full list of all available instance configurations, see Regional, dual-region, and multi-region configurations .

  4. Click Create free instance.

    After you create your free trial instance, Spanner creates a sample database for you to explore and familiarize yourself with Spanner features. For more information, see Free trial instances overview .

gcloud

To create a free trial instance, use the gcloud spanner instances create command.

  gcloud 
  
 spanner 
  
 instances 
  
 create 
  
  INSTANCE_ID 
 
  
\  
 -- 
 instance 
 - 
 type 
 = 
 free 
 - 
 instance 
  
 -- 
 config 
 = 
  INSTANCE_CONFIG 
 
  
\  
 -- 
 description 
 = 
  INSTANCE_DESCRIPTION 
 
 

Replace the following:

  • INSTANCE_ID : a permanent identifier that is unique within your Google Cloud project. You can't change the instance ID later.
  • INSTANCE_CONFIG : a permanent identifier of your instance configuration, which defines the geographic location of the instance. You can create a free trial instance in any of the Spanner regional instance configurations :

  • INSTANCE_DESCRIPTION : the name to display for the instance in the Google Cloud console. The instance name must be unique within your Google Cloud project.

For example, to create a free trial instance named trial-instance with the display name Trial Instance using the regional instance configuration regional-us-east5 , run the following:

  gcloud 
  
 spanner 
  
 instances 
  
 create 
  
 trial 
 - 
 instance 
  
 -- 
 config 
 = 
 regional 
 - 
 us 
 - 
 east5 
  
\  
 -- 
 instance 
 - 
 type 
 = 
 free 
 - 
 instance 
  
 -- 
 description 
 = 
 "Trial Instance" 
 

After you create your free trial instance, you are prompted to continue learning and exploring Spanner by launching a step-by-step tutorial that teaches you how to create a database using a sample application. For more information, see Get started with a sample application .

Get started with a sample database

After you create your free trial instance using the Google Cloud console, Spanner creates a sample database for you to explore and familiarize yourself with Spanner features.

You can access the sample database by using the Google Cloud console.

Google Cloud console

  1. In the Google Cloud console, go to the Spanner Instancespage.

    Go to the Instances page

  2. Click the name of the free trial instance.

  3. Click the name of the sample database.

You can view the tables and data in the sample database. You can also access and view saved queries on the Spanner Studio page. The saved queries showcase different Spanner features and capabilities.

Get started with a sample application

Spanner also offers an open source sample application to help you get started with the Spanner free trial instance. The sample application consists of a backend gRPC service backed by a Spanner database and a workload generator that drives traffic to the service.

You can access the sample application by using the Google Cloud CLI.

gcloud

  1. Complete the steps described in the gcloud set up , which covers creating and setting a default Google Cloud project, enabling the Cloud Spanner API, and setting up OAuth 2.0 to get authentication credentials to use the Cloud Spanner API.

    Run the gcloud auth application-default login command to set up your local development environment with authentication credentials.

  2. Run the gcloud spanner samples run command to download the sample application and start the backend gRPC service and workload generator for the given sample application:

     gcloud spanner samples run APPNAME --instance-id INSTANCE_ID 
     
    
  3. For more information and a list of other available commands for the sample application, see the gcloud CLI documentation .

Import your own data

You can import your own data into a Spanner database by using a CSV file, a MySQL dump file, or a PostgreSQL dump file. You can upload a local file using Cloud Storage or from a Cloud Storage bucket directly. Uploading a local file using Cloud Storage might incur charges.

If you choose to use a CSV file, you also need to upload a separate JSON file that contains the database schema.

Google Cloud console

  1. In the Google Cloud console, go to the Spanner Instancespage.

    Go to Spanner instances

  2. Select the instance to create the database in.

  3. Click Import my own data.

  4. Enter the following values:

    • Select the File type.

    • Upload the file from your computer or select a Cloud Storage bucket path to the file.

    • (Optional) If you choose to use a CSV file, you also need to upload a separate JSON file that contains the database schema. The JSON file must use the following structure to define the schema:

       { 
        
       "name" 
       : 
        
       " COLUMN_NAME 
      " 
       , 
        
       "type" 
       : 
        
       " TYPE 
      " 
       , 
        
       "notNull" 
       : 
        
        NOT_NULL_VALUE 
       
       , 
        
       "primaryKeyOrder" 
       : 
        
        PRIMARY_KEY_ORDER 
       
       } 
      

      Replace the following:

      • COLUMN_NAME : the name of the column in the table.

      • TYPE : the data type of the column.

      • (Optional) NOT_NULL_VALUE : whether the column can store null values or not. Valid inputs are true or false . Defaults to false .

      • (Optional): PRIMARY_KEY_ORDER : determines the primary key order. Set the value is set to 0 for a non-primary key column. Set the value to an integer, for example, 1 for a primary key column. Lower numbered columns appear earlier in a compound primary key.

      The CSV file expects a comma for the field delimiter and a new line for the line delimiter by default. For more information on using custom delimiters, see the gcloud alpha spanner databases import reference.

    • Select a new or existing database as the destination.

  5. Click Import.

  6. Spanner opens the Cloud Shell and populates a command that installs the Spanner migration tool and runs the gcloud alpha spanner databases import command. Press the ENTER key to import data into your database.x

Upgrade a free trial instance

The following steps explain how to upgrade your free trial instance.

Google Cloud console

  1. In the Google Cloud console, go to the Spanner Instancespage.

    Go to the Instances page

  2. Click the name of the free trial instance.

  3. On the Instance Overviewpage, click Edit instanceor Edit to upgrade.

Screenshot of the Instance Overview page and edit to upgrade button

  1. In the Update instance namefield, enter a more applicable name for your paid instance if applicable.

  2. Select your Upgrade option. You can select one of the following:

    • Upgrade now
    • Automatically upgrade to the full version of the Enterprise edition after my trial expires
    • Remind me later

    The Summarysection provides a description of compute and storage costs for the upgraded paid instance that you selected.

  3. Click Saveto upgrade your free trial instance.

gcloud

To upgrade your free trial instance to a paid Enterprise edition instance with the same instance configuration, run the following gcloud spanner instances update command:

  gcloud 
  
 spanner 
  
 instances 
  
 update 
  
  INSTANCE_ID 
 
  
 -- 
 instance 
 - 
 type 
 = 
 provisioned 
 

Delete the instance

Google Cloud console

  1. Go to the Spanner Instancespage in the Google Cloud console.

    Go to the Instances page

  2. Click the name of the instance that you want to delete.

  3. On the Instance Overviewpage, click Delete instance.

  4. Follow the instructions to confirm that you want to delete the instance.

  5. Click Delete.

gcloud

To delete your free trial instance, use the following gcloud spanner instances delete command:

 gcloud spanner instances delete INSTANCE_ID 
 

What's next

Create a Mobile Website
View Site in Mobile | Classic
Share by: