Google Compute Engine (GCE) is the Infrastructure as a Service (IaaS) component of Google Cloud Platform which is built on the global infrastructure that runs Google’s search engine, Gmail, YouTube, and other services. GCE enables users to launch virtual machines on demand. Juju can use GCE by communicating with it via API calls.

Prerequisites and installation

  • A Google account is required. See http://google.com .

  • A GCE account is required. See https://cloud.google.com/compute/ .

  • The Juju client (the host running the below commands) will need the ability to contact the GCE infrastructure on TCP ports 22 and 17070.

Proceed to install the software.

sudo apt-get update
sudo apt-get install -y juju-core

Create a GCE project

A separate GCE project is needed.

According to Google: "A project is a container for all GCE resources. Each project is a compartmentalized world. They do not share resources, can have different owners/users, and are billed separately.".

Create a project now. If you have already used GCE your existing projects will be listed in the pull-down menu with one being selected as your currently active project (here 'My First Project'). The dialog is found near the top-right corner:


Enter a project name (here 'My Juju-GCE Project'):


The project id (used later) will be generated automatically. Click 'Edit' to change it.

Google Compute Engine API

The Google Compute Engine API needs to be enabled for your new project in order for Juju to communicate with it. This is done automatically if a "billing method" has been set up. By following the below steps you will discover whether you need to set up billing or not.

At the top-left of the web UI there is an icon representing 'Product & services'. It is denoted by this icon, next to the 'Google Cloud Platform' title:

Product & services icon

Click through and select 'API Manager'. By default you will be on the 'Overview' screen, it will show this across the top:

API Manager screen

Click '+Enable API' and then from the list of available APIs you are shown, select 'Compute Engine API':

Compute Engine API

On the top of the page that opens, click 'Enable'. If the API is already enabled, this will display 'Disable'. Clicking it may prompt you to set up a billing method (if not already done).

GCE project credentials file

A collection of credentials-related material will be required for Juju to communicate with your GCE project. This is obtained by downloading a file from the UI.

Return to the 'API Manager' and choose the 'Credentials' screen. By default you will be within the 'Credentials' tab. Click the 'Create credentials' button and choose 'Service account key' from the 3 options available:

Create credentials dialog #1

In the ensuing dialog, select 'Compute Engine default service account' and 'JSON' key type:

Create credentials dialog #2

Once the 'Create' button is pressed you will be prompted to download a file. This is the file we're after. Store it safely as this file cannot be regenerated (although a new one can easily be created).

Place this file where the Juju client can find it. This may or may not be on the computer you downloaded the file to. We recommend the ~/.juju directory. For the current example, the file is called My-Juju-GCE-Project-f33a6cdbd8e3.json (based on our project name of 'Juju-GCE'. Let it be put here:


Warning: Due to LP #1533790 make a copy of the original file and put it in another location. Edit the original file by removing the sections containing these keywords: 'project-id', 'auth-uri', 'token_uri', 'auth_provider_x509_cert_url', and 'client-x509-cert-url'.

Configuring for GCE

If this is a new Juju install then you do not yet have a ~/.juju/environments.yaml file. Create one with

juju generate-config

If it does exist (but it was created with an older version of Juju), first move it out of the way (back it up) and then generate a new one. Alternatively, you can output a generic file to screen (STDOUT) and paste the GCE parts into your existing file:

juju generate-config --show

The file will contain a section for the GCE provider.

Configure and bootstrap

Values will need to be found for the following parameters:

  • auth-file
  • project-id


The value of auth-file is the path to the credentials file downloaded previously.


The value of project-id is based on the name of the project you created earlier. Take it from the downloaded file.

According to all the above, the GCE section of file environments.yaml for this example would look like this (comments removed for simplicity):

      type: gce
      auth-file: /home/ubuntu/.juju/Juju-GCE-f33a6cdbd8e3.json
      project-id: juju-gce-1204

Finally, switch to the GCE provider and bootstrap:

juju switch gce
juju bootstrap --debug

A successful bootstrap will result in the controller being visible in the GCE console:

bootstrap machine 0 in GCE portal

Additional notes

See General configuration options for additional and advanced customization of your environment.

Using the gcloud compute CLI tool

The gcloud compute tool is a CLI utility for querying and configuring a CGE account/project. It is not required nor sufficient for setting up Juju for GCE. It does, however, have many uses. In particular, it can be used to change defaults such as compute zone and region. The Google Cloud SDK gets installed along with the tool.


curl https://sdk.cloud.google.com | bash
exec -l $SHELL
gcloud init

For further information on the gcloud tool: