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

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

required_providers {
google = {
source = "hashicorp/google"
version = "~> 6.0"
}
}
}

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

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/service:latest"
}

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

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

ports = {
name = "http1"
port = 8080
}
}

# Allow unauthenticated access to the service
resource "google_cloud_run_service_iam_member" "public_access" {
location = module.cloud_run.location
service = module.cloud_run.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 on which the deployed service is available"
value = module.cloud_run.service_url
}

output "location" {
description = "Location in which the Cloud Run service was created"
value = module.cloud_run.location
}

output "service_name" {
description = "Name of the created service"
value = module.cloud_run.service_name
}
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 = "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
}