Home

Awesome

Google Spanner Chef Cookbook

This cookbook provides the built-in types and services for Chef to manage Google Cloud Spanner resources, as native Chef types.

Requirements

Platforms

Supported Operating Systems

This cookbook was tested on the following operating systems:

Example

gspanner_instance 'my-spanner' do
  action :create
  display_name 'My Spanner Instance'
  node_count 2
  labels [
    {
      'cost-center' => 'ti-1700004'
    }
  ]
  config 'regional-us-central1'
  project ENV['PROJECT']
  credential 'mycred'
end

gspanner_database 'webstore' do
  action :create
  instance 'my-spanner'
  extra_statements [
    'CREATE TABLE customers (
       customer_id INT64 NOT NULL,
       last_name STRING(MAX)
     ) PRIMARY KEY (customer_id)'
  ]
  project ENV['PROJECT']
  credential 'mycred'
end

Credentials

All Google Cloud Platform cookbooks use an unified authentication mechanism, provided by the google-gauth cookbook. Don't worry, it is automatically installed when you install this module.

Example

gauth_credential 'mycred' do
  action :serviceaccount
  path ENV['CRED_PATH'] # e.g. '/path/to/my_account.json'
  scopes [
    'https://www.googleapis.com/auth/spanner.admin'
  ]
end

For complete details of the authentication cookbook, visit the google-gauth cookbook documentation.

Resources

gspanner_instance

An isolated set of Cloud Spanner resources on which databases can be hosted.

Example

gspanner_instance 'my-spanner' do
  action :create
  display_name 'My Spanner Instance'
  node_count 2
  labels({
    'cost-center' => 'ti-1700004'
  })
  config 'regional-us-central1'
  project ENV['PROJECT']
  credential 'mycred'
end

Reference

gspanner_instance 'id-for-resource' do
  config       reference to gspanner_instance_config
  display_name string
  labels       namevalues
  name         string
  node_count   integer
  project      string
  credential   reference to gauth_credential
end

Actions

Properties

Label

Set the i_label property when attempting to set primary key of this object. The primary key will always be referred to by the initials of the resource followed by "_label"

gspanner_database

A Cloud Spanner Database which is hosted on a Spanner instance.

Example

gspanner_instance 'my-spanner' do
  action :create
  display_name 'My Spanner Instance'
  node_count 2
  labels({
      'cost-center' => 'ti-1700004'
  })
  config 'regional-us-central1'
  project ENV['PROJECT']
  credential 'mycred'
end

gspanner_database 'webstore' do
  action :create
  instance 'my-spanner'
  extra_statements [
    'CREATE TABLE customers (
       customer_id INT64 NOT NULL,
       last_name STRING(MAX)
     ) PRIMARY KEY (customer_id)'
  ]
  project ENV['PROJECT']
  credential 'mycred'
end

Reference

gspanner_database 'id-for-resource' do
  extra_statements [
    string,
    ...
  ]
  instance         reference to gspanner_instance
  name             string
  project          string
  credential       reference to gauth_credential
end

Actions

Properties

Label

Set the d_label property when attempting to set primary key of this object. The primary key will always be referred to by the initials of the resource followed by "_label"