Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ resource "google_cloudfunctions2_function" "function" {
labels = var.labels != null ? var.labels : {}
}

// IAM for invoking HTTP functions (roles/cloudfunctions.invoker)
// IAM for invoking HTTP functions (roles/run.invoker)
resource "google_cloudfunctions2_function_iam_member" "invokers" {
for_each = toset(contains(keys(var.members), "invokers") ? var.members["invokers"] : [])
location = google_cloudfunctions2_function.function.location
Expand All @@ -140,7 +140,7 @@ resource "google_cloudfunctions2_function_iam_member" "invokers" {
]
}

// Read and write access to all functions-related resources (roles/cloudfunctions.developer)
// Read and write access to all functions-related resources (roles/run.developer)
resource "google_cloudfunctions2_function_iam_member" "developers" {
for_each = toset(contains(keys(var.members), "developers") ? var.members["developers"] : [])
location = google_cloudfunctions2_function.function.location
Expand All @@ -153,3 +153,31 @@ resource "google_cloudfunctions2_function_iam_member" "developers" {
google_cloudfunctions2_function.function
]
}

// IAM for invoking HTTP functions (roles/run.invoker)
resource "google_cloud_run_service_iam_member" "invokers" {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to grant both google_cloudfunctions2_function_iam_member and google_cloud_run_service_iam_member?

@prabhu34 prabhu34 Apr 5, 2024

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bharathkkb Not necessarily. I thought this could be affecting existing users and left both of them. Previous comment.

for_each = toset(contains(keys(var.members), "invokers") ? var.members["invokers"] : [])
location = google_cloudfunctions2_function.function.location
project = google_cloudfunctions2_function.function.project
service = google_cloudfunctions2_function.function.name
role = "roles/run.invoker"
member = each.value

depends_on = [
google_cloudfunctions2_function.function
]
}

// Read and write access to all functions-related resources (roles/run.developer)
resource "google_cloud_run_service_iam_member" "developers" {
for_each = toset(contains(keys(var.members), "developers") ? var.members["developers"] : [])
location = google_cloudfunctions2_function.function.location
project = google_cloudfunctions2_function.function.project
service = google_cloudfunctions2_function.function.name
role = "roles/run.developer"
member = each.value

depends_on = [
google_cloudfunctions2_function.function
]
}