Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions cloudrun/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ inputs:
description: "The ingress for this Service. Possible values are INGRESS_TRAFFIC_ALL, INGRESS_TRAFFIC_INTERNAL_ONLY, or INGRESS_TRAFFIC_INTERNAL_LOAD_BALANCER"

outputs:
http_endpoint:
type: string
description: "HTTP endpoint URL for service-to-service communication"
9 changes: 6 additions & 3 deletions cloudrun/module/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,14 @@ resource "random_string" "service_id" {
upper = false
}

# Give all users permissions to execute the CloudRun service (is ingress only)
resource "google_cloud_run_service_iam_member" "invoker" {
# Grant service-to-service invoker permissions
# Each service that needs to invoke this service gets the run.invoker role
resource "google_cloud_run_service_iam_member" "service_invokers" {
for_each = var.suga.services

Choose a reason for hiding this comment

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

Are we just naïvely doing all services can intercommunicate or only the ones that have explicitly requested it?

Copy link
Member

Choose a reason for hiding this comment

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

I think the latter for security reasons. Then add a way to toggle this in the UI/yaml


project = var.project_id
service = google_cloud_run_v2_service.service.name
location = google_cloud_run_v2_service.service.location
role = "roles/run.invoker"
member = "allUsers"
member = "serviceAccount:${each.value.identities["gcp:iam:service_account"].exports["gcp_service_account:email"]}"
}
5 changes: 3 additions & 2 deletions cloudrun/module/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
output "suga" {
value = {
id = google_cloud_run_v2_service.service.name
domain_name = google_cloud_run_v2_service.service.uri
id = google_cloud_run_v2_service.service.name
domain_name = google_cloud_run_v2_service.service.uri
Copy link
Member

Choose a reason for hiding this comment

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

should we be stripping the protocol here?

http_endpoint = google_cloud_run_v2_service.service.uri
exports = {
resources = {
"google_cloud_run_v2_service" = google_cloud_run_v2_service.service.name
Expand Down
6 changes: 6 additions & 0 deletions cloudrun/module/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ variable "suga" {
identities = map(object({
exports = map(string)
}))
services = optional(map(object({
actions = list(string)
identities = map(object({
exports = map(string)
}))
})), {})
})
}

Expand Down