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"
}
35 changes: 35 additions & 0 deletions infra/environments/dev/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

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 = "python-app-dev"
container_image = "us-west1-docker.pkg.dev/launchflow-services-dev/app/python-app:latest"
cpu = "1000m"
memory = "512Mi"
public_access = true
}

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

resource "google_service_account" "service_account" {
account_id = var.service_name
display_name = "Service Account for ${var.service_name}"
description = "Service account for Cloud Run service ${var.service_name}"
}

resource "google_cloud_run_v2_service" "service" {
name = var.service_name
location = var.location

template {
containers {
image = var.container_image

resources {
limits = {
cpu = var.cpu
memory = var.memory
}
}

env {
name = "PROJECT_ID"
value = var.project_id
}
}

service_account = google_service_account.service_account.email
}
}

# IAM binding for public access (if enabled)
resource "google_cloud_run_v2_service_iam_member" "public" {
count = var.public_access ? 1 : 0
project = google_cloud_run_v2_service.service.project
location = google_cloud_run_v2_service.service.location
name = google_cloud_run_v2_service.service.name
role = "roles/run.invoker"
member = "allUsers"
}
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 = google_cloud_run_v2_service.service.uri
}

output "service_account_email" {
description = "The email of the service account"
value = google_service_account.service_account.email
}

output "service_name" {
description = "The name of the Cloud Run service"
value = google_cloud_run_v2_service.service.name
}
38 changes: 38 additions & 0 deletions infra/modules/cloud-run/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

variable "project_id" {
description = "The project ID where resources will be created"
type = string
}

variable "location" {
description = "The location where resources will be created"
type = string
}

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

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

variable "cpu" {
description = "The amount of CPU to allocate to the service"
type = string
default = "1000m"
}

variable "memory" {
description = "The amount of memory to allocate to the service"
type = string
default = "512Mi"
}

variable "public_access" {
description = "Whether to allow public access to the service"
type = bool
default = true
}