Skip to content

Commit

Permalink
Add terraform configuration for infra
Browse files Browse the repository at this point in the history
  • Loading branch information
Mulperi committed Nov 18, 2024
1 parent 4a7324d commit d99f6b1
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
38 changes: 38 additions & 0 deletions frontend/infra/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
provider "google" {
project = var.project_id
region = var.region
}

resource "google_storage_bucket" "frontend_bucket" {
name = "${var.bucket_name}-${terraform.workspace}"
location = var.region
# force_destroy = true

website {
main_page_suffix = "index.html"
not_found_page = "404.html"
}
}

resource "google_cloud_run_service" "backend" {
name = "${var.cloud_run_service_name}-${terraform.workspace}"
location = var.region

template {
spec {
containers {
# Placeholder-arvo, joka päivitetään myöhemmin CI/CD-pipeline -vaiheessa
image = "gcr.io/google-samples/hello-app:1.0"
env {
name = "ALLOWED_ORIGIN"
value = "https://getaroom.vincit.fi"
}
}
}
}

traffic {
percent = 100
latest_revision = true
}
}
7 changes: 7 additions & 0 deletions frontend/infra/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
output "bucket_url" {
value = google_storage_bucket.frontend_bucket.url
}

output "cloud_run_url" {
value = google_cloud_run_service.backend.status[0].url
}
4 changes: 4 additions & 0 deletions frontend/infra/production.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
project_id = "your-project-id"
region = "europe-west1"
bucket_name = "getaroom-frontend"
cloud_run_service_name = "getaroom-backend"
18 changes: 18 additions & 0 deletions frontend/infra/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
variable "project_id" {
type = string
}

variable "region" {
type = string
default = "europe-west1"
}

variable "bucket_name" {
description = "frontend bucket name"
type = string
}

variable "cloud_run_service_name" {
description = "backend service name"
type = string
}

0 comments on commit d99f6b1

Please sign in to comment.