Skip to content

Commit

Permalink
add: sample terraform template to deploy cru as a service
Browse files Browse the repository at this point in the history
  • Loading branch information
mvanholsteijn committed Nov 9, 2021
1 parent 7c01aeb commit d3c71f3
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.iml
.terraform/
.idea/
cru
x/
2 changes: 2 additions & 0 deletions terraform/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
terraform.tfstate*
.terraform.lock.hcl
48 changes: 48 additions & 0 deletions terraform/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
resource "google_cloud_run_service" "container_reference_updater" {
name = "container-reference-updater"
location = "us-central1"
project = data.google_client_config.current.project

template {
spec {
container_concurrency = 1
service_account_name = google_service_account.container_reference_updater.email
containers {
image = "gcr.io/binx-io-public/cru:0.9.0"
args = [
"serve",
"--repository",
"https://source.developers.google.com/p/speeltuin-mvanholsteijn/r/scratch",
"--branch",
"main",
]
}
}
}
timeouts {
create = "10m"
}
}

resource "google_cloud_run_service_iam_binding" "container_reference_updater_invokers" {
service = google_cloud_run_service.container_reference_updater.name
location = google_cloud_run_service.container_reference_updater.location
project = google_cloud_run_service.container_reference_updater.project
role = "roles/run.invoker"
members = [
"allUsers"
]
}

resource "google_service_account" "container_reference_updater" {
display_name = "Container image reference updater"
account_id = "container-reference-updater"
}

resource "google_project_iam_member" "cru_source_code_repository_writer" {
member = format("serviceAccount:%s", google_service_account.container_reference_updater.email)
role = "roles/source.writer"
project = data.google_client_config.current.project
}

data google_client_config current {}

0 comments on commit d3c71f3

Please sign in to comment.