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

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"
}

resource "google_project_iam_member" "cloudbuild_push" {
project = "launchflow-services-dev"
role = "roles/artifactregistry.writer"
member = "serviceAccount:${data.google_project.project.number}@cloudbuild.gserviceaccount.com"
}

data "google_project" "project" {
project_id = "launchflow-services-dev"
}
2 changes: 2 additions & 0 deletions infra/dev/dev.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

# No variables to set as all values are hardcoded in main.tf
36 changes: 36 additions & 0 deletions infra/dev/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

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"
}

# Create service account for Cloud Run
resource "google_service_account" "cloud_run_sa" {
account_id = "cloud-run-service"
display_name = "Cloud Run Service Account"
description = "Service account for Cloud Run application"
}

# Use the Cloud Run module
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/myapp:latest"
service_account_email = google_service_account.cloud_run_sa.email
}
10 changes: 10 additions & 0 deletions infra/dev/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

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

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

# No variables needed for dev environment as all values are hardcoded for simplicity
23 changes: 23 additions & 0 deletions infra/modules/cloud_run/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

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

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

service_account_email = var.service_account_email

template_annotations = {
"run.googleapis.com/client-name" = "terraform"
"generated-by" = "terraform"
"autoscaling.knative.dev/maxScale" = "2"
"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 on which the deployed service is available"
value = module.cloud_run.service_url
}

output "service_id" {
description = "Unique identifier for the Cloud Run service"
value = module.cloud_run.service_id
}

output "service_status" {
description = "Status of the Cloud Run service"
value = module.cloud_run.service_status
}
25 changes: 25 additions & 0 deletions infra/modules/cloud_run/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

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

variable "location" {
description = "Cloud Run service deployment location"
type = string
}

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

variable "image" {
description = "Container image to deploy"
type = string
}

variable "service_account_email" {
description = "Service account email for the Cloud Run service"
type = string
}