Skip to content

Commit 13e79af

Browse files
authored
feat(TPG>=5.6)!: use hub membership location for output (#1824)
1 parent 0d7f638 commit 13e79af

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

modules/fleet-membership/main.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2018 Google LLC
2+
* Copyright 2018-2023 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,6 +18,8 @@ locals {
1818
hub_project_id = var.hub_project_id == "" ? var.project_id : var.hub_project_id
1919
gke_hub_membership_name_complete = var.membership_name != "" ? var.membership_name : "${var.project_id}-${var.location}-${var.cluster_name}"
2020
gke_hub_membership_name = trimsuffix(substr(local.gke_hub_membership_name_complete, 0, 63), "-")
21+
gke_hub_membership_location = regex(local.gke_hub_membership_location_re, data.google_container_cluster.primary.fleet[0].membership)[0]
22+
gke_hub_membership_location_re = "//gkehub.googleapis.com/projects/[^/]*/locations/([^/]*)/memberships/[^/]*$"
2123
}
2224

2325
# Retrieve GKE cluster info

modules/fleet-membership/outputs.tf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ output "project_id" {
3030
}
3131

3232
output "location" {
33-
# TODO: google_gke_hub_membership b/300473592
3433
description = "The location of the hub membership."
35-
value = "global"
34+
value = var.enable_fleet_registration ? google_gke_hub_membership.primary[0].location : local.gke_hub_membership_location
3635
}

modules/fleet-membership/versions.tf

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@ terraform {
2020

2121
required_providers {
2222
google = {
23-
source = "hashicorp/google"
24-
# Avoid v4.49 and v4.50 for https://github.com/hashicorp/terraform-provider-google/issues/13507
25-
version = ">= 4.47.0, != 4.49.0, != 4.50.0, < 6"
23+
source = "hashicorp/google"
24+
version = ">= 5.6.0, < 6"
2625
}
2726
google-beta = {
28-
source = "hashicorp/google-beta"
29-
# Avoid v4.49 and v4.50 for https://github.com/hashicorp/terraform-provider-google/issues/13507
30-
version = ">= 4.47.0, != 4.49.0, != 4.50.0, < 6"
27+
source = "hashicorp/google-beta"
28+
version = ">= 5.6.0, < 6"
3129
}
3230
}
3331

0 commit comments

Comments
 (0)