Skip to content

Commit

Permalink
Add domain mapping.
Browse files Browse the repository at this point in the history
  • Loading branch information
anybodys committed Feb 20, 2024
1 parent 5bc7291 commit 6de87b5
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/cd.infra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
paths:
- infra/**
- .github/workflows/ci.infra.yaml
branches:
- main

env:
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GCP_CD }}
Expand Down
5 changes: 4 additions & 1 deletion infra/app/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ provider "google" {
region = var.region
}

provider "google-beta" {
project = var.project
}

data "google_client_config" "current" {
}

Expand All @@ -24,4 +28,3 @@ locals {
voting_tag = var.app_versions["voting_api"]
voting_image = "${local.image_base}voting_api:${local.voting_tag}"
}

55 changes: 55 additions & 0 deletions infra/app/networking.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
module "lb-http" {
source = "terraform-google-modules/lb-http/google//modules/serverless_negs"
version = "~> 9.0"

name = "artist"
project = var.project

ssl = var.ssl
managed_ssl_certificate_domains = [var.domain]
https_redirect = var.ssl

backends = {
default = {
description = null
groups = [
{
group = google_compute_region_network_endpoint_group.serverless_neg.id
}
]
enable_cdn = false

iap_config = {
enable = false
}
log_config = {
enable = false
}
}
}
}

resource "google_compute_region_network_endpoint_group" "serverless_neg" {
provider = google-beta
name = "serverless-neg"
network_endpoint_type = "SERVERLESS"
region = var.region
cloud_run {
service = data.google_cloud_run_service.client.name
}
}


data "google_cloud_run_service" "client" {
name = "client"
location = var.region
project = var.project
}

resource "google_cloud_run_service_iam_member" "public-access" {
location = data.google_cloud_run_service.client.location
project = data.google_cloud_run_service.client.project
service = data.google_cloud_run_service.client.name
role = "roles/run.invoker"
member = "allUsers"
}
26 changes: 18 additions & 8 deletions infra/app/variables.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
variable "app_versions" {
type = map(string)
default = {
client : "0.1.0",
voting_api : "0.1.1",
painter_api : "0.1.0",
}

}

variable "domain" {
type = string
default = "kmdcodes.com"
}

variable "project" {
type = string
default = "artist-2d"
Expand All @@ -8,12 +23,7 @@ variable "region" {
default = "us-west1"
}

variable "app_versions" {
type = map(string)
default = {
client : "0.1.0",
voting_api : "0.1.1",
painter_api : "0.1.0",
}

variable "ssl" {
type = bool
default = true
}

0 comments on commit 6de87b5

Please sign in to comment.