Make sure you have downloaded go
(aka Golang) and
that it is on your ${PATH}
. After doing this, the
Makefile
will handle installing isolated dependencies
to run this sample.
To list clusters run
make list_clusters
This consistently fails (at least with a service account). If you'd like to run it with a user account instead of a service account, you first will need to mint an account with
gcloud login
using the gcloud
CLI tool. After doing this, you can
use that token by adding a flag to the make
command:
make list_clusters USE_APP_DEFAULT=True
To list tables in a cluster
make list_tables
This will need to be a cluster you have created (see "Creating a Cluster in the UI" below).
Finally, to create a table in an existing cluster, run
make list_tables_with_create
This will create a table named omg-finally
. If you'd like
to use a different table name, you can edit
tableName := "omg-finally"
in main_with_table_admin_and_create.go
. However, the script
is just for demonstration, so it shouldn't matter.
-
Visit Google Cloud Console
-
Either create a new project or visit an existing one
-
In the project, click "APIs & auth > APIs". The URI should be of the form
https://console.developers.google.com/project/{project-id}/apiui/apis/library
-
On this page, search for bigtable, and click both
Cloud Bigtable API
andCloud Bigtable Table Admin API
. -
For each API, click "Enable API" (if not already enabled)
-
Visit Google Cloud Console
-
Either create a new project or visit an existing one
-
In the project, click "APIs & auth > Credentials". The URI should be of the form
https://console.developers.google.com/project/{project-id}/apiui/credential
-
On this page, click "Create new Client ID", select "Service account" as your "Application type" and then download the JSON key provided. The downloaded file should resemble
keyfile.json.sample
.
After downloading, move this key to the local directory holding this code.
-
Visit Google Cloud Console
-
Either create a new project or visit an existing one
-
In the project, click "Storage > Cloud Bigtable". The URI should be of the form
https://console.developers.google.com/project/{project-id}/bigtable/clusters
-
On this page, click Create a cluster and take note of the "Cluster ID" and "Zone" you use when creating it.
You will need configuration for your own account and the code
pulls this from consts.go
.
-
Execute
cp consts.go.sample consts.go
-
Edit
consts.go
to match your own project- The
ProjectID
inconsts.go
to match the project ID in the project you used above. (Make sure you use the Project ID, not the Project Number) - You may name
ClusterID
andZone
anything you like, but these should come from a cluster that already exists (see above for how to create a cluster). - Change
KeyFile
to the path of the service account key file that you downloaded above.
- The
This was previously a gist and has been updated here.