github.com/nathanielks/terraform@v0.6.1-0.20170509030759-13e1a62319dc/website/source/docs/providers/google/index.html.markdown (about)

     1  ---
     2  layout: "google"
     3  page_title: "Provider: Google Cloud"
     4  sidebar_current: "docs-google-index"
     5  description: |-
     6    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.
     7  ---
     8  
     9  # Google Cloud Provider
    10  
    11  The Google Cloud provider is used to interact with
    12  [Google Cloud services](https://cloud.google.com/). The provider needs
    13  to be configured with the proper credentials before it can be used.
    14  
    15  Use the navigation to the left to read about the available resources.
    16  
    17  ## Example Usage
    18  
    19  ```hcl
    20  // Configure the Google Cloud provider
    21  provider "google" {
    22    credentials = "${file("account.json")}"
    23    project     = "my-gce-project"
    24    region      = "us-central1"
    25  }
    26  
    27  // Create a new instance
    28  resource "google_compute_instance" "default" {
    29    # ...
    30  }
    31  ```
    32  
    33  ## Configuration Reference
    34  
    35  The following keys can be used to configure the provider.
    36  
    37  * `credentials` - (Optional) Contents of the JSON file used to describe your
    38    account credentials, downloaded from Google Cloud Console. More details on
    39    retrieving this file are below. Credentials may be blank if you are running
    40    Terraform from a GCE instance with a properly-configured [Compute Engine
    41    Service Account](https://cloud.google.com/compute/docs/authentication). This
    42    can also be specified using any of the following environment variables
    43    (listed in order of precedence):
    44  
    45      * `GOOGLE_CREDENTIALS`
    46      * `GOOGLE_CLOUD_KEYFILE_JSON`
    47      * `GCLOUD_KEYFILE_JSON`
    48  
    49      The [`GOOGLE_APPLICATION_CREDENTIALS`](https://developers.google.com/identity/protocols/application-default-credentials#howtheywork)
    50      environment variable can also contain the path of a file to obtain credentials
    51      from.
    52  
    53  * `project` - (Required) The ID of the project to apply any resources to.  This
    54    can be specified using any of the following environment variables (listed in
    55    order of precedence):
    56  
    57      * `GOOGLE_PROJECT`
    58      * `GCLOUD_PROJECT`
    59      * `CLOUDSDK_CORE_PROJECT`
    60  
    61  * `region` - (Required) The region to operate under. This can also be specified
    62    using any of the following environment variables (listed in order of
    63    precedence):
    64  
    65      * `GOOGLE_REGION`
    66      * `GCLOUD_REGION`
    67      * `CLOUDSDK_COMPUTE_REGION`
    68  
    69  ## Authentication JSON File
    70  
    71  Authenticating with Google Cloud services requires a JSON
    72  file which we call the _account file_.
    73  
    74  This file is downloaded directly from the
    75  [Google Developers Console](https://console.developers.google.com). To make
    76  the process more straightforwarded, it is documented here:
    77  
    78  1. Log into the [Google Developers Console](https://console.developers.google.com)
    79     and select a project.
    80  
    81  2. The API Manager view should be selected, click on "Credentials" on the left,
    82     then "Create credentials", and finally "Service account key".
    83  
    84  3. Select "Compute Engine default service account" in the "Service account"
    85     dropdown, and select "JSON" as the key type.
    86  
    87  4. Clicking "Create" will download your `credentials`.