Skip to content

Commit dd4bd8c

Browse files
Cloud Router Standard BPS Terraform Beta to GA support (#12697) (#9029)
[upstream:86536e5a65595d19c295cc5a5cfc5f83effc6272] Signed-off-by: Modular Magician <[email protected]>
1 parent 9a1e22f commit dd4bd8c

File tree

5 files changed

+27
-135
lines changed

5 files changed

+27
-135
lines changed

.changelog/12697.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
```release-note:enhancement
2+
compute: promoted `bgp_best_path_selection_mode `,`bgp_bps_always_compare_med` and `bgp_bps_inter_region_cost ` fields in `google_compute_network` from Beta to Ga
3+
```
4+
```release-note:enhancement
5+
compute: promoted `next_hop_origin `,`next_hop_med ` and `next_hop_inter_region_cost ` output fields in `google_compute_route` form Beta to GA
6+
```

google-beta/services/compute/resource_compute_network_generated_test.go

+3-6
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func TestAccComputeNetwork_networkBgpBestPathSelectionModeExample(t *testing.T)
145145

146146
acctest.VcrTest(t, resource.TestCase{
147147
PreCheck: func() { acctest.AccTestPreCheck(t) },
148-
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
148+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
149149
CheckDestroy: testAccCheckComputeNetworkDestroyProducer(t),
150150
Steps: []resource.TestStep{
151151
{
@@ -163,7 +163,6 @@ func TestAccComputeNetwork_networkBgpBestPathSelectionModeExample(t *testing.T)
163163
func testAccComputeNetwork_networkBgpBestPathSelectionModeExample(context map[string]interface{}) string {
164164
return acctest.Nprintf(`
165165
resource "google_compute_network" "vpc_network" {
166-
provider = google-beta
167166
project = "%{project}"
168167
name = "tf-test-vpc-network%{random_suffix}"
169168
routing_mode = "GLOBAL"
@@ -181,7 +180,7 @@ func TestAccComputeNetwork_networkBgpBestPathSelectionModeStandardExample(t *tes
181180

182181
acctest.VcrTest(t, resource.TestCase{
183182
PreCheck: func() { acctest.AccTestPreCheck(t) },
184-
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
183+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
185184
CheckDestroy: testAccCheckComputeNetworkDestroyProducer(t),
186185
Steps: []resource.TestStep{
187186
{
@@ -199,7 +198,6 @@ func TestAccComputeNetwork_networkBgpBestPathSelectionModeStandardExample(t *tes
199198
func testAccComputeNetwork_networkBgpBestPathSelectionModeStandardExample(context map[string]interface{}) string {
200199
return acctest.Nprintf(`
201200
resource "google_compute_network" "vpc_network" {
202-
provider = google-beta
203201
project = "%{project}"
204202
name = "tf-test-vpc-network%{random_suffix}"
205203
routing_mode = "GLOBAL"
@@ -218,7 +216,7 @@ func TestAccComputeNetwork_networkBgpBestPathSelectionModeStandardCustomFieldsEx
218216

219217
acctest.VcrTest(t, resource.TestCase{
220218
PreCheck: func() { acctest.AccTestPreCheck(t) },
221-
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
219+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
222220
CheckDestroy: testAccCheckComputeNetworkDestroyProducer(t),
223221
Steps: []resource.TestStep{
224222
{
@@ -236,7 +234,6 @@ func TestAccComputeNetwork_networkBgpBestPathSelectionModeStandardCustomFieldsEx
236234
func testAccComputeNetwork_networkBgpBestPathSelectionModeStandardCustomFieldsExample(context map[string]interface{}) string {
237235
return acctest.Nprintf(`
238236
resource "google_compute_network" "vpc_network" {
239-
provider = google-beta
240237
project = "%{project}"
241238
name = "tf-test-vpc-network%{random_suffix}"
242239
routing_mode = "GLOBAL"

google-beta/services/compute/resource_compute_network_test.go

+15-120
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,15 @@ func TestAccComputeNetwork_bgpBestPathSelectionModeAndUpdate(t *testing.T) {
119119

120120
acctest.VcrTest(t, resource.TestCase{
121121
PreCheck: func() { acctest.AccTestPreCheck(t) },
122-
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
122+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
123123
CheckDestroy: testAccCheckComputeNetworkDestroyProducer(t),
124124
Steps: []resource.TestStep{
125125
{
126126
Config: testAccComputeNetwork_best_bgp_path_selection_mode(networkName, "LEGACY"),
127127
Check: resource.ComposeTestCheckFunc(
128128
testAccCheckComputeNetworkExists(
129129
t, "google_compute_network.acc_network_bgp_best_path_selection_mode", &network),
130-
testAccCheckComputeNetworkHasBgpBestPathSelectionMode(t, "google_compute_network.acc_network_bgp_best_path_selection_mode", &network, "LEGACY"),
130+
resource.TestCheckResourceAttr("google_compute_network.acc_network_bgp_best_path_selection_mode", "bgp_best_path_selection_mode", "LEGACY"),
131131
),
132132
},
133133
// Test updating the best bgp path selection field (only updatable field).
@@ -136,7 +136,7 @@ func TestAccComputeNetwork_bgpBestPathSelectionModeAndUpdate(t *testing.T) {
136136
Check: resource.ComposeTestCheckFunc(
137137
testAccCheckComputeNetworkExists(
138138
t, "google_compute_network.acc_network_bgp_best_path_selection_mode", &network),
139-
testAccCheckComputeNetworkHasBgpBestPathSelectionMode(t, "google_compute_network.acc_network_bgp_best_path_selection_mode", &network, "STANDARD"),
139+
resource.TestCheckResourceAttr("google_compute_network.acc_network_bgp_best_path_selection_mode", "bgp_best_path_selection_mode", "STANDARD"),
140140
),
141141
},
142142
},
@@ -153,16 +153,15 @@ func TestAccComputeNetwork_bgpAlwaysCompareMedAndUpdate(t *testing.T) {
153153

154154
acctest.VcrTest(t, resource.TestCase{
155155
PreCheck: func() { acctest.AccTestPreCheck(t) },
156-
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
156+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
157157
CheckDestroy: testAccCheckComputeNetworkDestroyProducer(t),
158158
Steps: []resource.TestStep{
159159
{
160160
Config: testAccComputeNetwork_bgp_always_compare_med(networkName, false),
161161
Check: resource.ComposeTestCheckFunc(
162162
testAccCheckComputeNetworkExists(
163163
t, "google_compute_network.acc_network_bgp_always_compare_med", &network),
164-
testAccCheckComputeNetworkHasBgpAlwaysCompareMed(
165-
t, "google_compute_network.acc_network_bgp_always_compare_med", &network, false),
164+
resource.TestCheckResourceAttr("google_compute_network.acc_network_bgp_always_compare_med", "bgp_always_compare_med", "false"),
166165
),
167166
},
168167
// Test updating the bgpAlwaysCompareMed field (only updatable field).
@@ -171,8 +170,7 @@ func TestAccComputeNetwork_bgpAlwaysCompareMedAndUpdate(t *testing.T) {
171170
Check: resource.ComposeTestCheckFunc(
172171
testAccCheckComputeNetworkExists(
173172
t, "google_compute_network.acc_network_bgp_always_compare_med", &network),
174-
testAccCheckComputeNetworkHasBgpAlwaysCompareMed(
175-
t, "google_compute_network.acc_network_bgp_always_compare_med", &network, true),
173+
resource.TestCheckResourceAttr("google_compute_network.acc_network_bgp_always_compare_med", "bgp_always_compare_med", "true"),
176174
),
177175
},
178176
},
@@ -188,16 +186,15 @@ func TestAccComputeNetwork_bgpInterRegionCostAndUpdate(t *testing.T) {
188186

189187
acctest.VcrTest(t, resource.TestCase{
190188
PreCheck: func() { acctest.AccTestPreCheck(t) },
191-
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
189+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
192190
CheckDestroy: testAccCheckComputeNetworkDestroyProducer(t),
193191
Steps: []resource.TestStep{
194192
{
195193
Config: testAccComputeNetwork_bgp_inter_region_cost(networkName, "DEFAULT"),
196194
Check: resource.ComposeTestCheckFunc(
197195
testAccCheckComputeNetworkExists(
198196
t, "google_compute_network.acc_network_bgp_inter_region_cost", &network),
199-
testAccCheckComputeNetworkHasBgpInterRegionCost(
200-
t, "google_compute_network.acc_network_bgp_inter_region_cost", &network, "DEFAULT"),
197+
resource.TestCheckResourceAttr("google_compute_network.acc_network_bgp_inter_region_cost", "bgp_inter_region_cost", "DEFAULT"),
201198
),
202199
},
203200
// Test updating the bgpInterRegionCost field (only updatable field).
@@ -206,8 +203,7 @@ func TestAccComputeNetwork_bgpInterRegionCostAndUpdate(t *testing.T) {
206203
Check: resource.ComposeTestCheckFunc(
207204
testAccCheckComputeNetworkExists(
208205
t, "google_compute_network.acc_network_bgp_inter_region_cost", &network),
209-
testAccCheckComputeNetworkHasBgpInterRegionCost(
210-
t, "google_compute_network.acc_network_bgp_inter_region_cost", &network, "ADD_COST_TO_MED"),
206+
resource.TestCheckResourceAttr("google_compute_network.acc_network_bgp_inter_region_cost", "bgp_inter_region_cost", "ADD_COST_TO_MED"),
211207
),
212208
},
213209
},
@@ -308,15 +304,15 @@ func TestAccComputeNetwork_default_bgp_best_path_selection_mode(t *testing.T) {
308304

309305
acctest.VcrTest(t, resource.TestCase{
310306
PreCheck: func() { acctest.AccTestPreCheck(t) },
311-
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
307+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
312308
CheckDestroy: testAccCheckComputeNetworkDestroyProducer(t),
313309
Steps: []resource.TestStep{
314310
{
315-
Config: testAccComputeBetaNetwork_basic(networkName),
311+
Config: testAccComputeNetwork_basic(networkName),
316312
Check: resource.ComposeTestCheckFunc(
317313
testAccCheckComputeNetworkExists(
318314
t, "google_compute_network.bar", &network),
319-
testAccCheckComputeNetworkHasBgpBestPathSelectionMode(t, "google_compute_network.bar", &network, expectedBgpBestPathSelection),
315+
resource.TestCheckResourceAttr("google_compute_network.bar", "bgp_best_path_selection_mode", expectedBgpBestPathSelection),
320316
),
321317
},
322318
},
@@ -330,20 +326,19 @@ func TestAccComputeNetwork_default_bgp_always_compare_med(t *testing.T) {
330326
suffixName := acctest.RandString(t, 10)
331327
networkName := fmt.Sprintf("tf-test-bgp-always-compare-med-default-routes-%s", suffixName)
332328

333-
expectedBgpAlwaysCompareMed := false
329+
expectedBgpAlwaysCompareMed := "false"
334330

335331
acctest.VcrTest(t, resource.TestCase{
336332
PreCheck: func() { acctest.AccTestPreCheck(t) },
337-
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
333+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
338334
CheckDestroy: testAccCheckComputeNetworkDestroyProducer(t),
339335
Steps: []resource.TestStep{
340336
{
341337
Config: testAccComputeNetwork_best_bgp_path_selection_mode(networkName, "STANDARD"),
342338
Check: resource.ComposeTestCheckFunc(
343339
testAccCheckComputeNetworkExists(
344340
t, "google_compute_network.acc_network_bgp_best_path_selection_mode", &network),
345-
testAccCheckComputeNetworkHasBgpAlwaysCompareMed(
346-
t, "google_compute_network.acc_network_bgp_best_path_selection_mode", &network, expectedBgpAlwaysCompareMed),
341+
resource.TestCheckResourceAttr("google_compute_network.acc_network_bgp_best_path_selection_mode", "bgp_always_compare_med", expectedBgpAlwaysCompareMed),
347342
),
348343
},
349344
},
@@ -555,93 +550,6 @@ func testAccCheckComputeNetworkHasRoutingMode(t *testing.T, n string, network *c
555550
}
556551
}
557552

558-
func testAccCheckComputeNetworkHasBgpBestPathSelectionMode(t *testing.T, n string, network *compute.Network, bgpBestPathSelectionMode string) resource.TestCheckFunc {
559-
return func(s *terraform.State) error {
560-
config := acctest.GoogleProviderConfig(t)
561-
562-
rs, ok := s.RootModule().Resources[n]
563-
if !ok {
564-
return fmt.Errorf("Not found: %s", n)
565-
}
566-
567-
if rs.Primary.Attributes["bgp_always_compare_med"] == "" {
568-
return fmt.Errorf("BGP always compare med not found on resource")
569-
}
570-
571-
found, err := config.NewComputeClient(config.UserAgent).Networks.Get(
572-
config.Project, network.Name).Do()
573-
if err != nil {
574-
return err
575-
}
576-
577-
foundBgpBestPathSelectionMode := found.RoutingConfig.BgpBestPathSelectionMode
578-
579-
if bgpBestPathSelectionMode != foundBgpBestPathSelectionMode {
580-
return fmt.Errorf("Expected BGP always compare med %s to match actual BGP always compare med %s", bgpBestPathSelectionMode, foundBgpBestPathSelectionMode)
581-
}
582-
583-
return nil
584-
}
585-
}
586-
587-
func testAccCheckComputeNetworkHasBgpAlwaysCompareMed(t *testing.T, n string, network *compute.Network, bgpAlwaysCompareMed bool) resource.TestCheckFunc {
588-
return func(s *terraform.State) error {
589-
config := acctest.GoogleProviderConfig(t)
590-
591-
rs, ok := s.RootModule().Resources[n]
592-
if !ok {
593-
return fmt.Errorf("Not found: %s", n)
594-
}
595-
596-
if rs.Primary.Attributes["bgp_always_compare_med"] == "" {
597-
return fmt.Errorf("BGP always compare med not found on resource")
598-
}
599-
600-
found, err := config.NewComputeClient(config.UserAgent).Networks.Get(
601-
config.Project, network.Name).Do()
602-
if err != nil {
603-
return err
604-
}
605-
606-
foundBgpAlwaysCompareMed := found.RoutingConfig.BgpAlwaysCompareMed
607-
608-
if foundBgpAlwaysCompareMed != bgpAlwaysCompareMed {
609-
return fmt.Errorf("Expected BGP always compare med %t to match actual BGP always compare med %t", bgpAlwaysCompareMed, foundBgpAlwaysCompareMed)
610-
}
611-
612-
return nil
613-
}
614-
}
615-
616-
func testAccCheckComputeNetworkHasBgpInterRegionCost(t *testing.T, n string, network *compute.Network, bgpInterRegionCost string) resource.TestCheckFunc {
617-
return func(s *terraform.State) error {
618-
config := acctest.GoogleProviderConfig(t)
619-
620-
rs, ok := s.RootModule().Resources[n]
621-
if !ok {
622-
return fmt.Errorf("Not found: %s", n)
623-
}
624-
625-
if rs.Primary.Attributes["bgp_inter_region_cost"] == "" {
626-
return fmt.Errorf("BGP inter region cost not found on resource")
627-
}
628-
629-
found, err := config.NewComputeClient(config.UserAgent).Networks.Get(
630-
config.Project, network.Name).Do()
631-
if err != nil {
632-
return err
633-
}
634-
635-
foundBgpInterRegionCost := found.RoutingConfig.BgpInterRegionCost
636-
637-
if foundBgpInterRegionCost != bgpInterRegionCost {
638-
return fmt.Errorf("Expected BGP always compare med %s to match actual BGP always compare med %s", bgpInterRegionCost, foundBgpInterRegionCost)
639-
}
640-
641-
return nil
642-
}
643-
}
644-
645553
func testAccCheckComputeNetworkHasNetworkProfile(t *testing.T, n string, network *compute.Network, networkProfile string) resource.TestCheckFunc {
646554
return func(s *terraform.State) error {
647555
config := acctest.GoogleProviderConfig(t)
@@ -736,20 +644,9 @@ resource "google_compute_network" "acc_network_routing_mode" {
736644
`, networkName, routingMode)
737645
}
738646

739-
func testAccComputeBetaNetwork_basic(networkName string) string {
740-
return fmt.Sprintf(`
741-
resource "google_compute_network" "bar" {
742-
provider = google-beta
743-
name = "%s"
744-
auto_create_subnetworks = true
745-
}
746-
`, networkName)
747-
}
748-
749647
func testAccComputeNetwork_best_bgp_path_selection_mode(networkName, bgpBestPathSelection string) string {
750648
return fmt.Sprintf(`
751649
resource "google_compute_network" "acc_network_bgp_best_path_selection_mode" {
752-
provider = google-beta
753650
name = "%s"
754651
routing_mode = "GLOBAL"
755652
bgp_best_path_selection_mode = "%s"
@@ -760,7 +657,6 @@ resource "google_compute_network" "acc_network_bgp_best_path_selection_mode" {
760657
func testAccComputeNetwork_bgp_always_compare_med(networkName string, bgpAlwaysCompareMed bool) string {
761658
return fmt.Sprintf(`
762659
resource "google_compute_network" "acc_network_bgp_always_compare_med" {
763-
provider = google-beta
764660
name = "%s"
765661
routing_mode = "GLOBAL"
766662
bgp_best_path_selection_mode = "STANDARD"
@@ -772,7 +668,6 @@ resource "google_compute_network" "acc_network_bgp_always_compare_med" {
772668
func testAccComputeNetwork_bgp_inter_region_cost(networkName, bgpInterRegionCost string) string {
773669
return fmt.Sprintf(`
774670
resource "google_compute_network" "acc_network_bgp_inter_region_cost" {
775-
provider = google-beta
776671
name = "%s"
777672
routing_mode = "GLOBAL"
778673
bgp_best_path_selection_mode = "STANDARD"

website/docs/r/compute_network.html.markdown

+3-6
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ resource "google_compute_network" "vpc_network" {
6868

6969
```hcl
7070
resource "google_compute_network" "vpc_network" {
71-
provider = google-beta
7271
project = "my-project-name"
7372
name = "vpc-network"
7473
routing_mode = "GLOBAL"
@@ -79,7 +78,6 @@ resource "google_compute_network" "vpc_network" {
7978

8079
```hcl
8180
resource "google_compute_network" "vpc_network" {
82-
provider = google-beta
8381
project = "my-project-name"
8482
name = "vpc-network"
8583
routing_mode = "GLOBAL"
@@ -91,7 +89,6 @@ resource "google_compute_network" "vpc_network" {
9189

9290
```hcl
9391
resource "google_compute_network" "vpc_network" {
94-
provider = google-beta
9592
project = "my-project-name"
9693
name = "vpc-network"
9794
routing_mode = "GLOBAL"
@@ -143,17 +140,17 @@ The following arguments are supported:
143140
Possible values are: `REGIONAL`, `GLOBAL`.
144141

145142
* `bgp_best_path_selection_mode` -
146-
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
143+
(Optional)
147144
The BGP best selection algorithm to be employed. MODE can be LEGACY or STANDARD.
148145
Possible values are: `LEGACY`, `STANDARD`.
149146

150147
* `bgp_always_compare_med` -
151-
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
148+
(Optional)
152149
Enables/disables the comparison of MED across routes with different Neighbor ASNs.
153150
This value can only be set if the --bgp-best-path-selection-mode is STANDARD
154151

155152
* `bgp_inter_region_cost` -
156-
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
153+
(Optional)
157154
Choice of the behavior of inter-regional cost and MED in the BPS algorithm.
158155
Possible values are: `DEFAULT`, `ADD_COST_TO_MED`.
159156

website/docs/r/compute_route.html.markdown

-3
Original file line numberDiff line numberDiff line change
@@ -329,15 +329,12 @@ In addition to the arguments listed above, the following computed attributes are
329329
URL to a Network that should handle matching packets.
330330

331331
* `next_hop_origin` -
332-
([Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
333332
Indicates the origin of the route. Can be IGP (Interior Gateway Protocol), EGP (Exterior Gateway Protocol), or INCOMPLETE.
334333

335334
* `next_hop_med` -
336-
([Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
337335
Multi-Exit Discriminator, a BGP route metric that indicates the desirability of a particular route in a network.
338336

339337
* `next_hop_inter_region_cost` -
340-
([Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
341338
Internal fixed region-to-region cost that Google Cloud calculates based on factors such as network performance, distance, and available bandwidth between regions.
342339
* `self_link` - The URI of the created resource.
343340

0 commit comments

Comments
 (0)