2014-08-26 21:50:29 +00:00
---
layout: "google"
page_title: "Provider: Google Cloud"
sidebar_current: "docs-google-index"
2014-10-22 03:21:56 +00: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 21:50:29 +00: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
2017-04-17 10:17:54 +00:00
```hcl
2016-04-10 21:34:15 +00:00
// Configure the Google Cloud provider
2014-08-26 21:50:29 +00:00
provider "google" {
2015-11-12 22:13:07 +00:00
credentials = "${file("account.json")}"
2018-03-12 20:59:47 +00:00
project = "my-gce-project-id"
2015-11-12 22:13:07 +00:00
region = "us-central1"
2014-08-26 21:50:29 +00:00
}
2016-04-10 21:34:15 +00:00
// Create a new instance
2014-08-26 21:50:29 +00:00
resource "google_compute_instance" "default" {
2017-04-06 18:06:48 +00:00
# ...
2014-08-26 21:50:29 +00:00
}
```
## Configuration Reference
The following keys can be used to configure the provider.
2018-05-29 17:57:09 +00:00
* `credentials` - (Optional) Contents of a file that contains your service
2018-06-06 17:53:29 +00:00
account private key in JSON format. You can download your existing
[Google Cloud service account file]
from the Google Cloud Console, or you can create a new one from the same page.
2017-07-28 13:39:11 +00:00
Credentials can also be specified using any of the following environment
variables (listed in order of precedence):
2016-04-10 23:31:40 +00:00
* `GOOGLE_CREDENTIALS`
* `GOOGLE_CLOUD_KEYFILE_JSON`
* `GCLOUD_KEYFILE_JSON`
2018-06-06 17:53:29 +00:00
The [`GOOGLE_APPLICATION_CREDENTIALS`][adc]
2017-11-06 18:53:52 +00:00
environment variable can also contain the path of a file to obtain credentials
from.
2017-04-28 23:16:38 +00:00
2017-07-28 13:39:11 +00:00
If no credentials are specified, the provider will fall back to using the
2018-06-06 17:53:29 +00:00
[Google Application Default Credentials][adc].
2017-07-28 13:39:11 +00:00
If you are running Terraform from a GCE instance, see [Creating and Enabling
2018-06-06 17:53:29 +00:00
Service Accounts for Instances][gce-service-account] for details.
On your computer, if you have made your identity available as the
2017-07-28 13:39:11 +00:00
Application Default Credentials by running [`gcloud auth application-default
2018-06-06 17:53:29 +00:00
login`][gcloud adc], the provider will use your identity.
~> **Warning:** The gcloud method is not guaranteed to work for all APIs, and
[service accounts] or [GCE metadata] should be used if possible.
2017-07-28 13:39:11 +00:00
2018-01-03 21:33:58 +00:00
* `project` - (Optional) The ID of the project to apply any resources to. This
2017-08-01 19:37:32 +00:00
can also be specified using any of the following environment variables (listed
in order of precedence):
2016-04-10 23:31:40 +00:00
* `GOOGLE_PROJECT`
2018-03-29 18:43:45 +00:00
* `GOOGLE_CLOUD_PROJECT`
2016-04-10 23:31:40 +00:00
* `GCLOUD_PROJECT`
* `CLOUDSDK_CORE_PROJECT`
2014-08-26 21:50:29 +00:00
2018-01-03 22:09:46 +00:00
* `region` - (Optional) The region to operate under, if not specified by a given resource.
2018-01-03 21:33:58 +00:00
This can also be specified using any of the following environment variables (listed in order of
2016-04-10 23:31:40 +00:00
precedence):
2014-08-26 21:50:29 +00:00
2016-04-10 23:31:40 +00:00
* `GOOGLE_REGION`
* `GCLOUD_REGION`
* `CLOUDSDK_COMPUTE_REGION`
2018-03-29 18:43:45 +00:00
2018-01-03 21:33:58 +00:00
* `zone` - (Optional) The zone to operate under, if not specified by a given resource.
This can also be specified using any of the following environment variables (listed in order of
precedence):
2018-03-29 18:43:45 +00:00
2018-01-03 21:33:58 +00:00
* `GOOGLE_ZONE`
* `GCLOUD_ZONE`
* `CLOUDSDK_COMPUTE_ZONE`
2016-04-08 15:01:53 +00:00
2017-08-10 20:28:52 +00:00
## Beta Features
Some Google Provider resources contain Beta features; Beta GCP Features have no
deprecation policy, and no SLA, but are otherwise considered to be feature-complete
with only minor outstanding issues after their Alpha period. Beta is when a GCP feature
is publicly announced, and is when they generally become publicly available.
2018-05-09 18:24:40 +00:00
Terraform resources that support beta features will always use the Beta APIs to provision
the resource. Importing a resource that supports beta features will always import those
features, even if the resource was created in a matter that was not explicitly beta.
2018-06-06 17:53:29 +00:00
[Google Cloud service account file]: https://console.cloud.google.com/apis/credentials/serviceaccountkey
[adc]: https://cloud.google.com/docs/authentication/production
[gce-service-account]: https://cloud.google.com/compute/docs/authentication
[gcloud adc]: https://cloud.google.com/sdk/gcloud/reference/auth/application-default/login
[service accounts]: https://cloud.google.com/docs/authentication/getting-started
[GCE metadata]: https://cloud.google.com/docs/authentication/production#obtaining_credentials_on_compute_engine_kubernetes_engine_app_engine_flexible_environment_and_cloud_functions