Skip to content

Commit 3dd7fbd

Browse files
Add WireGroup Resource
1 parent e5e629b commit 3dd7fbd

File tree

3 files changed

+356
-0
lines changed

3 files changed

+356
-0
lines changed
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
# Copyright 2024 Google Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
---
15+
name: 'WireGroup'
16+
kind: 'compute#wireGroup'
17+
description: |
18+
The WireGroup resource represents a group of redundant wires between interconnects in two different metros. Each WireGroup belongs to a CrossSiteNetwork. A wire group defines endpoints and the wires which exist between them.
19+
20+
references:
21+
guides:
22+
'Create a WireGroup': 'https://cloud.google.com/network-connectivity/docs/interconnect/how-to/cross-site/modify-network#add-wire-group'
23+
api: 'https://cloud.google.com/compute/docs/reference/rest/beta/wireGroups'
24+
min_version: beta
25+
docs:
26+
id_format: 'projects/{{project}}/global/crossSiteNetworks/{{cross_site_network}}/wireGroups/{{name}}'
27+
base_url: 'projects/{{project}}/global/crossSiteNetworks/{{cross_site_network}}/wireGroups'
28+
self_link: 'projects/{{project}}/global/crossSiteNetworks/{{cross_site_network}}/wireGroups/{{name}}'
29+
update_verb: 'PATCH'
30+
update_mask: true
31+
import_format:
32+
- 'projects/{{project}}/global/crossSiteNetworks/{{cross_site_network}}/wireGroups/{{name}}'
33+
timeouts:
34+
insert_minutes: 20
35+
update_minutes: 20
36+
delete_minutes: 20
37+
async:
38+
actions: ['create', 'delete', 'update']
39+
type: 'OpAsync'
40+
operation:
41+
base_url: '{{op_id}}'
42+
result:
43+
resource_inside_response: false
44+
examples:
45+
- name: 'compute_wire_group_basic'
46+
primary_resource_id: 'example-test-wire-group'
47+
vars:
48+
name: 'test-wire-group'
49+
description: 'Example Wire Group'
50+
cross_site_network: 'test-cross-site-network'
51+
min_version: 'beta'
52+
test_env_vars:
53+
project: 'PROJECT_NAME'
54+
parameters:
55+
- name: 'crossSiteNetwork'
56+
type: ResourceRef
57+
description: Required cross site network to which wire group belongs.
58+
required: true
59+
immutable: true
60+
url_param_only: true
61+
resource: 'CrossSiteNetwork'
62+
imports: 'name'
63+
diff_suppress_func: 'tpgresource.CompareResourceNames'
64+
custom_expand: 'templates/terraform/custom_expand/resourceref_with_validation.go.tmpl'
65+
min_version: beta
66+
properties:
67+
- name: 'description'
68+
type: String
69+
description: |
70+
An optional description of this resource. Provide this property when you create the resource.
71+
- name: 'creationTimestamp'
72+
type: Time
73+
description: |
74+
Creation timestamp in RFC3339 text format.
75+
output: true
76+
- name: 'name'
77+
type: String
78+
description: |
79+
Name of the resource. Provided by the client when the resource is created. The name must be
80+
1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters
81+
long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first
82+
character must be a lowercase letter, and all following characters must be a dash,
83+
lowercase letter, or digit, except the last character, which cannot be a dash.
84+
required: true
85+
validation:
86+
regex: '^[a-z]([-a-z0-9]*[a-z0-9])?$'
87+
- name: endpoints
88+
type: Map
89+
description: |
90+
Endpoints grouped by location, each mapping to interconnect configurations.
91+
key_name: 'endpoint'
92+
key_description: |
93+
The name of the endpoint, which is a city name.
94+
value_type:
95+
type: NestedObject
96+
properties:
97+
- name: interconnects
98+
type: Map
99+
key_name: interconnect_name
100+
key_description: |
101+
The name of the interconnect.
102+
value_type:
103+
type: NestedObject
104+
description: |
105+
Map of interconnect details.
106+
properties:
107+
- name: interconnect
108+
type: string
109+
- name: vlan_tags
110+
type: Array
111+
description: |
112+
VLAN tags for the interconnect.
113+
item_type:
114+
type: Integer
115+
- name: adminEnabled
116+
type: Boolean
117+
description: |
118+
Indicates whether the wire group is administratively enabled.
119+
default_value: true
120+
- name: wireGroupProperties
121+
type: NestedObject
122+
description: |
123+
Properties specific to the wire group.
124+
properties:
125+
- name: type
126+
type: enum
127+
description: |
128+
Type of wire group (enum).
129+
WIRE: a single pseudowire over two Interconnect connections with no redundancy.
130+
REDUNDANT: two pseudowires over four Interconnect connections, with two connections in one metro and two connections in another metro.
131+
BOX_AND_CROSS: four pseudowires over four Interconnect connections, with two connections in one metro and two connections in another metro.
132+
enum_values:
133+
- 'WIRE'
134+
- 'REDUNDANT'
135+
- 'BOX_AND_CROSS'
136+
- name: wireProperties
137+
type: NestedObject
138+
description: |
139+
Default properties for wires within the group.
140+
properties:
141+
- name: bandwidthUnmetered
142+
type: Integer
143+
description: |
144+
The unmetered bandwidth setting.
145+
- name: faultResponse
146+
type: enum
147+
description: |
148+
Response when a fault is detected in a pseudowire:
149+
NONE: default.
150+
DISABLE_PORT: set the port line protocol down when inline probes detect a fault. This setting is only permitted on port mode pseudowires.
151+
enum_values:
152+
- 'NONE'
153+
- 'DISABLE_PORT'
154+
- name: wires
155+
type: Array
156+
description: |
157+
The single/redundant wire(s) managed by the wire group.
158+
output: true
159+
item_type:
160+
type: NestedObject
161+
properties:
162+
- name: label
163+
type: string
164+
output: true
165+
- name: endpoints
166+
type: Array
167+
output: true
168+
description: |
169+
'Wire endpoints are specific Interconnect connections.'
170+
item_type:
171+
type: NestedObject
172+
properties:
173+
- name: interconnect
174+
type: string
175+
output: true
176+
- name: vlanTag
177+
type: Integer
178+
output: true
179+
- name: wireProperties
180+
type: NestedObject
181+
output: true
182+
properties:
183+
- name: bandwidthUnmetered
184+
type: Integer
185+
output: true
186+
- name: faultResponse
187+
type: enum
188+
output: true
189+
enum_values:
190+
- 'NONE'
191+
- 'DISABLE_PORT'
192+
- name: adminEnabled
193+
type: Boolean
194+
output: true
195+
- name: topology
196+
type: NestedObject
197+
description: |
198+
Topology details for the wire group configuration.
199+
output: true
200+
properties:
201+
- name: endpoints
202+
type: Array
203+
output: true
204+
item_type:
205+
type: NestedObject
206+
properties:
207+
- name: label
208+
type: string
209+
output: true
210+
- name: city
211+
type: string
212+
output: true
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
data "google_project" "project" {
2+
provider = google-beta
3+
}
4+
5+
resource "google_compute_cross_site_network" "example-cross-site-network" {
6+
name = "{{index $.Vars "cross_site_network"}}"
7+
description = "Example cross site network"
8+
provider = google-beta
9+
}
10+
11+
resource "google_compute_wire_group" "{{$.PrimaryResourceId}}" {
12+
name = "{{index $.Vars "name"}}"
13+
description = "{{index $.Vars "description"}}"
14+
cross_site_network = "{{index $.Vars "cross_site_network"}}"
15+
provider = google-beta
16+
depends_on = [
17+
google_compute_cross_site_network.example-cross-site-network
18+
]
19+
wire_properties {
20+
bandwidth_unmetered = 10
21+
fault_response = "NONE"
22+
}
23+
wire_group_properties {
24+
type = "WIRE"
25+
}
26+
admin_enabled = true
27+
}
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
package compute_test
2+
{{ if ne $.TargetVersionName `ga` -}}
3+
import (
4+
"testing"
5+
6+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
7+
"github.com/hashicorp/terraform-plugin-testing/plancheck"
8+
9+
"github.com/hashicorp/terraform-provider-google/google/acctest"
10+
"github.com/hashicorp/terraform-provider-google/google/envvar"
11+
)
12+
13+
func TestAccComputeWireGroup_update(t *testing.T) {
14+
t.Parallel()
15+
16+
context := map[string]interface{}{
17+
"project": envvar.GetTestProjectFromEnv(),
18+
"random_suffix": acctest.RandString(t, 10),
19+
}
20+
21+
acctest.VcrTest(t, resource.TestCase{
22+
PreCheck: func() { acctest.AccTestPreCheck(t) },
23+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
24+
CheckDestroy: testAccCheckComputeWireGroupDestroyProducer(t),
25+
Steps: []resource.TestStep{
26+
{
27+
Config: testAccComputeWireGroup_basic(context),
28+
},
29+
{
30+
ResourceName: "google_compute_wire_group.example-test-wire-group",
31+
ImportState: true,
32+
ImportStateVerify: true,
33+
ImportStateVerifyIgnore: []string{"cross_site_network"},
34+
},
35+
{
36+
Config: testAccComputeWireGroup_update(context),
37+
ConfigPlanChecks: resource.ConfigPlanChecks{
38+
PreApply: []plancheck.PlanCheck{
39+
plancheck.ExpectResourceAction("google_compute_wire_group.example-test-wire-group", plancheck.ResourceActionUpdate),
40+
},
41+
},
42+
Check: resource.ComposeTestCheckFunc(
43+
resource.TestCheckResourceAttr("google_compute_wire_group.example-test-wire-group", "description", "Example Wire Group Updated"+context["random_suffix"].(string)),
44+
),
45+
},
46+
{
47+
ResourceName: "google_compute_wire_group.example-test-wire-group",
48+
ImportState: true,
49+
ImportStateVerify: true,
50+
ImportStateVerifyIgnore: []string{"cross_site_network"},
51+
},
52+
},
53+
})
54+
}
55+
56+
func testAccComputeWireGroup_basic(context map[string]interface{}) string {
57+
return acctest.Nprintf(`
58+
data "google_project" "project" {
59+
provider = google-beta
60+
}
61+
62+
resource "google_compute_cross_site_network" "example-cross-site-network" {
63+
name = "tf-test-cross-site-network%{random_suffix}"
64+
description = "Example cross site network"
65+
provider = google-beta
66+
}
67+
68+
resource "google_compute_wire_group" "example-test-wire-group" {
69+
name = "tf-test-test-wire-group%{random_suffix}"
70+
description = "Example Wire Group%{random_suffix}"
71+
cross_site_network = google_compute_cross_site_network.example-cross-site-network.name
72+
provider = google-beta
73+
depends_on = [
74+
google_compute_cross_site_network.example-cross-site-network
75+
]
76+
wire_properties {
77+
bandwidth_unmetered = 1000
78+
}
79+
wire_group_properties {
80+
type = "REDUNDANT"
81+
}
82+
admin_enabled = true
83+
}
84+
`, context)
85+
}
86+
87+
func testAccComputeWireGroup_update(context map[string]interface{}) string {
88+
return acctest.Nprintf(`
89+
data "google_project" "project" {
90+
provider = google-beta
91+
}
92+
93+
resource "google_compute_cross_site_network" "example-cross-site-network" {
94+
name = "tf-test-cross-site-network%{random_suffix}"
95+
description = "Example cross site network"
96+
provider = google-beta
97+
}
98+
99+
resource "google_compute_wire_group" "example-test-wire-group" {
100+
name = "tf-test-test-wire-group%{random_suffix}"
101+
description = "Example Wire Group Updated%{random_suffix}"
102+
cross_site_network = google_compute_cross_site_network.example-cross-site-network.name
103+
provider = google-beta
104+
depends_on = [
105+
google_compute_cross_site_network.example-cross-site-network
106+
]
107+
wire_properties {
108+
bandwidth_unmetered = 1000
109+
}
110+
wire_group_properties {
111+
type = "REDUNDANT"
112+
}
113+
admin_enabled = true
114+
}
115+
`, context)
116+
}
117+
{{- end }}

0 commit comments

Comments
 (0)