-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add Terraform Support for WireGroups. #13944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
NickElliot
merged 23 commits into
GoogleCloudPlatform:main
from
NandiniAgrawal15:test-wire
Jun 9, 2025
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
4cfc0c4
this is for testing purpose
NandiniAgrawal15 573771d
Revert not required changes.
NandiniAgrawal15 3a19d4c
testing changes
NandiniAgrawal15 4617a3d
Merge remote-tracking branch 'upstream/main'
NandiniAgrawal15 34f0e81
Testing changes
NandiniAgrawal15 15dcea3
Cross-Site Network
NandiniAgrawal15 c5ca6a0
Merge branch 'GoogleCloudPlatform:main' into main
NandiniAgrawal15 8cbc84e
Nit Changes.
NandiniAgrawal15 da83ea7
Add Terraform Support for WireGroups.
NandiniAgrawal15 93708f2
Nit Changes
NandiniAgrawal15 03e8416
Nit Changes1
NandiniAgrawal15 b581f9c
Removing the .tmpl extension from this File
NandiniAgrawal15 bdadc94
Change Type of bandwidth_unmetered to Integer
NandiniAgrawal15 dda2a26
Remove random_suffix from templates/terraform/examples/compute_wire_g…
NandiniAgrawal15 ec99768
Update mmv1/third_party/terraform/services/compute/resource_compute_w…
NandiniAgrawal15 84d80ce
Change the hard code to reference the vasr
NandiniAgrawal15 30605ca
Update mmv1/products/compute/WireGroup.yaml
NandiniAgrawal15 0702ee9
this is for testing purpose
NandiniAgrawal15 28d387d
Revert not required changes.
NandiniAgrawal15 91dca29
Testing changes
NandiniAgrawal15 9f6b851
Cross-Site Network
NandiniAgrawal15 9f33eb2
Change the snake_case name of the WireGroup
NandiniAgrawal15 4c08942
Merge branch 'main' into test-wire
NandiniAgrawal15 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,193 @@ | ||
| # Copyright 2024 Google Inc. | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| --- | ||
| name: 'WireGroup' | ||
| kind: 'compute#wireGroup' | ||
| description: | | ||
| 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. | ||
|
|
||
| references: | ||
| guides: | ||
| 'Create a WireGroup': 'https://cloud.google.com/network-connectivity/docs/interconnect/how-to/cross-site/modify-network#add-wire-group' | ||
| api: 'https://cloud.google.com/compute/docs/reference/rest/beta/wireGroups' | ||
| min_version: beta | ||
| docs: | ||
| id_format: 'projects/{{project}}/global/crossSiteNetworks/{{cross_site_network}}/wireGroups/{{name}}' | ||
| base_url: 'projects/{{project}}/global/crossSiteNetworks/{{cross_site_network}}/wireGroups' | ||
| self_link: 'projects/{{project}}/global/crossSiteNetworks/{{cross_site_network}}/wireGroups/{{name}}' | ||
| update_verb: 'PATCH' | ||
| update_mask: true | ||
| import_format: | ||
| - 'projects/{{project}}/global/crossSiteNetworks/{{cross_site_network}}/wireGroups/{{name}}' | ||
| timeouts: | ||
| insert_minutes: 20 | ||
| update_minutes: 20 | ||
| delete_minutes: 20 | ||
| async: | ||
| actions: ['create', 'delete', 'update'] | ||
| type: 'OpAsync' | ||
| operation: | ||
| base_url: '{{op_id}}' | ||
| result: | ||
| resource_inside_response: false | ||
| custom_code: | ||
| test_check_destroy: 'templates/terraform/custom_check_destroy/wire_group.go.tmpl' | ||
| examples: | ||
| - name: 'compute_wire_group_basic' | ||
| primary_resource_id: 'example-test-wire-group' | ||
| vars: | ||
| name: 'test-wire-group' | ||
| description: 'Example Wire Group' | ||
| cross_site_network: 'test-cross-site-network' | ||
| min_version: 'beta' | ||
| test_env_vars: | ||
| project: 'PROJECT_NAME' | ||
| parameters: | ||
| - name: 'crossSiteNetwork' | ||
| type: ResourceRef | ||
| description: Required cross site network to which wire group belongs. | ||
| required: true | ||
| immutable: true | ||
| url_param_only: true | ||
| resource: 'CrossSiteNetwork' | ||
| imports: 'name' | ||
| diff_suppress_func: 'tpgresource.CompareResourceNames' | ||
| custom_expand: 'templates/terraform/custom_expand/resourceref_with_validation.go.tmpl' | ||
| min_version: beta | ||
| properties: | ||
| - name: 'description' | ||
| type: String | ||
| description: | | ||
| An optional description of this resource. Provide this property when you create the resource. | ||
| - name: 'creationTimestamp' | ||
| type: Time | ||
| description: | | ||
| Creation timestamp in RFC3339 text format. | ||
| output: true | ||
| - name: 'name' | ||
| type: String | ||
| description: | | ||
| Name of the resource. Provided by the client when the resource is created. The name must be | ||
| 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters | ||
| long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first | ||
| character must be a lowercase letter, and all following characters must be a dash, | ||
| lowercase letter, or digit, except the last character, which cannot be a dash. | ||
| required: true | ||
| validation: | ||
| regex: '^[a-z]([-a-z0-9]*[a-z0-9])?$' | ||
| - name: endpoints | ||
| type: KeyValuePairs | ||
| description: | | ||
| Endpoints grouped by location, each mapping to interconnect configurations. | ||
| properties: | ||
| - name: interconnects | ||
| type: KeyValuePairs | ||
| description: | | ||
| Map of interconnect details. | ||
| properties: | ||
| - name: interconnect | ||
| type: string | ||
| - name: vlan_tags | ||
| type: Array | ||
| description: | | ||
| VLAN tags for the interconnect. | ||
| item_type: | ||
| type: integer | ||
| - name: adminEnabled | ||
| type: boolean | ||
| description: | | ||
| Indicates whether the wire group is administratively enabled. | ||
| - name: wireGroupProperties | ||
| type: NestedObject | ||
| description: | | ||
| Properties specific to the wire group. | ||
| properties: | ||
| - name: type | ||
| type: enum | ||
| description: | | ||
| Type of wire group (enum). | ||
| WIRE: a single pseudowire over two Interconnect connections with no redundancy. | ||
| REDUNDANT: two pseudowires over four Interconnect connections, with two connections in one metro and two connections in another metro. | ||
| BOX_AND_CROSS: four pseudowires over four Interconnect connections, with two connections in one metro and two connections in another metro. | ||
| enum_values: | ||
| - 'WIRE' | ||
| - 'REDUNDANT' | ||
| - 'BOX_AND_CROSS' | ||
| - name: wireProperties | ||
| type: NestedObject | ||
| description: | | ||
| Default properties for wires within the group. | ||
| properties: | ||
| - name: bandwidthUnmetered | ||
| type: Integer | ||
| description: | | ||
| The unmetered bandwidth setting. | ||
| - name: faultResponse | ||
| type: enum | ||
| description: | | ||
| Response when a fault is detected in a pseudowire: | ||
| NONE: default. | ||
| DISABLE_PORT: set the port line protocol down when inline probes detect a fault. This setting is only permitted on port mode pseudowires. | ||
| enum_values: | ||
| - 'NONE' | ||
| - 'DISABLE_PORT' | ||
| - name: wires | ||
| type: Array | ||
| description: | | ||
| The single/redundant wire(s) managed by the wire group. | ||
| output: true | ||
| item_type: | ||
| type: NestedObject | ||
| properties: | ||
| - name: label | ||
| type: string | ||
| - name: endpoints | ||
| type: Array | ||
| description: | | ||
| 'Wire endpoints are specific Interconnect connections.' | ||
| item_type: | ||
| type: NestedObject | ||
| properties: | ||
| - name: interconnect | ||
| type: string | ||
| - name: vlanTag | ||
| type: integer | ||
| - name: wireProperties | ||
| type: NestedObject | ||
| output: true # This is redundant if the parent 'wires' is output: true, but harmless | ||
| properties: | ||
| - name: bandwidthUnmetered | ||
| type: Integer | ||
| - name: faultResponse | ||
| type: enum | ||
| enum_values: | ||
| - 'NONE' | ||
| - 'DISABLE_PORT' | ||
| - name: adminEnabled | ||
| type: boolean | ||
| - name: topology | ||
| type: NestedObject | ||
| description: | | ||
| Topology details for the wire group configuration. | ||
| output: true | ||
| properties: | ||
| - name: endpoints | ||
| type: Array | ||
| item_type: | ||
| type: NestedObject | ||
| properties: | ||
| - name: label | ||
| type: string | ||
| - name: city | ||
| type: string | ||
23 changes: 23 additions & 0 deletions
23
mmv1/templates/terraform/custom_check_destroy/cross_site_network.go.tmpl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| config := acctest.GoogleProviderConfig(t) | ||
|
|
||
| url, err := tpgresource.ReplaceVarsForTest(config, rs, "{{"{{"}}ComputeBasePath{{"}}"}}projects/{{"{{"}}project{{"}}"}}/global/crossSiteNetworks") | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| billingProject := "" | ||
|
|
||
| if config.BillingProject != "" { | ||
| billingProject = config.BillingProject | ||
| } | ||
|
|
||
| _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ | ||
| Config: config, | ||
| Method: "GET", | ||
| Project: billingProject, | ||
| RawURL: url, | ||
| UserAgent: config.UserAgent, | ||
| }) | ||
| if err == nil { | ||
| return fmt.Errorf("ComputeCrossSiteNetwork still exists at %s", url) | ||
| } |
22 changes: 22 additions & 0 deletions
22
mmv1/templates/terraform/custom_check_destroy/wire_group.go.tmpl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| config := acctest.GoogleProviderConfig(t) | ||
| url, err := tpgresource.ReplaceVarsForTest(config, rs, "{{"{{"}}ComputeBasePath{{"}}"}}projects/{{"{{"}}project{{"}}"}}/global/crossSiteNetworks/{{"{{"}}cross_site_network{{"}}"}}/wireGroups/{{"{{"}}name{{"}}"}}") | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| billingProject := "" | ||
|
|
||
| if config.BillingProject != "" { | ||
| billingProject = config.BillingProject | ||
| } | ||
|
|
||
| _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ | ||
| Config: config, | ||
| Method: "GET", | ||
| Project: billingProject, | ||
| RawURL: url, | ||
| UserAgent: config.UserAgent, | ||
| }) | ||
| if err == nil { | ||
| return fmt.Errorf("ComputeWireGroup still exists at %s", url) | ||
| } |
48 changes: 48 additions & 0 deletions
48
mmv1/templates/terraform/custom_delete/cross_site_network.go.tmpl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
|
|
||
| billingProject := "" | ||
|
|
||
| project, err := tpgresource.GetProject(d, config) | ||
| if err != nil { | ||
| return fmt.Errorf("Error fetching project for CrossSiteNetwork: %s", err) | ||
| } | ||
| billingProject = project | ||
|
|
||
| url, err := tpgresource.ReplaceVars(d, config, "{{"{{"}}ComputeBasePath{{"}}"}}projects/{{"{{"}}project{{"}}"}}/global/crossSiteNetworks/{{"{{"}}crossSiteNetworks{{"}}"}}") | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| var obj map[string]interface{} | ||
|
|
||
| // err == nil indicates that the billing_project value was found | ||
| if bp, err := tpgresource.GetBillingProject(d, config); err == nil { | ||
| billingProject = bp | ||
| } | ||
|
|
||
| headers := make(http.Header) | ||
|
|
||
| log.Printf("[DEBUG] Deleting CrossSiteNetwork %q", d.Id()) | ||
| res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ | ||
| Config: config, | ||
| Method: "DELETE", | ||
| Project: billingProject, | ||
| RawURL: url, | ||
| UserAgent: userAgent, | ||
| Body: obj, | ||
| Timeout: d.Timeout(schema.TimeoutDelete), | ||
| Headers: headers, | ||
| }) | ||
| if err != nil { | ||
| return transport_tpg.HandleNotFoundError(err, d, "CrossSiteNetwork") | ||
| } | ||
|
|
||
| err = ComputeOperationWaitTime( | ||
| config, res, project, "Deleting CrossSiteNetwork", userAgent, | ||
| d.Timeout(schema.TimeoutDelete)) | ||
|
|
||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| log.Printf("[DEBUG] Finished deleting CrossSiteNetwork %q: %#v", d.Id(), res) | ||
| return nil |
25 changes: 25 additions & 0 deletions
25
mmv1/templates/terraform/examples/compute_wire_group_basic.tf.tmpl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| data "google_project" "project" { | ||
| provider = google-beta | ||
| } | ||
|
|
||
| resource "google_compute_cross_site_network" "example-cross-site-network" { | ||
| name = "{{index $.Vars "cross_site_network"}}" | ||
| description = "Example cross site network" | ||
| provider = google-beta | ||
| } | ||
|
|
||
| resource "google_compute_wire_group" "{{$.PrimaryResourceId}}" { | ||
| name = "{{index $.Vars "name"}}" | ||
| description = "{{index $.Vars "description"}}" | ||
| cross_site_network = "{{index $.Vars "cross_site_network"}}" | ||
| provider = google-beta | ||
| depends_on = [ | ||
| google_compute_cross_site_network.example-cross-site-network | ||
| ] | ||
| wire_properties { | ||
| bandwidth_unmetered = 10 | ||
| } | ||
| wire_group_properties { | ||
| type = "WIRE" | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.