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

terraform {
backend "gcs" {
bucket = "infra-new-state"
prefix = "tanke/v1/artifacts"
}

required_providers {
google = {
source = "hashicorp/google"
version = "~> 6.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"
}
55 changes: 55 additions & 0 deletions infra/environments/dev/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@

terraform {
backend "gcs" {
bucket = "infra-new-state"
prefix = "tanke/v1/dev"
}

required_providers {
google = {
source = "hashicorp/google"
version = "~> 6.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_service" {
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/app:latest"
service_account_email = google_service_account.cloud_run_sa.email

env_vars = [
{
name = "ENVIRONMENT"
value = "development"
}
]
}

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

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

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

# Required variables
project_id = var.project_id
location = var.location
service_name = var.service_name
image = var.image

# Optional configurations
service_annotations = {
"run.googleapis.com/ingress" = "all"
}

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

service_account_email = var.service_account_email

env_vars = var.env_vars
}
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 created service"
value = module.cloud_run.service_id
}

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

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 to use for the service"
type = string
}

variable "env_vars" {
description = "Environment variables to set"
type = list(object({
name = string
value = string
}))
default = []
}