Skip to content

Commit 174d678

Browse files
modular-magicianrileykarson
authored andcommitted
Add support for google_cloudfunctions_function runtime (#2340)
<!-- This change is generated by MagicModules. --> /cc @rileykarson
1 parent cf6da28 commit 174d678

4 files changed

+27
-2
lines changed

google/resource_cloudfunctions_function.go

+13
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ func resourceCloudFunctionsFunction() *schema.Resource {
169169
Optional: true,
170170
},
171171

172+
"runtime": {
173+
Type: schema.TypeString,
174+
Optional: true,
175+
Computed: true,
176+
},
177+
172178
"environment_variables": {
173179
Type: schema.TypeMap,
174180
Optional: true,
@@ -293,6 +299,7 @@ func resourceCloudFunctionsCreate(d *schema.ResourceData, meta interface{}) erro
293299

294300
function := &cloudfunctions.CloudFunction{
295301
Name: cloudFuncId.cloudFunctionId(),
302+
Runtime: d.Get("runtime").(string),
296303
ForceSendFields: []string{},
297304
}
298305

@@ -376,6 +383,7 @@ func resourceCloudFunctionsRead(d *schema.ResourceData, meta interface{}) error
376383
}
377384
d.Set("timeout", timeout)
378385
d.Set("labels", function.Labels)
386+
d.Set("runtime", function.Runtime)
379387
d.Set("environment_variables", function.EnvironmentVariables)
380388
if function.SourceArchiveUrl != "" {
381389
// 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
458466
updateMaskArr = append(updateMaskArr, "labels")
459467
}
460468

469+
if d.HasChange("runtime") {
470+
function.Runtime = d.Get("runtime").(string)
471+
updateMaskArr = append(updateMaskArr, "runtime")
472+
}
473+
461474
if d.HasChange("environment_variables") {
462475
function.EnvironmentVariables = expandEnvironmentVariables(d)
463476
updateMaskArr = append(updateMaskArr, "environment_variables")

google/resource_cloudfunctions_function_test.go

+11
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ func TestAccCloudFunctionsFunction_update(t *testing.T) {
105105
testAccCloudFunctionsFunctionHasLabel("my-label", "my-label-value", &function),
106106
),
107107
},
108+
{
109+
ResourceName: funcResourceName,
110+
ImportState: true,
111+
ImportStateVerify: true,
112+
},
108113
{
109114
Config: testAccCloudFunctionsFunction_updated(functionName, bucketName, zipFileUpdatePath),
110115
Check: resource.ComposeTestCheckFunc(
@@ -124,6 +129,11 @@ func TestAccCloudFunctionsFunction_update(t *testing.T) {
124129
"new-env-variable-value", &function),
125130
),
126131
},
132+
{
133+
ResourceName: funcResourceName,
134+
ImportState: true,
135+
ImportStateVerify: true,
136+
},
127137
},
128138
})
129139
}
@@ -394,6 +404,7 @@ resource "google_cloudfunctions_function" "function" {
394404
source_archive_bucket = "${google_storage_bucket.bucket.name}"
395405
source_archive_object = "${google_storage_bucket_object.archive.name}"
396406
trigger_http = true
407+
runtime = "nodejs8"
397408
timeout = 91
398409
entry_point = "helloGET"
399410
labels {

website/docs/d/datasource_cloudfunctions_function.html.markdown

+1-2
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,10 @@ exported:
4545
* `description` - Description of the function.
4646
* `available_memory_mb` - Available memory (in MB) to the function.
4747
* `timeout` - Function execution timeout (in seconds).
48+
* `runtime` - The runtime in which the function is running.
4849
* `entry_point` - Name of a JavaScript function that will be executed when the Google Cloud Function is triggered.
4950
* `trigger_http` - If function is triggered by HTTP, this boolean is set.
5051
* `event_trigger` - A source that fires events in response to a condition in another service. Structure is documented below.
51-
* `trigger_bucket` - If function is triggered by bucket, bucket name is set here. Deprecated. Use `event_trigger` instead.
52-
* `trigger_topic` - If function is triggered by Pub/Sub topic, name of topic is set here. Deprecated. Use `event_trigger` instead.
5352
* `https_trigger_url` - If function is triggered by HTTP, trigger URL is set here.
5453
* `labels` - A map of labels applied to this function.
5554

website/docs/r/cloudfunctions_function.html.markdown

+2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ Deprecated. Use `event_trigger` instead.
7676

7777
* `labels` - (Optional) A set of key/value label pairs to assign to the function.
7878

79+
* `runtime` - (Optional) The runtime in which the function is going to run. If empty, defaults to `"nodejs6"`.
80+
7981
* `environment_variables` - (Optional) A set of key/value environment variable pairs to assign to the function.
8082

8183
* `retry_on_failure` - (Optional) Whether the function should be retried on failure. This only applies to bucket and topic triggers, not HTTPS triggers.

0 commit comments

Comments
 (0)