Skip to content

feat(compute): support self_link input for google_compute_network data source#17393

Merged
trodge merged 2 commits into
GoogleCloudPlatform:mainfrom
raman1236:feat/compute-network-self-link-input
May 21, 2026
Merged

feat(compute): support self_link input for google_compute_network data source#17393
trodge merged 2 commits into
GoogleCloudPlatform:mainfrom
raman1236:feat/compute-network-self-link-input

Conversation

@raman1236

@raman1236 raman1236 commented May 1, 2026

Copy link
Copy Markdown
Contributor

Description

The data_source_google_compute_network data source previously only supported looking up a network by its short name. This meant users who had a self_link (e.g. from another resource output or from an import) had to manually extract the name before using the data source.

This change updates the data source to detect when the name field is a self_link and extract the name from it, using the same logic as the existing CompareSelfLinkOrResourceName diff-suppress function.

Bug

Fixes hashicorp/terraform-provider-google#7863

Tests

Includes unit tests for self_link parsing (full URL, partial path, beta API).

Files changed

  • mmv1/third_party/terraform/services/compute/data_source_google_compute_network.go
  • mmv1/third_party/terraform/services/compute/data_source_google_compute_network_internal_test.go (new)
google_compute_network: added support in the datasource for looking up a network by `self_link` in addition to `name`

…a source

The `google_compute_network` data source previously required `name`
to look up a network. This adds support for looking up a network by
`self_link`, which is useful when you have a self_link from another
resource and want to look up network details without parsing the name.

Changes:
- `name` is now Optional+Computed (was Required)
- `self_link` is now Optional+Computed (was Computed only)
- `project` is now Computed in addition to Optional
- Read function parses project and name from self_link when provided
- Validates that either `name` or `self_link` is provided

Includes unit tests for self_link parsing.

Fixes hashicorp/terraform-provider-google#7863
@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown

Googlers: For automatic test runs see go/terraform-auto-test-runs.

@trodge, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look.

You can help make sure that review is quick by doing a self-review and by running impacted tests locally.

@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown

@trodge This PR has been waiting for review for 3 weekdays. Please take a look! Use the label disable-review-reminders to disable these notifications.

@modular-magician modular-magician added service/compute-vpc and removed awaiting-approval Pull requests that need reviewer's approval to run presubmit tests labels May 7, 2026
@modular-magician

modular-magician commented May 7, 2026

Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes for commit b28207c:

Diff report

Your PR generated the following diffs in downstream repositories:

Repository Diff Link Changes
google provider View Diff 2 files changed, 122 insertions(+), 5 deletions(-)
google-beta provider View Diff 2 files changed, 122 insertions(+), 5 deletions(-)

Test report

Analytics

Total Tests Passed Skipped Affected
1433 1339 91 3
Affected Service Packages
  • compute

Learn how VCR tests work


Step 1: Replaying Mode

Action taken

Found 3 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccComputeInstanceFromTemplate_DiskForceAttach
  • TestAccComputeOrganizationSecurityPolicy_organizationSecurityPolicyWithAdvancedOptionsExample
  • TestAccComputeSecurityPolicyRule_securityPolicyRuleWithBodyExcludeExample

View the build log


Step 2: Recording Mode

Recording Mode Replaying Rerun Test Name
✅ Log TestAccComputeOrganizationSecurityPolicy_organizationSecurityPolicyWithAdvancedOptionsExample
❌ Error · Log - TestAccComputeInstanceFromTemplate_DiskForceAttach
❌ Error · Log - TestAccComputeSecurityPolicyRule_securityPolicyRuleWithBodyExcludeExample

Caution

Issues requiring attention before PR completion

🔴 Initial Recording Failed: Some tests failed during the recording step. See the table above for details.

Please address these issues to complete your PR. If you believe these detections are incorrect or unrelated to your change, please raise the concern with your reviewer.

View the build log or the debug logs folder for detailed results.

@raman1236, @trodge VCR tests complete for b28207c!

@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown

@GoogleCloudPlatform/terraform-team @trodge This PR has been waiting for review for 1 week. Please take a look! Use the label disable-review-reminders to disable these notifications.

@github-actions

Copy link
Copy Markdown

@GoogleCloudPlatform/terraform-team @trodge This PR has been waiting for review for 2 weeks. Please take a look! Use the label disable-review-reminders to disable these notifications.

@modular-magician modular-magician added awaiting-approval Pull requests that need reviewer's approval to run presubmit tests and removed awaiting-approval Pull requests that need reviewer's approval to run presubmit tests labels May 15, 2026
@modular-magician

modular-magician commented May 21, 2026

Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes for commit f3d6770:

Diff report

Your PR generated the following diffs in downstream repositories:

Repository Diff Link Changes
google provider View Diff 2 files changed, 122 insertions(+), 5 deletions(-)
google-beta provider View Diff 2 files changed, 122 insertions(+), 5 deletions(-)

Test report

Analytics

Total Tests Passed Skipped Affected
1456 1363 93 0
Affected Service Packages
  • compute

Learn how VCR tests work


Step 1: Replaying Mode

🟢 All tests passed in Replaying mode! No Recording was needed.

View the replaying VCR build log

@raman1236, @trodge VCR tests complete for f3d6770!

@trodge trodge added this pull request to the merge queue May 21, 2026
Merged via the queue into GoogleCloudPlatform:main with commit 4cb1b71 May 21, 2026
25 checks passed
MikolajLuczko pushed a commit to MikolajLuczko/magic-modules that referenced this pull request May 28, 2026
…a source (GoogleCloudPlatform#17393)

Co-authored-by: raman1236 <25852516+raman1236@users.noreply.github.com>
gitika-yadav pushed a commit to gitika-yadav/magic-modules that referenced this pull request Jun 10, 2026
…a source (GoogleCloudPlatform#17393)

Co-authored-by: raman1236 <25852516+raman1236@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support self_link as an input for google_compute_network data source

3 participants