Skip to content

Commit

Permalink
update app configuration variables
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasisnes committed Sep 28, 2024
1 parent 50be799 commit 015a8aa
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 11 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/apps-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Apps CI

on:
push:
branches-ignore:
- main
paths:
- src/**
- .github/workflows/apps-*

env:
DOTNET_VERSION: 8.0.x
APPS_DIR: src/apps

jobs:
bundle:
name: Bundle Apps
uses: ./.github/workflows/template-bundle.yml
with:
dir: apps

ci:
name: CI
runs-on: ubuntu-latest
needs: bundle
strategy:
matrix:
name: ${{ fromJson(needs.bundle.outputs.dirs) }}

steps:
- uses: actions/checkout@v4

- name: Install .NET ${{ env.DOTNET_VERSION }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Build
working-directory: ${{ env.APPS_DIR }}/${{ matrix.name }}
run: dotnet build

- name: Test
if: always()
working-directory: src/apps/${{ matrix.name }}
run: dotnet test --no-build
29 changes: 29 additions & 0 deletions .github/workflows/bundle-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: bundle-template.yml

on:
workflow_call:
outputs:
dirs:
value: ${{ jobs.bundle.outputs.names }}
description: JSON list of folders in either <apps, pkgs, libs>

inputs:
dir:
required: true
description: <apps, pkgs, libs>
type: string

jobs:
bundle:
name: Bundle Apps
runs-on: ubuntu-latest
outputs:
names: ${{ steps.list.outputs.result }}
steps:
- uses: actions/checkout@v4
- name: List ${{ inputs.dir }}
id: list
working-directory: src/${{ inputs.dir }}
run: |
result=$(find . -maxdepth 1 -type d -not -path '.' -printf '%P\n' | jq -R -s -c 'split("\n")[:-1]')
echo "result=$result" >> $GITHUB_OUTPUT
4 changes: 2 additions & 2 deletions .github/workflows/infra-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
cert:
name: Cert
secrets: inherit
uses: ./.github/workflows/infra-cd-template.yml
uses: ./.github/workflows/infra-ci-template.yml
with:
environment: at21
tf_state: cert.tfstate
Expand All @@ -27,7 +27,7 @@ jobs:
name: Auth
needs: cert
secrets: inherit
uses: ./.github/workflows/infra-cd-template.yml
uses: ./.github/workflows/infra-ci-template.yml
with:
environment: at21
tf_state: auth.tfstate
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/libs-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Libs CI

on:
push:
branches-ignore:
- main
paths:
- src/**
- .github/workflows/libs-*

env:
DOTNET_VERSION: 8.0.x
DIR: src/libs

jobs:
bundle:
name: Bundle Libs
uses: ./.github/workflows/template-bundle.yml
with:
dir: libs

ci:
name: CI
runs-on: ubuntu-latest
needs: bundle
strategy:
matrix:
name: ${{ fromJson(needs.bundle.outputs.dirs) }}

steps:
- uses: actions/checkout@v4

- name: Install .NET ${{ env.DOTNET_VERSION }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Build
working-directory: ${{ env.DIR }}/${{ matrix.name }}
run: dotnet build

- name: Test
if: always()
working-directory: src/apps/${{ matrix.name }}
run: dotnet test --no-build
9 changes: 6 additions & 3 deletions infra/deploy/auth/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ locals {

domains = {
api = var.environment == "prod" ? "api.auth.${var.domain}" : "api.auth.${local.environment}.${var.domain}"
frontend = "auth.${local.environment}.${var.domain}"
frontend = var.environment == "prod" ? "auth.${var.domain}" : "auth.${local.environment}.${var.domain}"
}

metadata = {
Expand Down Expand Up @@ -160,7 +160,7 @@ module "application_gateway" {
cert_user_assigned_identity_name = var.cert_user_assigned_identity_name

domains = local.domains
backend = var.backend
backend = var.services

depends_on = [azurerm_resource_group.auth]
}
Expand All @@ -173,7 +173,10 @@ module "app_configuration" {

variables = merge(
{
for api in var.backend : "AltinnEndpoints:${title(api.hostname)}" => "http://${api.hostname}.${local.domains.api}" if api.domain == "api"
for service in var.services : "AltinnApiEndpoints:${title(service.hostname)}" => "http://${service.hostname}.${local.domains.api}" if service.domain == "api"
},
{
for service in var.services : "AltinnFrontendEndpoints:${title(service.hostname)}" => "http://${service.hostname}.${local.domains.frontend}" if service.domain == "frontend"
},
{
"Postgres:Host" = module.postgres_server.host
Expand Down
2 changes: 1 addition & 1 deletion infra/deploy/auth/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ variable "cert_user_assigned_identity_name" {
description = "The name of the user-assigned managed identity that will be used for authenticating the cert Key Vault."
}

variable "backend" {
variable "services" {
type = list(object(
{
domain = string # Should be "api" or "frontend"
Expand Down
8 changes: 4 additions & 4 deletions infra/modules/application_gateway/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ resource "azurerm_application_gateway" "appgw" {
fqdns = ["${backend_address_pool.value.hostname}.${var.domains[backend_address_pool.value.domain]}"]
}

for_each = toset(var.backend)
for_each = toset(var.services)
}

dynamic "probe" {
Expand All @@ -129,7 +129,7 @@ resource "azurerm_application_gateway" "appgw" {
}
}

for_each = toset(var.backend)
for_each = toset(var.services)
}

# Container Apps
Expand Down Expand Up @@ -158,7 +158,7 @@ resource "azurerm_application_gateway" "appgw" {
paths = ["/${path_rule.value.path}/*", "/${path_rule.value.path}"]
}

for_each = toset(var.backend)
for_each = toset(var.services)
}
}

Expand All @@ -176,7 +176,7 @@ resource "azurerm_application_gateway" "appgw" {
pick_host_name_from_backend_address = true
}

for_each = toset(var.backend)
for_each = toset(var.services)
}


Expand Down
2 changes: 1 addition & 1 deletion infra/modules/application_gateway/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ variable "log_analytics_workspace_id" {
description = "The ID of the Log Analytics workspace for logging and monitoring the Application Gateway."
}

variable "backend" {
variable "services" {
type = list(object({
domain = string
path = string
Expand Down

0 comments on commit 015a8aa

Please sign in to comment.