Skip to content

Commit 8fa4d01

Browse files
add https_trigger_security_level to cloudfunction_function (#6007) (#11672)
* add https_trigger_security_level to cloudfunction_function * remove default, make O+C Signed-off-by: Modular Magician <[email protected]>
1 parent d271ee9 commit 8fa4d01

5 files changed

+34
-14
lines changed

.changelog/6007.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
cloudfunctions: added `https_trigger_security_level` to `google_cloudfunctions_function`
3+
```

google/resource_clouddeploy_target_generated_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,9 @@ resource "google_clouddeploy_target" "primary" {
267267
}
268268
269269
labels = {
270-
my_second_label = "updated-example-label-2"
271-
272270
my_third_label = "example-label-3"
271+
272+
my_second_label = "updated-example-label-2"
273273
}
274274
275275
project = "%{project_name}"

google/resource_cloudfunctions_function.go

+16
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,13 @@ func resourceCloudFunctionsFunction() *schema.Resource {
297297
Description: `URL which triggers function execution. Returned only if trigger_http is used.`,
298298
},
299299

300+
"https_trigger_security_level": {
301+
Type: schema.TypeString,
302+
Optional: true,
303+
Computed: true,
304+
Description: `The security level for the function. Defaults to SECURE_OPTIONAL. Valid only if trigger_http is used.`,
305+
},
306+
300307
"max_instances": {
301308
Type: schema.TypeInt,
302309
Optional: true,
@@ -481,6 +488,7 @@ func resourceCloudFunctionsCreate(d *schema.ResourceData, meta interface{}) erro
481488
function.EventTrigger = expandEventTrigger(v.([]interface{}), project)
482489
} else if v, ok := d.GetOk("trigger_http"); ok && v.(bool) {
483490
function.HttpsTrigger = &cloudfunctions.HttpsTrigger{}
491+
function.HttpsTrigger.SecurityLevel = d.Get("https_trigger_security_level").(string)
484492
} else {
485493
return fmt.Errorf("One of `event_trigger` or `trigger_http` is required: " +
486494
"You must specify a trigger when deploying a new function.")
@@ -644,6 +652,9 @@ func resourceCloudFunctionsRead(d *schema.ResourceData, meta interface{}) error
644652
if err := d.Set("https_trigger_url", function.HttpsTrigger.Url); err != nil {
645653
return fmt.Errorf("Error setting https_trigger_url: %s", err)
646654
}
655+
if err := d.Set("https_trigger_security_level", function.HttpsTrigger.SecurityLevel); err != nil {
656+
return fmt.Errorf("Error setting https_trigger_security_level: %s", err)
657+
}
647658
}
648659

649660
if err := d.Set("event_trigger", flattenEventTrigger(function.EventTrigger)); err != nil {
@@ -780,6 +791,11 @@ func resourceCloudFunctionsUpdate(d *schema.ResourceData, meta interface{}) erro
780791
updateMaskArr = append(updateMaskArr, "eventTrigger", "eventTrigger.failurePolicy.retry")
781792
}
782793

794+
if d.HasChange("https_trigger_security_level") {
795+
function.HttpsTrigger.SecurityLevel = d.Get("https_trigger_security_level").(string)
796+
updateMaskArr = append(updateMaskArr, "httpsTrigger", "httpsTrigger.securityLevel")
797+
}
798+
783799
if d.HasChange("docker_repository") {
784800
function.Runtime = d.Get("docker_repository").(string)
785801
updateMaskArr = append(updateMaskArr, "dockerRepository")

google/resource_cloudfunctions_function_test.go

+11-10
Original file line numberDiff line numberDiff line change
@@ -731,16 +731,17 @@ resource "google_storage_bucket_object" "archive" {
731731
}
732732
733733
resource "google_cloudfunctions_function" "function" {
734-
name = "%s"
735-
description = "test function updated"
736-
available_memory_mb = 256
737-
source_archive_bucket = google_storage_bucket.bucket.name
738-
source_archive_object = google_storage_bucket_object.archive.name
739-
trigger_http = true
740-
runtime = "nodejs10"
741-
timeout = 91
742-
entry_point = "helloGET"
743-
ingress_settings = "ALLOW_ALL"
734+
name = "%s"
735+
description = "test function updated"
736+
available_memory_mb = 256
737+
source_archive_bucket = google_storage_bucket.bucket.name
738+
source_archive_object = google_storage_bucket_object.archive.name
739+
trigger_http = true
740+
https_trigger_security_level = "SECURE_ALWAYS"
741+
runtime = "nodejs10"
742+
timeout = 91
743+
entry_point = "helloGET"
744+
ingress_settings = "ALLOW_ALL"
744745
labels = {
745746
my-label = "my-updated-label-value"
746747
a-new-label = "a-new-label-value"

website/docs/r/clouddeploy_delivery_pipeline.html.markdown

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ resource "google_clouddeploy_delivery_pipeline" "primary" {
4141
description = "basic description"
4242
4343
labels = {
44-
my_second_label = "example-label-2"
45-
4644
my_first_label = "example-label-1"
45+
46+
my_second_label = "example-label-2"
4747
}
4848
4949
project = "my-project-name"

0 commit comments

Comments
 (0)