Skip to content

Commit

Permalink
Add roles/cloudsql.client binding for the data project (#126)
Browse files Browse the repository at this point in the history
Requires a new module under data/ because:
* apps depends on data to exist for the Cloud SQL connection
* This new IAM binding in data requires apps to exist to know the service account

Co-authored-by: Martin Petkov <mpetkov@google.com>
  • Loading branch information
MartinPetkov and MartinPetkov committed Apr 14, 2020
1 parent 25eabc0 commit 2736151
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "service_account" {
value = module.heroes_hat_cluster.service_account
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
terraform {
backend "gcs" {}
}

resource "google_project_iam_member" "gke_sql_access" {
project = var.project_id
role = "roles/cloudsql.client"
member = var.gke_service_account
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
project_id = "heroes-hat-dev-data"
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
include {
path = find_in_parent_folders()
}

dependency "project" {
config_path = "../project"
skip_outputs = true
}

dependency "apps" {
config_path = "../../project.heroes-hat-dev-apps/apps"

mock_outputs = {
service_account = "mock-service-account"
}
}

inputs = {
gke_service_account = dependency.apps.outputs.service_account
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
variable "project_id" {
type = string
}

variable "gke_service_account" {
description = "The service account used by the GKE cluster"
type = string
}

0 comments on commit 2736151

Please sign in to comment.