Skip to content

Commit 37ed0f9

Browse files
Revert "[do not merge] Promote functions gen 2 direct VPC to GA. (#1… (#16395) (#26091)
[upstream:da36a2ca389fde74de8d6c97d37bbbdbd335c66f] Signed-off-by: Modular Magician <magic-modules@google.com>
1 parent 81732fa commit 37ed0f9

File tree

6 files changed

+14
-368
lines changed

6 files changed

+14
-368
lines changed

.changelog/16395.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
```release-note:note
2+
(revert) cloudfunctions2: promoted `direct_vpc_network_interface` and `direct_vpc_egress` fields to GA in the `google_cloudfunctions2_function` resource.
3+
```
4+
5+
```release-note:note
6+
(revert) cloudfunctions2: added new fields `direct_vpc_network_interface` and `direct_vpc_egress`. Users who have enabled DirectVPC on the underlying Run service will need to take extra care, as the values may now need to be explicitly set in your configuration
7+
```

google/services/cloudfunctions2/resource_cloudfunctions2_function.go

Lines changed: 0 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -433,40 +433,6 @@ supplied the value is interpreted as bytes.`,
433433
Optional: true,
434434
Description: `The binary authorization policy to be checked when deploying the Cloud Run service.`,
435435
},
436-
"direct_vpc_egress": {
437-
Type: schema.TypeString,
438-
Computed: true,
439-
Optional: true,
440-
ValidateFunc: verify.ValidateEnum([]string{"VPC_EGRESS_ALL_TRAFFIC", "VPC_EGRESS_PRIVATE_RANGES_ONLY", ""}),
441-
Description: `Egress settings for direct VPC. If not provided, it defaults to VPC_EGRESS_PRIVATE_RANGES_ONLY. Possible values: ["VPC_EGRESS_ALL_TRAFFIC", "VPC_EGRESS_PRIVATE_RANGES_ONLY"]`,
442-
},
443-
"direct_vpc_network_interface": {
444-
Type: schema.TypeList,
445-
Optional: true,
446-
Description: `The Direct VPC network interface for the Cloud Function. Currently only a single Direct VPC is supported.`,
447-
Elem: &schema.Resource{
448-
Schema: map[string]*schema.Schema{
449-
"network": {
450-
Type: schema.TypeString,
451-
Optional: true,
452-
Description: `The name of the VPC network to which the function will be connected. Specify either a VPC network or a subnet, or both. If you specify only a network, the subnet uses the same name as the network.`,
453-
},
454-
"subnetwork": {
455-
Type: schema.TypeString,
456-
Optional: true,
457-
Description: `The name of the VPC subnetwork that the Cloud Function resource will get IPs from. Specify either a VPC network or a subnet, or both. If both network and subnetwork are specified, the given VPC subnetwork must belong to the given VPC network. If subnetwork is not specified, the subnetwork with the same name with the network will be used.`,
458-
},
459-
"tags": {
460-
Type: schema.TypeList,
461-
Optional: true,
462-
Description: `Network tags applied to this Cloud Function resource.`,
463-
Elem: &schema.Schema{
464-
Type: schema.TypeString,
465-
},
466-
},
467-
},
468-
},
469-
},
470436
"environment_variables": {
471437
Type: schema.TypeMap,
472438
Computed: true,
@@ -1375,10 +1341,6 @@ func flattenCloudfunctions2functionServiceConfig(v interface{}, d *schema.Resour
13751341
flattenCloudfunctions2functionServiceConfigVpcConnector(original["vpcConnector"], d, config)
13761342
transformed["vpc_connector_egress_settings"] =
13771343
flattenCloudfunctions2functionServiceConfigVpcConnectorEgressSettings(original["vpcConnectorEgressSettings"], d, config)
1378-
transformed["direct_vpc_network_interface"] =
1379-
flattenCloudfunctions2functionServiceConfigDirectVpcNetworkInterface(original["directVpcNetworkInterface"], d, config)
1380-
transformed["direct_vpc_egress"] =
1381-
flattenCloudfunctions2functionServiceConfigDirectVpcEgress(original["directVpcEgress"], d, config)
13821344
transformed["ingress_settings"] =
13831345
flattenCloudfunctions2functionServiceConfigIngressSettings(original["ingressSettings"], d, config)
13841346
transformed["uri"] =
@@ -1489,42 +1451,6 @@ func flattenCloudfunctions2functionServiceConfigVpcConnectorEgressSettings(v int
14891451
return v
14901452
}
14911453

1492-
func flattenCloudfunctions2functionServiceConfigDirectVpcNetworkInterface(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1493-
if v == nil {
1494-
return v
1495-
}
1496-
l := v.([]interface{})
1497-
transformed := make([]interface{}, 0, len(l))
1498-
for _, raw := range l {
1499-
original := raw.(map[string]interface{})
1500-
if len(original) < 1 {
1501-
// Do not include empty json objects coming back from the api
1502-
continue
1503-
}
1504-
transformed = append(transformed, map[string]interface{}{
1505-
"network": flattenCloudfunctions2functionServiceConfigDirectVpcNetworkInterfaceNetwork(original["network"], d, config),
1506-
"subnetwork": flattenCloudfunctions2functionServiceConfigDirectVpcNetworkInterfaceSubnetwork(original["subnetwork"], d, config),
1507-
"tags": flattenCloudfunctions2functionServiceConfigDirectVpcNetworkInterfaceTags(original["tags"], d, config),
1508-
})
1509-
}
1510-
return transformed
1511-
}
1512-
func flattenCloudfunctions2functionServiceConfigDirectVpcNetworkInterfaceNetwork(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1513-
return v
1514-
}
1515-
1516-
func flattenCloudfunctions2functionServiceConfigDirectVpcNetworkInterfaceSubnetwork(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1517-
return v
1518-
}
1519-
1520-
func flattenCloudfunctions2functionServiceConfigDirectVpcNetworkInterfaceTags(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1521-
return v
1522-
}
1523-
1524-
func flattenCloudfunctions2functionServiceConfigDirectVpcEgress(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1525-
return v
1526-
}
1527-
15281454
func flattenCloudfunctions2functionServiceConfigIngressSettings(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
15291455
return v
15301456
}
@@ -2197,20 +2123,6 @@ func expandCloudfunctions2functionServiceConfig(v interface{}, d tpgresource.Ter
21972123
transformed["vpcConnectorEgressSettings"] = transformedVpcConnectorEgressSettings
21982124
}
21992125

2200-
transformedDirectVpcNetworkInterface, err := expandCloudfunctions2functionServiceConfigDirectVpcNetworkInterface(original["direct_vpc_network_interface"], d, config)
2201-
if err != nil {
2202-
return nil, err
2203-
} else if val := reflect.ValueOf(transformedDirectVpcNetworkInterface); val.IsValid() && !tpgresource.IsEmptyValue(val) {
2204-
transformed["directVpcNetworkInterface"] = transformedDirectVpcNetworkInterface
2205-
}
2206-
2207-
transformedDirectVpcEgress, err := expandCloudfunctions2functionServiceConfigDirectVpcEgress(original["direct_vpc_egress"], d, config)
2208-
if err != nil {
2209-
return nil, err
2210-
} else if val := reflect.ValueOf(transformedDirectVpcEgress); val.IsValid() && !tpgresource.IsEmptyValue(val) {
2211-
transformed["directVpcEgress"] = transformedDirectVpcEgress
2212-
}
2213-
22142126
transformedIngressSettings, err := expandCloudfunctions2functionServiceConfigIngressSettings(original["ingress_settings"], d, config)
22152127
if err != nil {
22162128
return nil, err
@@ -2317,61 +2229,6 @@ func expandCloudfunctions2functionServiceConfigVpcConnectorEgressSettings(v inte
23172229
return v, nil
23182230
}
23192231

2320-
func expandCloudfunctions2functionServiceConfigDirectVpcNetworkInterface(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
2321-
if v == nil {
2322-
return nil, nil
2323-
}
2324-
l := v.([]interface{})
2325-
req := make([]interface{}, 0, len(l))
2326-
for _, raw := range l {
2327-
if raw == nil {
2328-
continue
2329-
}
2330-
original := raw.(map[string]interface{})
2331-
transformed := make(map[string]interface{})
2332-
2333-
transformedNetwork, err := expandCloudfunctions2functionServiceConfigDirectVpcNetworkInterfaceNetwork(original["network"], d, config)
2334-
if err != nil {
2335-
return nil, err
2336-
} else if val := reflect.ValueOf(transformedNetwork); val.IsValid() && !tpgresource.IsEmptyValue(val) {
2337-
transformed["network"] = transformedNetwork
2338-
}
2339-
2340-
transformedSubnetwork, err := expandCloudfunctions2functionServiceConfigDirectVpcNetworkInterfaceSubnetwork(original["subnetwork"], d, config)
2341-
if err != nil {
2342-
return nil, err
2343-
} else if val := reflect.ValueOf(transformedSubnetwork); val.IsValid() && !tpgresource.IsEmptyValue(val) {
2344-
transformed["subnetwork"] = transformedSubnetwork
2345-
}
2346-
2347-
transformedTags, err := expandCloudfunctions2functionServiceConfigDirectVpcNetworkInterfaceTags(original["tags"], d, config)
2348-
if err != nil {
2349-
return nil, err
2350-
} else if val := reflect.ValueOf(transformedTags); val.IsValid() && !tpgresource.IsEmptyValue(val) {
2351-
transformed["tags"] = transformedTags
2352-
}
2353-
2354-
req = append(req, transformed)
2355-
}
2356-
return req, nil
2357-
}
2358-
2359-
func expandCloudfunctions2functionServiceConfigDirectVpcNetworkInterfaceNetwork(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
2360-
return v, nil
2361-
}
2362-
2363-
func expandCloudfunctions2functionServiceConfigDirectVpcNetworkInterfaceSubnetwork(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
2364-
return v, nil
2365-
}
2366-
2367-
func expandCloudfunctions2functionServiceConfigDirectVpcNetworkInterfaceTags(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
2368-
return v, nil
2369-
}
2370-
2371-
func expandCloudfunctions2functionServiceConfigDirectVpcEgress(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
2372-
return v, nil
2373-
}
2374-
23752232
func expandCloudfunctions2functionServiceConfigIngressSettings(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
23762233
return v, nil
23772234
}

google/services/cloudfunctions2/resource_cloudfunctions2_function_generated_meta.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ fields:
4646
- api_field: serviceConfig.availableCpu
4747
- api_field: serviceConfig.availableMemory
4848
- api_field: serviceConfig.binaryAuthorizationPolicy
49-
- api_field: serviceConfig.directVpcEgress
50-
- api_field: serviceConfig.directVpcNetworkInterface.network
51-
- api_field: serviceConfig.directVpcNetworkInterface.subnetwork
52-
- api_field: serviceConfig.directVpcNetworkInterface.tags
5349
- api_field: serviceConfig.environmentVariables
5450
- api_field: serviceConfig.gcfUri
5551
- api_field: serviceConfig.ingressSettings

google/services/cloudfunctions2/resource_cloudfunctions2_function_generated_test.go

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -911,83 +911,6 @@ resource "google_cloudfunctions2_function" "function" {
911911
`, context)
912912
}
913913

914-
func TestAccCloudfunctions2function_cloudfunctions2DirectvpcExample(t *testing.T) {
915-
t.Parallel()
916-
917-
context := map[string]interface{}{
918-
"project": envvar.GetTestProjectFromEnv(),
919-
"location": "us-central1",
920-
"zip_path": "./test-fixtures/function-source.zip",
921-
"random_suffix": acctest.RandString(t, 10),
922-
}
923-
924-
acctest.VcrTest(t, resource.TestCase{
925-
PreCheck: func() { acctest.AccTestPreCheck(t) },
926-
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
927-
CheckDestroy: testAccCheckCloudfunctions2functionDestroyProducer(t),
928-
Steps: []resource.TestStep{
929-
{
930-
Config: testAccCloudfunctions2function_cloudfunctions2DirectvpcExample(context),
931-
},
932-
{
933-
ResourceName: "google_cloudfunctions2_function.function",
934-
ImportState: true,
935-
ImportStateVerify: true,
936-
ImportStateVerifyIgnore: []string{"build_config.0.source.0.storage_source.0.bucket", "build_config.0.source.0.storage_source.0.object", "labels", "location", "terraform_labels"},
937-
},
938-
},
939-
})
940-
}
941-
942-
func testAccCloudfunctions2function_cloudfunctions2DirectvpcExample(context map[string]interface{}) string {
943-
return acctest.Nprintf(`
944-
locals {
945-
project = "%{project}" # Google Cloud Platform Project ID
946-
}
947-
948-
resource "google_storage_bucket" "bucket" {
949-
name = "${local.project}-tf-test-gcf-source%{random_suffix}" # Every bucket name must be globally unique
950-
location = "US"
951-
uniform_bucket_level_access = true
952-
}
953-
954-
resource "google_storage_bucket_object" "object" {
955-
name = "function-source.zip"
956-
bucket = google_storage_bucket.bucket.name
957-
source = "%{zip_path}" # Add path to the zipped function source code
958-
}
959-
960-
resource "google_cloudfunctions2_function" "function" {
961-
name = "tf-test-function-v2%{random_suffix}"
962-
location = "us-central1"
963-
description = "a new function"
964-
965-
build_config {
966-
runtime = "nodejs20"
967-
entry_point = "helloHttp" # Set the entry point
968-
source {
969-
storage_source {
970-
bucket = google_storage_bucket.bucket.name
971-
object = google_storage_bucket_object.object.name
972-
}
973-
}
974-
}
975-
976-
service_config {
977-
max_instance_count = 1
978-
available_memory = "256M"
979-
timeout_seconds = 60
980-
direct_vpc_network_interface {
981-
network = "default"
982-
subnetwork = "default"
983-
tags = ["tag1", "tag2"]
984-
}
985-
direct_vpc_egress = "VPC_EGRESS_ALL_TRAFFIC"
986-
}
987-
}
988-
`, context)
989-
}
990-
991914
func testAccCheckCloudfunctions2functionDestroyProducer(t *testing.T) func(s *terraform.State) error {
992915
return func(s *terraform.State) error {
993916
for name, rs := range s.RootModule().Resources {

0 commit comments

Comments
 (0)