-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8b9ba4b
commit 8464bf3
Showing
3 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Deploy to Google Cloud Run | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- dev | ||
|
||
jobs: | ||
terraform: | ||
name: Apply Terraform Configuration | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
||
deploy: | ||
name: Deploy to Google Cloud Run | ||
needs: terraform | ||
runs-on: ubuntu-latest | ||
|
||
steps: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
provider "google" { | ||
project = var.project_id | ||
region = var.region | ||
} | ||
|
||
locals { | ||
registry_name = "${var.project_id}-registry" | ||
} | ||
|
||
# activated services in cloud-platform-iac | ||
# services: | ||
# - secretmanager.googleapis.com | ||
# - sqladmin.googleapis.com | ||
# - run.googleapis.com | ||
# - compute.googleapis.com | ||
# - artifactregistry.googleapis.com | ||
|
||
resource "google_project_service" "secret_manager" { | ||
project = var.project_id | ||
service = "secretmanager.googleapis.com" | ||
} | ||
|
||
resource "google_project_service" "sqladmin" { | ||
project = var.project_id | ||
service = "sqladmin.googleapis.com" | ||
} | ||
|
||
resource "google_project_service" "cloud_run" { | ||
project = var.project_id | ||
service = "run.googleapis.com" | ||
} | ||
|
||
resource "google_project_service" "compute" { | ||
project = var.project_id | ||
service = "compute.googleapis.com" | ||
} | ||
|
||
resource "google_project_service" "artifact_registry" { | ||
project = var.project_id | ||
service = "artifactregistry.googleapis.com" | ||
} | ||
|
||
resource "google_artifact_registry_repository" "keycloak_repo" { | ||
project = var.project_id | ||
location = var.region | ||
repository_id = local.registry_name # Current https://console.cloud.google.com/artifacts/docker/keycloak-dev-399613/europe-west6/keycloak/keycloak?project=keycloak-dev-399613 | ||
format = "DOCKER" # @todo is it right? | ||
description = "Docker repository for Keycloak images" | ||
} | ||
|
||
resource "google_sql_database_instance" "keycloak_db_instance" { | ||
project = var.project_id | ||
region = var.region | ||
name = "keycloak-dev-db" # Current https://console.cloud.google.com/sql/instances/keycloak-dev/overview?project=keycloak-dev-399613 | ||
database_version = "POSTGRES_15" | ||
|
||
settings { | ||
tier = var.tier # @todo the other setting like in sous-titrage? | ||
} | ||
} | ||
|
||
resource "google_sql_database" "keycloak_db" { | ||
instance = google_sql_database_instance.keycloak_db_instance.name | ||
name = "keycloakdb" # @or should it be keycloak-dev-db? | ||
} | ||
|
||
resource "google_cloud_run_service" "keycloak_service" { | ||
name = "keycloak-service" | ||
location = var.region | ||
|
||
template { | ||
spec { | ||
containers { | ||
image = "${module.docker_artifact_registry.image_path}/${var.backend_image_tag}" | ||
# image = "europe-west6-docker.pkg.dev/keycloak-dev-399613/keycloak/keycloak@sha256:0eeed2228ff032040510f2b478f1bb475693179018cfd5587d9a0cc1d7c5716e" | ||
|
||
env { # took it from the docker file | ||
name = "KC_DB_KIND" | ||
value = "postgres" | ||
} | ||
|
||
} | ||
} | ||
} | ||
|
||
autogenerate_revision_name = true #took from the official docs | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
variable "project_id" { | ||
description = "Google Cloud Project ID" | ||
type = string | ||
default = "ast-d-keycloak" | ||
} | ||
|
||
variable "region" { | ||
description = "Google Cloud Region" | ||
type = string | ||
default = "europe-west1" | ||
} | ||
|
||
variable "env" { | ||
description = "Deployment environment (dev or prod)" | ||
type = string | ||
default = "dev" # temporarily dev | ||
} | ||
|
||
variable "tier" { | ||
description = "The machine type to use for the instances." | ||
type = string | ||
} |