2014-08-26 23:50:29 +02:00
---
layout: "google"
page_title: "Provider: Google Cloud"
sidebar_current: "docs-google-index"
2014-10-22 05:21:56 +02:00
description: |-
The Google Cloud provider is used to interact with Google Cloud services. The provider needs to be configured with the proper credentials before it can be used.
2014-08-26 23:50:29 +02:00
---
# Google Cloud Provider
The Google Cloud provider is used to interact with
[Google Cloud services ](https://cloud.google.com/ ). The provider needs
to be configured with the proper credentials before it can be used.
Use the navigation to the left to read about the available resources.
## Example Usage
2016-04-10 23:34:15 +02:00
```js
// Configure the Google Cloud provider
2014-08-26 23:50:29 +02:00
provider "google" {
2015-11-12 23:13:07 +01:00
credentials = "${file("account.json")}"
project = "my-gce-project"
region = "us-central1"
2014-08-26 23:50:29 +02:00
}
2016-04-10 23:34:15 +02:00
// Create a new instance
2014-08-26 23:50:29 +02:00
resource "google_compute_instance" "default" {
2016-04-10 23:34:15 +02:00
// ...
2014-08-26 23:50:29 +02:00
}
```
## Configuration Reference
The following keys can be used to configure the provider.
2015-11-12 23:13:07 +01:00
* `credentials` - (Optional) Contents of the JSON file used to describe your
2015-07-27 21:35:52 +02:00
account credentials, downloaded from Google Cloud Console. More details on
2015-11-12 23:13:07 +01:00
retrieving this file are below. Credentials may be blank if you are running
Terraform from a GCE instance with a properly-configured [Compute Engine
2015-07-27 21:35:52 +02:00
Service Account](https://cloud.google.com/compute/docs/authentication). This
2016-04-11 01:31:40 +02:00
can also be specified using any of the following environment variables
(listed in order of precedence):
* `GOOGLE_CREDENTIALS`
* `GOOGLE_CLOUD_KEYFILE_JSON`
* `GCLOUD_KEYFILE_JSON`
* `project` - (Required) The ID of the project to apply any resources to. This
can be specified using any of the following environment variables (listed in
order of precedence):
* `GOOGLE_PROJECT`
* `GCLOUD_PROJECT`
* `CLOUDSDK_CORE_PROJECT`
2014-08-26 23:50:29 +02:00
2015-04-09 21:25:21 +02:00
* `region` - (Required) The region to operate under. This can also be specified
2016-04-11 01:31:40 +02:00
using any of the following environment variables (listed in order of
precedence):
2014-08-26 23:50:29 +02:00
2016-04-11 01:31:40 +02:00
* `GOOGLE_REGION`
* `GCLOUD_REGION`
* `CLOUDSDK_COMPUTE_REGION`
2016-04-08 17:01:53 +02:00
2015-11-12 23:13:07 +01:00
The following keys are supported for backwards compatibility, and may be
removed in a future version:
* `account_file` - __Deprecated: please use `credentials` instead.__
Path to or contents of the JSON file used to describe your
account credentials, downloaded from Google Cloud Console. More details on
retrieving this file are below. The `account file` can be "" if you are running
terraform from a GCE instance with a properly-configured [Compute Engine
Service Account](https://cloud.google.com/compute/docs/authentication). This
can also be specified with the `GOOGLE_ACCOUNT_FILE` shell environment
variable.
2014-10-14 09:00:44 +02:00
## Authentication JSON File
2014-08-26 23:50:29 +02:00
2014-10-14 09:00:44 +02:00
Authenticating with Google Cloud services requires a JSON
file which we call the _account file_ .
2014-08-26 23:50:29 +02:00
2014-10-14 09:00:44 +02:00
This file is downloaded directly from the
2014-08-26 23:50:29 +02:00
[Google Developers Console ](https://console.developers.google.com ). To make
2014-10-14 09:00:44 +02:00
the process more straightforwarded, it is documented here:
2014-08-26 23:50:29 +02:00
1. Log into the [Google Developers Console ](https://console.developers.google.com )
and select a project.
2016-06-20 23:54:54 +02:00
2. The API Manager view should be selected, click on "Credentials" on the left,
then "Create credentials", and finally "Service account key".
2014-08-26 23:50:29 +02:00
2016-06-20 23:54:54 +02:00
3. Select "Compute Engine default service account" in the "Service account"
dropdown, and select "JSON" as the key type.
2015-12-11 19:19:37 +01:00
4. Clicking "Create" will download your `credentials` .