feat(terraform): add Cloud Run, Artifact Registry and outputs
This commit is contained in:
parent
e3b07af4c7
commit
6f6390dbe1
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -41,3 +41,7 @@ Thumbs.db
|
||||||
/tmp/
|
/tmp/
|
||||||
*.log
|
*.log
|
||||||
.env.prefilled
|
.env.prefilled
|
||||||
|
|
||||||
|
# Terraform
|
||||||
|
.terraform/
|
||||||
|
tfplan.txt
|
||||||
|
|
|
||||||
22
infrastructure/terraform/.terraform.lock.hcl
Normal file
22
infrastructure/terraform/.terraform.lock.hcl
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
# This file is maintained automatically by "terraform init".
|
||||||
|
# Manual edits may be lost in future updates.
|
||||||
|
|
||||||
|
provider "registry.terraform.io/hashicorp/google" {
|
||||||
|
version = "7.33.0"
|
||||||
|
constraints = ">= 5.0.0"
|
||||||
|
hashes = [
|
||||||
|
"h1:AtuVYxtxBEHMS9o/9HR2bg9Z/Ta4MLckXhSOwX8PWFs=",
|
||||||
|
"zh:10620bf55734d05701852dbbd55aa151860cbaf672001222c29ee93ec02d062e",
|
||||||
|
"zh:1ca1a3829a1fdbbce17a540d2be63b1529e46debdb8dbf0057facc992110ff38",
|
||||||
|
"zh:5f3a1b7b1feeafd4d4677b3936a1f6a66a02bf9844b6949e876ee64d0573a73a",
|
||||||
|
"zh:63c513a92a4842c53adbcd0103646e6828ce412f5a66efafaa0c79bc0dbe95de",
|
||||||
|
"zh:862812a0185d3467eae29f8923eebcecdcd50f9d1f0ec543004eaea96105ddc9",
|
||||||
|
"zh:9bf2df9ece0ade7c3fd57f0d164fb5c05211adfbb11315cf78d637bdb21c33cf",
|
||||||
|
"zh:9c378b72733dbe51ed81c81bb2c1902668d8f833d0d352d5fc2201571cffc6fe",
|
||||||
|
"zh:c17f96906e616b8e78c106884cf1c6621a5bdf69026f5debbddcc4b11af7b62c",
|
||||||
|
"zh:c410df582884bb3b8bc08a27b223783a541f4bd8223d025918545ae5435dcb10",
|
||||||
|
"zh:e68d159165213cd7f9c24a3d12a2141879126d6253f58587bb88de648fc6fbc9",
|
||||||
|
"zh:f13d4e191bb36979c3d9a40d8e18119743e8951bcb6fb7c456c0d94ea548f574",
|
||||||
|
"zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -58,3 +58,37 @@ resource "google_pubsub_subscription" "billing_alerts_sub" {
|
||||||
push_endpoint = "mailto:${var.alert_email}"
|
push_endpoint = "mailto:${var.alert_email}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource "google_artifact_registry_repository" "repo" {
|
||||||
|
location = var.artifact_region
|
||||||
|
repository_id = var.artifact_repo_name
|
||||||
|
format = "DOCKER"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "google_cloud_run_v2_service" "agent_service" {
|
||||||
|
name = var.cloud_run_service_name
|
||||||
|
location = var.cloud_run_region
|
||||||
|
|
||||||
|
template {
|
||||||
|
service_account = google_service_account.agent_sa.email
|
||||||
|
|
||||||
|
containers {
|
||||||
|
image = var.container_image
|
||||||
|
env {
|
||||||
|
name = "CUSTOMER_ID"
|
||||||
|
value = var.customer_id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
depends_on = [google_project_service.apis]
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "google_cloud_run_v2_service_iam_member" "invoker" {
|
||||||
|
project = var.project_id
|
||||||
|
location = google_cloud_run_v2_service.agent_service.location
|
||||||
|
name = google_cloud_run_v2_service.agent_service.name
|
||||||
|
role = "roles/run.invoker"
|
||||||
|
member = "user:chris.christiansen@vauco.no"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
14
infrastructure/terraform/outputs.tf
Normal file
14
infrastructure/terraform/outputs.tf
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
output "cloud_run_url" {
|
||||||
|
description = "The URL of the Cloud Run service."
|
||||||
|
value = google_cloud_run_v2_service.agent_service.uri
|
||||||
|
}
|
||||||
|
|
||||||
|
output "service_account_email" {
|
||||||
|
description = "The email of the service account."
|
||||||
|
value = google_service_account.agent_sa.email
|
||||||
|
}
|
||||||
|
|
||||||
|
output "artifact_registry_url" {
|
||||||
|
description = "The URL of the Artifact Registry repository."
|
||||||
|
value = "${google_artifact_registry_repository.repo.location}-docker.pkg.dev/${google_artifact_registry_repository.repo.project}/${google_artifact_registry_repository.repo.repository_id}"
|
||||||
|
}
|
||||||
|
|
@ -24,3 +24,34 @@ variable "billing_account_id" {
|
||||||
description = "The billing account ID to associate with the project."
|
description = "The billing account ID to associate with the project."
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "cloud_run_region" {
|
||||||
|
description = "The region for the Cloud Run service."
|
||||||
|
type = string
|
||||||
|
default = "europe-west1"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "artifact_region" {
|
||||||
|
description = "The region for the Artifact Registry repository."
|
||||||
|
type = string
|
||||||
|
default = "europe-west1"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "cloud_run_service_name" {
|
||||||
|
description = "The name of the Cloud Run service."
|
||||||
|
type = string
|
||||||
|
default = "osvauco-agent"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "artifact_repo_name" {
|
||||||
|
description = "The name of the Artifact Registry repository."
|
||||||
|
type = string
|
||||||
|
default = "agent-images"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "container_image" {
|
||||||
|
description = "The container image to deploy."
|
||||||
|
type = string
|
||||||
|
default = "europe-west1-docker.pkg.dev/propane-will-491900-m5/agent-images/osvauco-agent:latest"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user