Skip to content

Commit

Permalink
Revert the promotion of Port Mapping NEGs from GA to Beta (GoogleClou…
Browse files Browse the repository at this point in the history
…dPlatform#11854)

Co-authored-by: Stephen Lewis (Burrows) <[email protected]>
  • Loading branch information
2 people authored and BBBmau committed Oct 24, 2024
1 parent 3533631 commit 9279baf
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 1 deletion.
3 changes: 3 additions & 0 deletions mmv1/products/compute/RegionNetworkEndpoint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ examples:
network_name: 'network'
- name: 'region_network_endpoint_portmap'
primary_resource_id: 'region_network_endpoint_portmap'
min_version: 'beta'
vars:
network_name: 'network'
subnetwork_name: 'subnetwork'
Expand Down Expand Up @@ -139,6 +140,7 @@ properties:
type: Integer
description: |
Client destination port for the `GCE_VM_IP_PORTMAP` NEG.
min_version: 'beta'
custom_flatten: 'templates/terraform/custom_flatten/float64_to_int.go.tmpl'
- name: 'instance'
type: ResourceRef
Expand All @@ -147,3 +149,4 @@ properties:
This is required for network endpoints of type GCE_VM_IP_PORTMAP.
resource: 'Instance'
imports: 'name'
min_version: 'beta'
1 change: 1 addition & 0 deletions mmv1/products/compute/RegionNetworkEndpointGroup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ examples:
network_name: 'network'
- name: 'region_network_endpoint_group_portmap'
primary_resource_id: 'region_network_endpoint_group_portmap'
min_version: 'beta'
vars:
network_name: 'network'
subnetwork_name: 'subnetwork'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ resource "google_compute_region_network_endpoint_group" "{{$.PrimaryResourceId}}
subnetwork = google_compute_subnetwork.default.id

network_endpoint_type = "GCE_VM_IP_PORTMAP"
provider = google-beta
}

resource "google_compute_network" "default" {
name = "{{index $.Vars "network_name"}}"
provider = google-beta
}

resource "google_compute_subnetwork" "default" {
name = "{{index $.Vars "subnetwork_name"}}"
ip_cidr_range = "10.0.0.0/16"
region = "us-central1"
network = google_compute_network.default.id
provider = google-beta
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
resource "google_compute_network" "default" {
name = "{{index $.Vars "network_name"}}"
auto_create_subnetworks = false
provider = google-beta
}

resource "google_compute_subnetwork" "default" {
name = "{{index $.Vars "subnetwork_name"}}"
ip_cidr_range = "10.0.0.0/16"
region = "us-central1"
network = google_compute_network.default.id
provider = google-beta
}

resource "google_compute_region_network_endpoint_group" default {
Expand All @@ -17,6 +19,7 @@ resource "google_compute_region_network_endpoint_group" default {
subnetwork = google_compute_subnetwork.default.id

network_endpoint_type = "GCE_VM_IP_PORTMAP"
provider = google-beta
}

resource "google_compute_region_network_endpoint" "{{$.PrimaryResourceId}}" {
Expand All @@ -26,11 +29,13 @@ resource "google_compute_region_network_endpoint" "{{$.PrimaryResourceId}}" {
port = 80
ip_address = google_compute_instance.default.network_interface[0].network_ip
client_destination_port = 8080
provider = google-beta
}

data "google_compute_image" "my_image" {
family = "debian-11"
project = "debian-cloud"
provider = google-beta
}

resource "google_compute_instance" "default" {
Expand All @@ -49,4 +54,5 @@ resource "google_compute_instance" "default" {
access_config {
}
}
provider = google-beta
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ if fqdnProp != "" {
toDelete["fqdn"] = fqdnProp
}

{{- if ne $.TargetVersionName "ga" }}
// Instance
instanceProp, err := expandNestedComputeRegionNetworkEndpointInstance(d.Get("instance"), d, config)
if err != nil {
Expand All @@ -44,6 +45,7 @@ if err != nil {
if clientDestinationPortProp != "" && d.Get("client_destination_port").(int) > 0 {
toDelete["clientDestinationPort"] = clientDestinationPortProp
}
{{- end }}

obj = map[string]interface{}{
"networkEndpoints": []map[string]interface{}{toDelete},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ resource "google_compute_region_network_endpoint" "add2" {
`, context) + testAccComputeRegionNetworkEndpoint_noRegionNetworkEndpoints(context)
}

{{- if ne $.TargetVersionName "ga" }}

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

Expand All @@ -155,7 +157,7 @@ func TestAccComputeRegionNetworkEndpoint_regionNetworkEndpointPortmapExample(t *

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
Steps: []resource.TestStep{
{
Config: testAccComputeRegionNetworkEndpoint_regionNetworkEndpointPortmapExample(context),
Expand All @@ -182,13 +184,15 @@ func testAccComputeRegionNetworkEndpoint_regionNetworkEndpointPortmapNoEndpointE
resource "google_compute_network" "default" {
name = "network%{random_suffix}"
auto_create_subnetworks = false
provider = google-beta
}

resource "google_compute_subnetwork" "default" {
name = "subnetwork%{random_suffix}"
ip_cidr_range = "10.0.0.0/16"
region = "us-central1"
network = google_compute_network.default.id
provider = google-beta
}

resource "google_compute_region_network_endpoint_group" default {
Expand All @@ -198,11 +202,13 @@ resource "google_compute_region_network_endpoint_group" default {
subnetwork = google_compute_subnetwork.default.id

network_endpoint_type = "GCE_VM_IP_PORTMAP"
provider = google-beta
}

data "google_compute_image" "my_image" {
family = "debian-11"
project = "debian-cloud"
provider = google-beta
}

resource "google_compute_instance" "default" {
Expand All @@ -221,6 +227,7 @@ resource "google_compute_instance" "default" {
access_config {
}
}
provider = google-beta
}
`, context)
}
Expand All @@ -234,9 +241,11 @@ resource "google_compute_region_network_endpoint" "region_network_endpoint_portm
port = 80
ip_address = google_compute_instance.default.network_interface[0].network_ip
client_destination_port = 8080
provider = google-beta
}
`, context) + testAccComputeRegionNetworkEndpoint_regionNetworkEndpointPortmapNoEndpointExample(context)
}
{{- end }}

func testAccComputeRegionNetworkEndpoint_noRegionNetworkEndpoints(context map[string]interface{}) string {
return acctest.Nprintf(`
Expand Down

0 comments on commit 9279baf

Please sign in to comment.