Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provider/google: Accept GOOGLE_CLOUD_KEYFILE_JSON env var for credentials #6007

Merged
merged 1 commit into from
Apr 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions builtin/providers/google/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ func Provider() terraform.ResourceProvider {
},

"credentials": &schema.Schema{
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("GOOGLE_CREDENTIALS", nil),
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
"GOOGLE_CREDENTIALS",
"GOOGLE_CLOUD_KEYFILE_JSON",
}, nil),
ValidateFunc: validateCredentials,
},

Expand Down
4 changes: 3 additions & 1 deletion builtin/providers/google/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ func testAccPreCheck(t *testing.T) {
}

if v := os.Getenv("GOOGLE_CREDENTIALS"); v == "" {
t.Fatal("GOOGLE_CREDENTIALS must be set for acceptance tests")
if w := os.Getenv("GOOGLE_CLOUD_KEYFILE_JSON"); w == "" {
t.Fatal("GOOGLE_CREDENTIALS or GOOGLE_CLOUD_KEYFILE_JSON must be set for acceptance tests")
}
}

if v := os.Getenv("GOOGLE_PROJECT"); v == "" {
Expand Down
4 changes: 2 additions & 2 deletions website/source/docs/providers/google/index.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ The following keys can be used to configure the provider.
retrieving this file are below. Credentials may be blank 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_CREDENTIALS` shell environment
variable.
can also be specified with the `GOOGLE_CREDENTIALS` or `GOOGLE_CLOUD_KEYFILE_JSON`
shell environment variable, containing the contents of the credentials file.

* `project` - (Required) The ID of the project to apply any resources to. This
can also be specified with the `GOOGLE_PROJECT` shell environment variable.
Expand Down