Skip to content
Open
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
25 changes: 25 additions & 0 deletions infra/environments/artifacts/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

terraform {
backend "gcs" {
bucket = "infra-new-state"
prefix = "artifacts"
}
required_providers {
google = {
source = "hashicorp/google"
version = "~> 5.0"
}
}
}

provider "google" {
project = "launchflow-services-dev"
region = "us-west1"
}

resource "google_artifact_registry_repository" "app" {
location = "us-west1"
repository_id = "app"
description = "Docker repository for application images"
format = "DOCKER"
}
37 changes: 37 additions & 0 deletions infra/environments/dev/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

terraform {
backend "gcs" {
bucket = "infra-new-state"
prefix = "dev"
}
required_providers {
google = {
source = "hashicorp/google"
version = "~> 5.0"
}
}
}

provider "google" {
project = "launchflow-services-dev"
region = "us-west1"
}

module "cloud_run" {
source = "../../modules/cloud-run"

project_id = "launchflow-services-dev"
location = "us-west1"
service_name = "app-dev"
image = "us-west1-docker.pkg.dev/launchflow-services-dev/app/service:latest"
}

output "service_url" {
description = "The URL of the deployed service"
value = module.cloud_run.service_url
}

output "service_status" {
description = "The status of the deployed service"
value = module.cloud_run.service_status
}
33 changes: 33 additions & 0 deletions infra/modules/cloud-run/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

module "cloud_run_service_account" {
source = "terraform-google-modules/service-accounts/google"
version = "4.5.3"
project_id = var.project_id
names = ["cloud-run-service"]
project_roles = [
"${var.project_id}=>roles/run.invoker",
]
}

module "cloud_run" {
source = "GoogleCloudPlatform/cloud-run/google"
version = "0.17.2"

project_id = var.project_id
location = var.location
service_name = var.service_name
image = var.image

service_account_email = module.cloud_run_service_account.email

template_annotations = {
"run.googleapis.com/client-name" = "terraform"
"generated-by" = "terraform"
"autoscaling.knative.dev/maxScale" = "4"
"autoscaling.knative.dev/minScale" = "1"
}

service_annotations = {
"run.googleapis.com/ingress" = "all"
}
}
15 changes: 15 additions & 0 deletions infra/modules/cloud-run/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

output "service_url" {
description = "The URL of the deployed service"
value = module.cloud_run.service_url
}

output "service_id" {
description = "The ID of the deployed service"
value = module.cloud_run.service_id
}

output "service_status" {
description = "The status of the deployed service"
value = module.cloud_run.service_status
}
20 changes: 20 additions & 0 deletions infra/modules/cloud-run/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

variable "project_id" {
description = "The project ID to deploy to"
type = string
}

variable "location" {
description = "The location to deploy to"
type = string
}

variable "service_name" {
description = "The name of the Cloud Run service"
type = string
}

variable "image" {
description = "The container image to deploy"
type = string
}