Skip to content

Commit

Permalink
feat: add cross project fleet service agent
Browse files Browse the repository at this point in the history
  • Loading branch information
apeabody committed Mar 6, 2024
1 parent 79a8d68 commit 306abc7
Show file tree
Hide file tree
Showing 10 changed files with 140 additions and 0 deletions.
14 changes: 14 additions & 0 deletions autogen/main/sa.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,17 @@ resource "google_project_iam_member" "cluster_service_account-artifact-registry"
role = "roles/artifactregistry.reader"
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
}

resource "google_project_service_identity" "fleet_project" {
count = var.fleet_project != null || var.fleet_project != var.project_id ? 1 : 0
provider = google-beta
project = var.fleet_project
service = "gkehub.googleapis.com"
}

resource "google_project_iam_member" "cross_project_service_agent" {
for_each = var.fleet_project != null || var.fleet_project != var.project_id ? toset(["roles/gkehub.serviceAgent", "roles/gkehub.crossProjectServiceAgent"]) : []
project = var.fleet_project
role = each.value
member = "serviceAccount:${google_project_service_identity.fleet_project.email[0]}"
}
14 changes: 14 additions & 0 deletions modules/beta-autopilot-private-cluster/sa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,17 @@ resource "google_project_iam_member" "cluster_service_account-artifact-registry"
role = "roles/artifactregistry.reader"
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
}

resource "google_project_service_identity" "fleet_project" {
count = var.fleet_project != null || var.fleet_project != var.project_id ? 1 : 0
provider = google-beta
project = var.fleet_project
service = "gkehub.googleapis.com"
}

resource "google_project_iam_member" "cross_project_service_agent" {
for_each = var.fleet_project != null || var.fleet_project != var.project_id ? toset(["roles/gkehub.serviceAgent", "roles/gkehub.crossProjectServiceAgent"]) : []
project = var.fleet_project
role = each.value
member = "serviceAccount:${google_project_service_identity.fleet_project.email[0]}"
}
14 changes: 14 additions & 0 deletions modules/beta-autopilot-public-cluster/sa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,17 @@ resource "google_project_iam_member" "cluster_service_account-artifact-registry"
role = "roles/artifactregistry.reader"
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
}

resource "google_project_service_identity" "fleet_project" {
count = var.fleet_project != null || var.fleet_project != var.project_id ? 1 : 0
provider = google-beta
project = var.fleet_project
service = "gkehub.googleapis.com"
}

resource "google_project_iam_member" "cross_project_service_agent" {
for_each = var.fleet_project != null || var.fleet_project != var.project_id ? toset(["roles/gkehub.serviceAgent", "roles/gkehub.crossProjectServiceAgent"]) : []
project = var.fleet_project
role = each.value
member = "serviceAccount:${google_project_service_identity.fleet_project.email[0]}"
}
14 changes: 14 additions & 0 deletions modules/beta-private-cluster-update-variant/sa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,17 @@ resource "google_project_iam_member" "cluster_service_account-artifact-registry"
role = "roles/artifactregistry.reader"
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
}

resource "google_project_service_identity" "fleet_project" {
count = var.fleet_project != null || var.fleet_project != var.project_id ? 1 : 0
provider = google-beta
project = var.fleet_project
service = "gkehub.googleapis.com"
}

resource "google_project_iam_member" "cross_project_service_agent" {
for_each = var.fleet_project != null || var.fleet_project != var.project_id ? toset(["roles/gkehub.serviceAgent", "roles/gkehub.crossProjectServiceAgent"]) : []
project = var.fleet_project
role = each.value
member = "serviceAccount:${google_project_service_identity.fleet_project.email[0]}"
}
14 changes: 14 additions & 0 deletions modules/beta-private-cluster/sa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,17 @@ resource "google_project_iam_member" "cluster_service_account-artifact-registry"
role = "roles/artifactregistry.reader"
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
}

resource "google_project_service_identity" "fleet_project" {
count = var.fleet_project != null || var.fleet_project != var.project_id ? 1 : 0
provider = google-beta
project = var.fleet_project
service = "gkehub.googleapis.com"
}

resource "google_project_iam_member" "cross_project_service_agent" {
for_each = var.fleet_project != null || var.fleet_project != var.project_id ? toset(["roles/gkehub.serviceAgent", "roles/gkehub.crossProjectServiceAgent"]) : []
project = var.fleet_project
role = each.value
member = "serviceAccount:${google_project_service_identity.fleet_project.email[0]}"
}
14 changes: 14 additions & 0 deletions modules/beta-public-cluster-update-variant/sa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,17 @@ resource "google_project_iam_member" "cluster_service_account-artifact-registry"
role = "roles/artifactregistry.reader"
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
}

resource "google_project_service_identity" "fleet_project" {
count = var.fleet_project != null || var.fleet_project != var.project_id ? 1 : 0
provider = google-beta
project = var.fleet_project
service = "gkehub.googleapis.com"
}

resource "google_project_iam_member" "cross_project_service_agent" {
for_each = var.fleet_project != null || var.fleet_project != var.project_id ? toset(["roles/gkehub.serviceAgent", "roles/gkehub.crossProjectServiceAgent"]) : []
project = var.fleet_project
role = each.value
member = "serviceAccount:${google_project_service_identity.fleet_project.email[0]}"
}
14 changes: 14 additions & 0 deletions modules/beta-public-cluster/sa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,17 @@ resource "google_project_iam_member" "cluster_service_account-artifact-registry"
role = "roles/artifactregistry.reader"
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
}

resource "google_project_service_identity" "fleet_project" {
count = var.fleet_project != null || var.fleet_project != var.project_id ? 1 : 0
provider = google-beta
project = var.fleet_project
service = "gkehub.googleapis.com"
}

resource "google_project_iam_member" "cross_project_service_agent" {
for_each = var.fleet_project != null || var.fleet_project != var.project_id ? toset(["roles/gkehub.serviceAgent", "roles/gkehub.crossProjectServiceAgent"]) : []
project = var.fleet_project
role = each.value
member = "serviceAccount:${google_project_service_identity.fleet_project.email[0]}"
}
14 changes: 14 additions & 0 deletions modules/private-cluster-update-variant/sa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,17 @@ resource "google_project_iam_member" "cluster_service_account-artifact-registry"
role = "roles/artifactregistry.reader"
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
}

resource "google_project_service_identity" "fleet_project" {
count = var.fleet_project != null || var.fleet_project != var.project_id ? 1 : 0
provider = google-beta
project = var.fleet_project
service = "gkehub.googleapis.com"
}

resource "google_project_iam_member" "cross_project_service_agent" {
for_each = var.fleet_project != null || var.fleet_project != var.project_id ? toset(["roles/gkehub.serviceAgent", "roles/gkehub.crossProjectServiceAgent"]) : []
project = var.fleet_project
role = each.value
member = "serviceAccount:${google_project_service_identity.fleet_project.email[0]}"
}
14 changes: 14 additions & 0 deletions modules/private-cluster/sa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,17 @@ resource "google_project_iam_member" "cluster_service_account-artifact-registry"
role = "roles/artifactregistry.reader"
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
}

resource "google_project_service_identity" "fleet_project" {
count = var.fleet_project != null || var.fleet_project != var.project_id ? 1 : 0
provider = google-beta
project = var.fleet_project
service = "gkehub.googleapis.com"
}

resource "google_project_iam_member" "cross_project_service_agent" {
for_each = var.fleet_project != null || var.fleet_project != var.project_id ? toset(["roles/gkehub.serviceAgent", "roles/gkehub.crossProjectServiceAgent"]) : []
project = var.fleet_project
role = each.value
member = "serviceAccount:${google_project_service_identity.fleet_project.email[0]}"
}
14 changes: 14 additions & 0 deletions sa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,17 @@ resource "google_project_iam_member" "cluster_service_account-artifact-registry"
role = "roles/artifactregistry.reader"
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
}

resource "google_project_service_identity" "fleet_project" {
count = var.fleet_project != null || var.fleet_project != var.project_id ? 1 : 0
provider = google-beta
project = var.fleet_project
service = "gkehub.googleapis.com"
}

resource "google_project_iam_member" "cross_project_service_agent" {
for_each = var.fleet_project != null || var.fleet_project != var.project_id ? toset(["roles/gkehub.serviceAgent", "roles/gkehub.crossProjectServiceAgent"]) : []
project = var.fleet_project
role = each.value
member = "serviceAccount:${google_project_service_identity.fleet_project.email[0]}"
}

0 comments on commit 306abc7

Please sign in to comment.