Skip to content

Commit

Permalink
feat(TPG>=5.6)!: use hub membership location for output (terraform-go…
Browse files Browse the repository at this point in the history
  • Loading branch information
apeabody committed Dec 26, 2023
1 parent dd53d92 commit 0c64be5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
4 changes: 3 additions & 1 deletion modules/fleet-membership/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2018 Google LLC
* Copyright 2018-2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,6 +18,8 @@ locals {
hub_project_id = var.hub_project_id == "" ? var.project_id : var.hub_project_id
gke_hub_membership_name_complete = var.membership_name != "" ? var.membership_name : "${var.project_id}-${var.location}-${var.cluster_name}"
gke_hub_membership_name = trimsuffix(substr(local.gke_hub_membership_name_complete, 0, 63), "-")
gke_hub_membership_location = regex(local.gke_hub_membership_location_re, data.google_container_cluster.primary.fleet[0].membership)[0]
gke_hub_membership_location_re = "//gkehub.googleapis.com/projects/[^/]*/locations/([^/]*)/memberships/[^/]*$"
}

# Retrieve GKE cluster info
Expand Down
3 changes: 1 addition & 2 deletions modules/fleet-membership/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ output "project_id" {
}

output "location" {
# TODO: google_gke_hub_membership b/300473592
description = "The location of the hub membership."
value = "global"
value = var.enable_fleet_registration ? google_gke_hub_membership.primary[0].location : local.gke_hub_membership_location
}
10 changes: 4 additions & 6 deletions modules/fleet-membership/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ terraform {

required_providers {
google = {
source = "hashicorp/google"
# Avoid v4.49 and v4.50 for https://github.com/hashicorp/terraform-provider-google/issues/13507
version = ">= 4.47.0, != 4.49.0, != 4.50.0, < 6"
source = "hashicorp/google"
version = ">= 5.6.0, < 6"
}
google-beta = {
source = "hashicorp/google-beta"
# Avoid v4.49 and v4.50 for https://github.com/hashicorp/terraform-provider-google/issues/13507
version = ">= 4.47.0, != 4.49.0, != 4.50.0, < 6"
source = "hashicorp/google-beta"
version = ">= 5.6.0, < 6"
}
}

Expand Down

0 comments on commit 0c64be5

Please sign in to comment.