Skip to content

Commit 90597dd

Browse files
Revert "Add Update Connector Support for VPC Access Connectors (#8205)" (#8456) (#15313)
This reverts commit 85ff1c2. Signed-off-by: Modular Magician <[email protected]>
1 parent b47915e commit 90597dd

8 files changed

+17
-194
lines changed

.changelog/8456.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
```release-note:bug
2+
vpcaccess: reverted new behaviour introduced by resource `google_vpc_access_connector` in `4.75.0`. `min_throughput` and `max_throughput` fields lost their default value, and customers could not make deployment due to that change.
3+
```
4+
```release-note:note
5+
vpcaccess: reverted the ability to update the number of instances for resource `google_vpc_access_connector`
6+
```

google/data_source_vpc_access_connector_test.go

-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ resource "google_vpc_access_connector" "connector" {
4242
ip_cidr_range = "10.8.0.0/28"
4343
network = "default"
4444
region = "us-central1"
45-
min_instances = 2
46-
max_instances = 3
4745
}
4846
4947
data "google_vpc_access_connector" "connector" {

google/resource_app_engine_standard_app_version_test.go

-2
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,6 @@ resource "google_vpc_access_connector" "bar" {
179179
region = "us-central1"
180180
ip_cidr_range = "10.8.0.0/28"
181181
network = "default"
182-
min_instances = 3
183-
max_instances = 10
184182
}
185183
186184
resource "google_app_engine_standard_app_version" "foo" {

google/resource_cloudfunctions_function_test.go

-2
Original file line numberDiff line numberDiff line change
@@ -955,8 +955,6 @@ resource "google_vpc_access_connector" "%s" {
955955
region = "us-central1"
956956
ip_cidr_range = "%s"
957957
network = google_compute_network.vpc.name
958-
min_instances = 3
959-
max_instances = 10
960958
}
961959
962960
resource "google_storage_bucket" "bucket" {

google/resource_vpc_access_connector_generated_test.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,8 @@ func testAccVPCAccessConnector_vpcAccessConnectorExample(context map[string]inte
5959
return acctest.Nprintf(`
6060
resource "google_vpc_access_connector" "connector" {
6161
name = "tf-test-vpc-con%{random_suffix}"
62-
ip_cidr_range = "10.18.0.0/28"
62+
ip_cidr_range = "10.8.0.0/28"
6363
network = "default"
64-
min_instances = 2
65-
max_instances = 3
6664
}
6765
`, context)
6866
}
@@ -100,8 +98,6 @@ resource "google_vpc_access_connector" "connector" {
10098
name = google_compute_subnetwork.custom_test.name
10199
}
102100
machine_type = "e2-standard-4"
103-
min_instances = 2
104-
max_instances = 3
105101
}
106102
107103
resource "google_compute_subnetwork" "custom_test" {

google/resource_vpc_access_connector_test.go

-59
Original file line numberDiff line numberDiff line change
@@ -33,38 +33,6 @@ func TestAccVPCAccessConnector_vpcAccessConnectorThroughput(t *testing.T) {
3333
})
3434
}
3535

36-
func TestAccVPCAccessConnector_vpcAccessConnectorMachineAndInstancesChanged(t *testing.T) {
37-
t.Parallel()
38-
39-
context := map[string]interface{}{
40-
"random_suffix": RandString(t, 10),
41-
}
42-
43-
VcrTest(t, resource.TestCase{
44-
PreCheck: func() { acctest.AccTestPreCheck(t) },
45-
ProtoV5ProviderFactories: ProtoV5ProviderFactories(t),
46-
CheckDestroy: testAccCheckVPCAccessConnectorDestroyProducer(t),
47-
Steps: []resource.TestStep{
48-
{
49-
Config: testAccVPCAccessConnector_vpcAccessConnectorThroughput(context),
50-
},
51-
{
52-
ResourceName: "google_vpc_access_connector.connector",
53-
ImportState: true,
54-
ImportStateVerify: true,
55-
},
56-
{
57-
Config: testAccVPCAccessConnector_vpcAccessConnectorMachineAndInstancesChanged(context),
58-
},
59-
{
60-
ResourceName: "google_vpc_access_connector.connector",
61-
ImportState: true,
62-
ImportStateVerify: true,
63-
},
64-
},
65-
})
66-
}
67-
6836
func testAccVPCAccessConnector_vpcAccessConnectorThroughput(context map[string]interface{}) string {
6937
return acctest.Nprintf(`
7038
resource "google_vpc_access_connector" "connector" {
@@ -91,30 +59,3 @@ resource "google_compute_network" "custom_test" {
9159
}
9260
`, context)
9361
}
94-
95-
func testAccVPCAccessConnector_vpcAccessConnectorMachineAndInstancesChanged(context map[string]interface{}) string {
96-
return Nprintf(`
97-
resource "google_vpc_access_connector" "connector" {
98-
name = "tf-test-vpc-con%{random_suffix}"
99-
subnet {
100-
name = google_compute_subnetwork.custom_test.name
101-
}
102-
machine_type = "e2-micro"
103-
min_instances = 3
104-
max_instances = 5
105-
region = "us-central1"
106-
}
107-
108-
resource "google_compute_subnetwork" "custom_test" {
109-
name = "tf-test-vpc-con%{random_suffix}"
110-
ip_cidr_range = "10.2.0.0/28"
111-
region = "us-central1"
112-
network = google_compute_network.custom_test.id
113-
}
114-
115-
resource "google_compute_network" "custom_test" {
116-
name = "tf-test-vpc-con%{random_suffix}"
117-
auto_create_subnetworks = false
118-
}
119-
`, context)
120-
}

google/services/vpcaccess/resource_vpc_access_connector.go

+8-117
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,22 @@
1818
package vpcaccess
1919

2020
import (
21-
"context"
2221
"fmt"
2322
"log"
2423
"reflect"
25-
"strings"
2624
"time"
2725

28-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff"
2926
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
3027
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
3128

3229
"github.com/hashicorp/terraform-provider-google/google/tpgresource"
3330
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
3431
)
3532

36-
// Are the number of min/max instances reduced?
37-
func AreInstancesReduced(_ context.Context, old, new, _ interface{}) bool {
38-
return new.(int) < old.(int)
39-
}
40-
4133
func ResourceVPCAccessConnector() *schema.Resource {
4234
return &schema.Resource{
4335
Create: resourceVPCAccessConnectorCreate,
4436
Read: resourceVPCAccessConnectorRead,
45-
Update: resourceVPCAccessConnectorUpdate,
4637
Delete: resourceVPCAccessConnectorDelete,
4738

4839
Importer: &schema.ResourceImporter{
@@ -51,14 +42,9 @@ func ResourceVPCAccessConnector() *schema.Resource {
5142

5243
Timeouts: &schema.ResourceTimeout{
5344
Create: schema.DefaultTimeout(20 * time.Minute),
54-
Update: schema.DefaultTimeout(20 * time.Minute),
5545
Delete: schema.DefaultTimeout(20 * time.Minute),
5646
},
5747

58-
CustomizeDiff: customdiff.All(
59-
customdiff.ForceNewIfChange("min_instances", AreInstancesReduced),
60-
customdiff.ForceNewIfChange("max_instances", AreInstancesReduced)),
61-
6248
Schema: map[string]*schema.Schema{
6349
"name": {
6450
Type: schema.TypeString,
@@ -76,36 +62,39 @@ func ResourceVPCAccessConnector() *schema.Resource {
7662
"machine_type": {
7763
Type: schema.TypeString,
7864
Optional: true,
65+
ForceNew: true,
7966
Description: `Machine type of VM Instance underlying connector. Default is e2-micro`,
8067
Default: "e2-micro",
8168
},
8269
"max_instances": {
8370
Type: schema.TypeInt,
8471
Computed: true,
8572
Optional: true,
73+
ForceNew: true,
8674
Description: `Maximum value of instances in autoscaling group underlying the connector.`,
8775
},
8876
"max_throughput": {
8977
Type: schema.TypeInt,
90-
Computed: true,
9178
Optional: true,
9279
ForceNew: true,
93-
ValidateFunc: validation.IntBetween(300, 1000),
94-
Description: `Maximum throughput of the connector in Mbps, must be greater than 'min_throughput'. Default is 1000.`,
80+
ValidateFunc: validation.IntBetween(200, 1000),
81+
Description: `Maximum throughput of the connector in Mbps, must be greater than 'min_throughput'. Default is 300.`,
82+
Default: 300,
9583
},
9684
"min_instances": {
9785
Type: schema.TypeInt,
9886
Computed: true,
9987
Optional: true,
88+
ForceNew: true,
10089
Description: `Minimum value of instances in autoscaling group underlying the connector.`,
10190
},
10291
"min_throughput": {
10392
Type: schema.TypeInt,
104-
Computed: true,
10593
Optional: true,
10694
ForceNew: true,
107-
ValidateFunc: validation.IntBetween(200, 900),
95+
ValidateFunc: validation.IntBetween(200, 1000),
10896
Description: `Minimum throughput of the connector in Mbps. Default and min is 200.`,
97+
Default: 200,
10998
},
11099
"network": {
111100
Type: schema.TypeString,
@@ -416,104 +405,6 @@ func resourceVPCAccessConnectorRead(d *schema.ResourceData, meta interface{}) er
416405
return nil
417406
}
418407

419-
func resourceVPCAccessConnectorUpdate(d *schema.ResourceData, meta interface{}) error {
420-
config := meta.(*transport_tpg.Config)
421-
userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent)
422-
if err != nil {
423-
return err
424-
}
425-
426-
billingProject := ""
427-
428-
project, err := tpgresource.GetProject(d, config)
429-
if err != nil {
430-
return fmt.Errorf("Error fetching project for Connector: %s", err)
431-
}
432-
billingProject = project
433-
434-
obj := make(map[string]interface{})
435-
machineTypeProp, err := expandVPCAccessConnectorMachineType(d.Get("machine_type"), d, config)
436-
if err != nil {
437-
return err
438-
} else if v, ok := d.GetOkExists("machine_type"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, machineTypeProp)) {
439-
obj["machineType"] = machineTypeProp
440-
}
441-
minInstancesProp, err := expandVPCAccessConnectorMinInstances(d.Get("min_instances"), d, config)
442-
if err != nil {
443-
return err
444-
} else if v, ok := d.GetOkExists("min_instances"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, minInstancesProp)) {
445-
obj["minInstances"] = minInstancesProp
446-
}
447-
maxInstancesProp, err := expandVPCAccessConnectorMaxInstances(d.Get("max_instances"), d, config)
448-
if err != nil {
449-
return err
450-
} else if v, ok := d.GetOkExists("max_instances"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, maxInstancesProp)) {
451-
obj["maxInstances"] = maxInstancesProp
452-
}
453-
454-
obj, err = resourceVPCAccessConnectorEncoder(d, meta, obj)
455-
if err != nil {
456-
return err
457-
}
458-
459-
url, err := tpgresource.ReplaceVars(d, config, "{{VPCAccessBasePath}}projects/{{project}}/locations/{{region}}/connectors/{{name}}")
460-
if err != nil {
461-
return err
462-
}
463-
464-
log.Printf("[DEBUG] Updating Connector %q: %#v", d.Id(), obj)
465-
updateMask := []string{}
466-
467-
if d.HasChange("machine_type") {
468-
updateMask = append(updateMask, "machineType")
469-
}
470-
471-
if d.HasChange("min_instances") {
472-
updateMask = append(updateMask, "minInstances")
473-
}
474-
475-
if d.HasChange("max_instances") {
476-
updateMask = append(updateMask, "maxInstances")
477-
}
478-
// updateMask is a URL parameter but not present in the schema, so ReplaceVars
479-
// won't set it
480-
url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")})
481-
if err != nil {
482-
return err
483-
}
484-
485-
// err == nil indicates that the billing_project value was found
486-
if bp, err := tpgresource.GetBillingProject(d, config); err == nil {
487-
billingProject = bp
488-
}
489-
490-
res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
491-
Config: config,
492-
Method: "PATCH",
493-
Project: billingProject,
494-
RawURL: url,
495-
UserAgent: userAgent,
496-
Body: obj,
497-
Timeout: d.Timeout(schema.TimeoutUpdate),
498-
})
499-
500-
if err != nil {
501-
return fmt.Errorf("Error updating Connector %q: %s", d.Id(), err)
502-
} else {
503-
log.Printf("[DEBUG] Finished updating Connector %q: %#v", d.Id(), res)
504-
}
505-
506-
err = VPCAccessOperationWaitTime(
507-
config, res, project, "Updating Connector", userAgent,
508-
d.Timeout(schema.TimeoutUpdate))
509-
510-
if err != nil {
511-
return err
512-
}
513-
514-
return resourceVPCAccessConnectorRead(d, meta)
515-
}
516-
517408
func resourceVPCAccessConnectorDelete(d *schema.ResourceData, meta interface{}) error {
518409
config := meta.(*transport_tpg.Config)
519410
userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent)

website/docs/r/vpc_access_connector.html.markdown

+2-7
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,8 @@ To get more information about Connector, see:
3939
```hcl
4040
resource "google_vpc_access_connector" "connector" {
4141
name = "vpc-con"
42-
ip_cidr_range = "10.18.0.0/28"
42+
ip_cidr_range = "10.8.0.0/28"
4343
network = "default"
44-
min_instances = 2
45-
max_instances = 3
4644
}
4745
```
4846
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
@@ -60,8 +58,6 @@ resource "google_vpc_access_connector" "connector" {
6058
name = google_compute_subnetwork.custom_test.name
6159
}
6260
machine_type = "e2-standard-4"
63-
min_instances = 2
64-
max_instances = 3
6561
}
6662
6763
resource "google_compute_subnetwork" "custom_test" {
@@ -116,7 +112,7 @@ The following arguments are supported:
116112

117113
* `max_throughput` -
118114
(Optional)
119-
Maximum throughput of the connector in Mbps, must be greater than `min_throughput`. Default is 1000.
115+
Maximum throughput of the connector in Mbps, must be greater than `min_throughput`. Default is 300.
120116

121117
* `subnet` -
122118
(Optional)
@@ -164,7 +160,6 @@ This resource provides the following
164160
[Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options:
165161

166162
- `create` - Default is 20 minutes.
167-
- `update` - Default is 20 minutes.
168163
- `delete` - Default is 20 minutes.
169164

170165
## Import

0 commit comments

Comments
 (0)