Skip to content

Instantly share code, notes, and snippets.

@dale-c-anderson
Created September 6, 2024 20:27
Show Gist options
  • Save dale-c-anderson/2ca18ff466919edbb5e7399f4ee510fa to your computer and use it in GitHub Desktop.
Save dale-c-anderson/2ca18ff466919edbb5e7399f4ee510fa to your computer and use it in GitHub Desktop.
GKE IAM setup for External DNS
# For accessing properites defined in my default `google` terraform provider.
data google_project current {}
# Create a google service account
resource google_service_account "external-dns" {
account_id = "gke-external-dns-manager"
display_name = "Cluster-controlled DNS management"
}
# Bind the ExternalDNS Service Account to the DNS admin role
resource google_project_iam_member "external-dns" {
project = data.google_project.current.project_id
role = "roles/dns.admin"
member = "serviceAccount:${google_service_account.external-dns.email}"
}
# Link the ExternalDNS GSA to the Kubernetes service account (KSA) that
# external-dns will run under, i.e., the 'external-dns' KSA in the 'external-dns' namespace.
resource google_service_account_iam_member "external-dns" {
service_account_id = google_service_account.external-dns.name
role = "roles/iam.workloadIdentityUser"
member = "serviceAccount:${data.google_project.current.project_id}.svc.id.goog[external-dns/external-dns]"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment