Skip to content

Commit 08b87d4

Browse files
Fix target_server validation for service attachment (#14195) (#23243)
[upstream:a2335a05eb5feae5df981c54e94e9cca82ef0230] Signed-off-by: Modular Magician <[email protected]>
1 parent c304ee0 commit 08b87d4

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

.changelog/14195.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
compute: fixed validation for `target_service` in `google_compute_service_attachment`
3+
```

google/services/compute/resource_compute_service_attachment.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -891,12 +891,13 @@ func expandComputeServiceAttachmentConnectionPreference(v interface{}, d tpgreso
891891

892892
func expandComputeServiceAttachmentTargetService(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
893893
resource := strings.Split(v.(string), "/")
894-
resourceKind := resource[len(resource)-2]
895-
resourceBound := resource[len(resource)-4]
896894
if len(resource) < 4 {
897895
return nil, fmt.Errorf("invalid value for target_service")
898896
}
899897

898+
resourceKind := resource[len(resource)-2]
899+
resourceBound := resource[len(resource)-4]
900+
900901
_, err := tpgresource.ParseRegionalFieldValue(resourceKind, v.(string), "project", resourceBound, "zone", d, config, true)
901902
if err != nil {
902903
return nil, fmt.Errorf("invalid value for target_service: %w", err)

0 commit comments

Comments
 (0)