provider/google: Accept GOOGLE_CLOUD_KEYFILE_JSON env var for credentials
This commit is contained in:
parent
805fd7c5c1
commit
986fcd95f9
|
@ -22,9 +22,12 @@ func Provider() terraform.ResourceProvider {
|
||||||
},
|
},
|
||||||
|
|
||||||
"credentials": &schema.Schema{
|
"credentials": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
DefaultFunc: schema.EnvDefaultFunc("GOOGLE_CREDENTIALS", nil),
|
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
|
||||||
|
"GOOGLE_CREDENTIALS",
|
||||||
|
"GOOGLE_CLOUD_KEYFILE_JSON",
|
||||||
|
}, nil),
|
||||||
ValidateFunc: validateCredentials,
|
ValidateFunc: validateCredentials,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,9 @@ func testAccPreCheck(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if v := os.Getenv("GOOGLE_CREDENTIALS"); v == "" {
|
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 == "" {
|
if v := os.Getenv("GOOGLE_PROJECT"); v == "" {
|
||||||
|
|
|
@ -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
|
retrieving this file are below. Credentials may be blank if you are running
|
||||||
Terraform from a GCE instance with a properly-configured [Compute Engine
|
Terraform from a GCE instance with a properly-configured [Compute Engine
|
||||||
Service Account](https://cloud.google.com/compute/docs/authentication). This
|
Service Account](https://cloud.google.com/compute/docs/authentication). This
|
||||||
can also be specified with the `GOOGLE_CREDENTIALS` shell environment
|
can also be specified with the `GOOGLE_CREDENTIALS` or `GOOGLE_CLOUD_KEYFILE_JSON`
|
||||||
variable.
|
shell environment variable, containing the contents of the credentials file.
|
||||||
|
|
||||||
* `project` - (Required) The ID of the project to apply any resources to. This
|
* `project` - (Required) The ID of the project to apply any resources to. This
|
||||||
can also be specified with the `GOOGLE_PROJECT` shell environment variable.
|
can also be specified with the `GOOGLE_PROJECT` shell environment variable.
|
||||||
|
|
Loading…
Reference in New Issue