diff --git a/frontend/infra/main.tf b/frontend/infra/main.tf new file mode 100644 index 0000000..f8a3de6 --- /dev/null +++ b/frontend/infra/main.tf @@ -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 + } +} diff --git a/frontend/infra/outputs.tf b/frontend/infra/outputs.tf new file mode 100644 index 0000000..cef1da8 --- /dev/null +++ b/frontend/infra/outputs.tf @@ -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 +} diff --git a/frontend/infra/production.tfvars b/frontend/infra/production.tfvars new file mode 100644 index 0000000..e54a10f --- /dev/null +++ b/frontend/infra/production.tfvars @@ -0,0 +1,4 @@ +project_id = "your-project-id" +region = "europe-west1" +bucket_name = "getaroom-frontend" +cloud_run_service_name = "getaroom-backend" diff --git a/frontend/infra/variables.tf b/frontend/infra/variables.tf new file mode 100644 index 0000000..dc193d1 --- /dev/null +++ b/frontend/infra/variables.tf @@ -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 +}