diff --git a/google/resource_cloudfunctions_function.go b/google/resource_cloudfunctions_function.go index ec2bed68..ceb04ab4 100644 --- a/google/resource_cloudfunctions_function.go +++ b/google/resource_cloudfunctions_function.go @@ -169,6 +169,12 @@ func resourceCloudFunctionsFunction() *schema.Resource { Optional: true, }, + "runtime": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "environment_variables": { Type: schema.TypeMap, Optional: true, @@ -293,6 +299,7 @@ func resourceCloudFunctionsCreate(d *schema.ResourceData, meta interface{}) erro function := &cloudfunctions.CloudFunction{ Name: cloudFuncId.cloudFunctionId(), + Runtime: d.Get("runtime").(string), ForceSendFields: []string{}, } @@ -376,6 +383,7 @@ func resourceCloudFunctionsRead(d *schema.ResourceData, meta interface{}) error } d.Set("timeout", timeout) d.Set("labels", function.Labels) + d.Set("runtime", function.Runtime) d.Set("environment_variables", function.EnvironmentVariables) if function.SourceArchiveUrl != "" { // sourceArchiveUrl should always be a Google Cloud Storage URL (e.g. gs://bucket/object) @@ -458,6 +466,11 @@ func resourceCloudFunctionsUpdate(d *schema.ResourceData, meta interface{}) erro updateMaskArr = append(updateMaskArr, "labels") } + if d.HasChange("runtime") { + function.Runtime = d.Get("runtime").(string) + updateMaskArr = append(updateMaskArr, "runtime") + } + if d.HasChange("environment_variables") { function.EnvironmentVariables = expandEnvironmentVariables(d) updateMaskArr = append(updateMaskArr, "environment_variables") diff --git a/google/resource_cloudfunctions_function_test.go b/google/resource_cloudfunctions_function_test.go index 9d7046d6..10ee2946 100644 --- a/google/resource_cloudfunctions_function_test.go +++ b/google/resource_cloudfunctions_function_test.go @@ -105,6 +105,11 @@ func TestAccCloudFunctionsFunction_update(t *testing.T) { testAccCloudFunctionsFunctionHasLabel("my-label", "my-label-value", &function), ), }, + { + ResourceName: funcResourceName, + ImportState: true, + ImportStateVerify: true, + }, { Config: testAccCloudFunctionsFunction_updated(functionName, bucketName, zipFileUpdatePath), Check: resource.ComposeTestCheckFunc( @@ -124,6 +129,11 @@ func TestAccCloudFunctionsFunction_update(t *testing.T) { "new-env-variable-value", &function), ), }, + { + ResourceName: funcResourceName, + ImportState: true, + ImportStateVerify: true, + }, }, }) } @@ -394,6 +404,7 @@ resource "google_cloudfunctions_function" "function" { source_archive_bucket = "${google_storage_bucket.bucket.name}" source_archive_object = "${google_storage_bucket_object.archive.name}" trigger_http = true + runtime = "nodejs8" timeout = 91 entry_point = "helloGET" labels { diff --git a/website/docs/d/datasource_cloudfunctions_function.html.markdown b/website/docs/d/datasource_cloudfunctions_function.html.markdown index d455f77a..7e1ea8fe 100644 --- a/website/docs/d/datasource_cloudfunctions_function.html.markdown +++ b/website/docs/d/datasource_cloudfunctions_function.html.markdown @@ -45,11 +45,10 @@ exported: * `description` - Description of the function. * `available_memory_mb` - Available memory (in MB) to the function. * `timeout` - Function execution timeout (in seconds). +* `runtime` - The runtime in which the function is running. * `entry_point` - Name of a JavaScript function that will be executed when the Google Cloud Function is triggered. * `trigger_http` - If function is triggered by HTTP, this boolean is set. * `event_trigger` - A source that fires events in response to a condition in another service. Structure is documented below. -* `trigger_bucket` - If function is triggered by bucket, bucket name is set here. Deprecated. Use `event_trigger` instead. -* `trigger_topic` - If function is triggered by Pub/Sub topic, name of topic is set here. Deprecated. Use `event_trigger` instead. * `https_trigger_url` - If function is triggered by HTTP, trigger URL is set here. * `labels` - A map of labels applied to this function. diff --git a/website/docs/r/cloudfunctions_function.html.markdown b/website/docs/r/cloudfunctions_function.html.markdown index 84fe0b9f..d7334084 100644 --- a/website/docs/r/cloudfunctions_function.html.markdown +++ b/website/docs/r/cloudfunctions_function.html.markdown @@ -76,6 +76,8 @@ Deprecated. Use `event_trigger` instead. * `labels` - (Optional) A set of key/value label pairs to assign to the function. +* `runtime` - (Optional) The runtime in which the function is going to run. If empty, defaults to `"nodejs6"`. + * `environment_variables` - (Optional) A set of key/value environment variable pairs to assign to the function. * `retry_on_failure` - (Optional) Whether the function should be retried on failure. This only applies to bucket and topic triggers, not HTTPS triggers.