Skip to content

Commit

Permalink
fix: policy bundles now use idx as resource name (bundles will be re-…
Browse files Browse the repository at this point in the history
…applied) (#1657)
  • Loading branch information
apeabody authored Jun 2, 2023
1 parent 044968d commit e51804e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions modules/acm/creds.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ resource "tls_private_key" "k8sop_creds" {
rsa_bits = 4096
}

# Wait for the ACM operator to create the namespace
# Wait for ACM
resource "time_sleep" "wait_acm" {
count = (var.create_ssh_key == true || var.ssh_auth_key != null || var.enable_policy_controller || var.enable_config_sync) ? 1 : 0
depends_on = [google_gke_hub_feature_membership.main]

create_duration = "300s"
create_duration = (length(var.policy_bundles) > 0) ? "600s" : "300s"
}

resource "google_service_account_iam_binding" "ksa_iam" {
Expand Down
7 changes: 4 additions & 3 deletions modules/acm/policy_bundles.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ module "policy_bundles" {
source = "terraform-google-modules/gcloud/google//modules/kubectl-wrapper"
version = "~> 3.1"

for_each = toset(var.policy_bundles)
# Use index as name to avoid long url or special filesystem chars
for_each = { for i, v in var.policy_bundles : i => v }
project_id = var.project_id
cluster_name = var.cluster_name
cluster_location = var.location
kubectl_create_command = "kubectl apply -k ${each.key}"
kubectl_destroy_command = "kubectl delete -k ${each.key}"
kubectl_create_command = "kubectl apply -k ${each.value}"
kubectl_destroy_command = "kubectl delete -k ${each.value}"

module_depends_on = [time_sleep.wait_acm]
}

0 comments on commit e51804e

Please sign in to comment.