Skip to content

Commit

Permalink
Allow sending empty app_engine and serverless google_compute_region_n…
Browse files Browse the repository at this point in the history
…etwork_endpoint_group (#10031) (#17500)

[upstream:1b12d6c903c6ef15fe8395918f47c9f476195cf8]

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician committed Mar 6, 2024
1 parent bf69180 commit 331e4aa
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/10031.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
compute: allowed sending empty values for `SERVERLESS` in `google_compute_region_network_endpoint_group` resource
```
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ func resourceComputeRegionNetworkEndpointGroupCreate(d *schema.ResourceData, met
appEngineProp, err := expandComputeRegionNetworkEndpointGroupAppEngine(d.Get("app_engine"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("app_engine"); !tpgresource.IsEmptyValue(reflect.ValueOf(appEngineProp)) && (ok || !reflect.DeepEqual(v, appEngineProp)) {
} else if v, ok := d.GetOkExists("app_engine"); ok || !reflect.DeepEqual(v, appEngineProp) {
obj["appEngine"] = appEngineProp
}
cloudFunctionProp, err := expandComputeRegionNetworkEndpointGroupCloudFunction(d.Get("cloud_function"), d, config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,44 @@ resource "google_storage_bucket_object" "appengine_neg" {
`, context)
}

func TestAccComputeRegionNetworkEndpointGroup_regionNetworkEndpointGroupAppengineEmptyExample(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"random_suffix": acctest.RandString(t, 10),
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckComputeRegionNetworkEndpointGroupDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccComputeRegionNetworkEndpointGroup_regionNetworkEndpointGroupAppengineEmptyExample(context),
},
{
ResourceName: "google_compute_region_network_endpoint_group.appengine_neg",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"network", "subnetwork", "region"},
},
},
})
}

func testAccComputeRegionNetworkEndpointGroup_regionNetworkEndpointGroupAppengineEmptyExample(context map[string]interface{}) string {
return acctest.Nprintf(`
// App Engine Example
resource "google_compute_region_network_endpoint_group" "appengine_neg" {
name = "tf-test-appengine-neg%{random_suffix}"
network_endpoint_type = "SERVERLESS"
region = "us-central1"
app_engine {
}
}
`, context)
}

func TestAccComputeRegionNetworkEndpointGroup_regionNetworkEndpointGroupPscExample(t *testing.T) {
t.Parallel()

Expand Down
18 changes: 18 additions & 0 deletions website/docs/r/compute_region_network_endpoint_group.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,24 @@ resource "google_storage_bucket_object" "appengine_neg" {
source = "./test-fixtures/hello-world.zip"
}
```
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=region_network_endpoint_group_appengine_empty&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank">
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
</a>
</div>
## Example Usage - Region Network Endpoint Group Appengine Empty


```hcl
// App Engine Example
resource "google_compute_region_network_endpoint_group" "appengine_neg" {
name = "appengine-neg"
network_endpoint_type = "SERVERLESS"
region = "us-central1"
app_engine {
}
}
```
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=region_network_endpoint_group_psc&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank">
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
Expand Down

0 comments on commit 331e4aa

Please sign in to comment.