Skip to content

Commit 16bd71d

Browse files
First working version
1 parent 3bdcfba commit 16bd71d

22 files changed

Lines changed: 224 additions & 58 deletions

File tree

dev/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ module "dev_environment" {
3030
database_name = "ctk"
3131
acr_id = data.terraform_remote_state.shared.outputs.acr_id
3232
acr_login_server = data.terraform_remote_state.shared.outputs.acr_login_server
33+
acr_admin_username = data.terraform_remote_state.shared.outputs.acr_admin_username
34+
acr_admin_password = data.terraform_remote_state.shared.outputs.acr_admin_password
3335
webapp_image_tag = var.webapp_image_tag
3436
cloai_service_image_tag = var.cloai_service_image_tag
3537
ctk_functions_image_tag = var.ctk_functions_image_tag

justfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ plan env=default_env *args='':
99
apply env=default_env *args='':
1010
terraform -chdir="./{{env}}" apply {{args}}
1111

12+
plapply env=default_env:
13+
just plan {{env}} --out ./{{env}}.plan
14+
just apply {{env}} ./{{env}}.plan
15+
1216
destroy env=default_env *args='':
1317
terraform -chdir="./{{env}}" destroy {{args}}
1418

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
data "azuread_client_config" "current" {}
2+
3+
resource "azuread_application" "app" {
4+
display_name = var.display_name
5+
owners = [data.azuread_client_config.current.object_id]
6+
7+
web {
8+
redirect_uris = var.redirect_uris
9+
implicit_grant {
10+
access_token_issuance_enabled = false
11+
id_token_issuance_enabled = true
12+
}
13+
}
14+
15+
lifecycle {
16+
prevent_destroy = true
17+
}
18+
}
19+
20+
resource "azuread_service_principal" "sp" {
21+
client_id = azuread_application.app.client_id
22+
owners = [data.azuread_client_config.current.object_id]
23+
24+
lifecycle {
25+
prevent_destroy = true
26+
}
27+
}
28+
29+
resource "azuread_application_password" "secret" {
30+
application_id = azuread_application.app.id
31+
32+
lifecycle {
33+
prevent_destroy = true
34+
}
35+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
output "client_id" {
2+
value = azuread_application.app.client_id
3+
}
4+
5+
output "client_secret" {
6+
value = azuread_application_password.secret.value
7+
sensitive = true
8+
}
9+
10+
output "tenant_id" {
11+
value = data.azuread_client_config.current.tenant_id
12+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
variable "display_name" {
2+
description = "The display name for the application."
3+
type = string
4+
}
5+
6+
variable "redirect_uris" {
7+
description = "A set of redirect URIs for the application."
8+
type = list(string)
9+
default = []
10+
}

modules/container_apps/cloai_service/main.tf

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resource "azurerm_container_app" "cloai_service" {
2-
name = format("ca-cloai-service-%s-%s", var.project_name, var.environment_name)
2+
name = format("ca-%s-%s-cloai-service", var.project_name, var.environment_name)
33
container_app_environment_id = var.container_app_environment_id
44
resource_group_name = var.resource_group_name
55
revision_mode = "Single"
@@ -17,10 +17,21 @@ resource "azurerm_container_app" "cloai_service" {
1717
type = "SystemAssigned"
1818
}
1919

20+
registry {
21+
server = var.acr_login_server
22+
username = var.acr_admin_username
23+
password_secret_name = "acr-admin-password"
24+
}
25+
26+
secret {
27+
name = "acr-admin-password"
28+
value = var.acr_admin_password
29+
}
30+
2031
template {
2132
container {
22-
name = format("ca-cloai-service-%s-%s", var.project_name, var.environment_name)
23-
image = "${var.acr_login_server}/cloai-service:${var.image_tag}"
33+
name = format("ca-%s-%s-cloai-service", var.project_name, var.environment_name)
34+
image = "${var.acr_login_server}/childmindresearch/cloai-service:${var.image_tag}"
2435
cpu = 1
2536
memory = "2Gi"
2637

@@ -30,7 +41,7 @@ resource "azurerm_container_app" "cloai_service" {
3041
}
3142

3243
env {
33-
name = "CONFIG_JSON"
44+
name = "CONFIG_JSON"
3445
secret_name = "config-json"
3546
}
3647
}

modules/container_apps/cloai_service/vars.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,14 @@ variable "acr_id" {
4343
type = string
4444
description = "The ID of the Azure Container Registry."
4545
}
46+
47+
variable "acr_admin_username" {
48+
type = string
49+
description = "Admin username for the Azure Container Registry."
50+
}
51+
52+
variable "acr_admin_password" {
53+
type = string
54+
description = "Admin password for the Azure Container Registry."
55+
sensitive = true
56+
}

modules/container_apps/ctk_functions/main.tf

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resource "azurerm_container_app" "ctk_functions" {
2-
name = format("ca-ctk-functions-%s-%s", var.project_name, var.environment_name)
2+
name = format("ca-%s-%s-ctk-functions", var.project_name, var.environment_name)
33
container_app_environment_id = var.container_app_environment_id
44
resource_group_name = var.resource_group_name
55
revision_mode = "Single"
@@ -17,10 +17,20 @@ resource "azurerm_container_app" "ctk_functions" {
1717
type = "SystemAssigned"
1818
}
1919

20+
registry {
21+
server = var.acr_login_server
22+
username = var.acr_admin_username
23+
password_secret_name = "acr-admin-password"
24+
}
25+
26+
secret {
27+
name = "acr-admin-password"
28+
value = var.acr_admin_password
29+
}
2030
template {
2131
container {
22-
name = format("ca-ctk-functions-%s-%s", var.project_name, var.environment_name)
23-
image = "${var.acr_login_server}/ctk-functions:${var.image_tag}"
32+
name = format("ca-%s-ctk-functions-%s", var.project_name, var.environment_name)
33+
image = "${var.acr_login_server}/childmindresearch/ctk-functions:${var.image_tag}"
2434
cpu = 1
2535
memory = "2Gi"
2636

modules/container_apps/ctk_functions/vars.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,15 @@ variable "acr_id" {
9090
type = string
9191
description = "The ID of the Azure Container Registry."
9292
}
93+
94+
95+
variable "acr_admin_username" {
96+
type = string
97+
description = "Admin username for the Azure Container Registry."
98+
}
99+
100+
variable "acr_admin_password" {
101+
type = string
102+
description = "Admin password for the Azure Container Registry."
103+
sensitive = true
104+
}

modules/container_apps/languagetool/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resource "azurerm_container_app" "languagetool" {
2-
name = format("ca-ctk-languagetool-%s-%s", var.project_name, var.environment_name)
2+
name = format("ca-%s-%s-languagetool", var.project_name, var.environment_name)
33
container_app_environment_id = var.container_app_environment_id
44
resource_group_name = var.resource_group_name
55
revision_mode = "Single"
@@ -15,7 +15,7 @@ resource "azurerm_container_app" "languagetool" {
1515

1616
template {
1717
container {
18-
name = format("ca-ctk-languagetool-%s-%s", var.project_name, var.environment_name)
18+
name = format("ca-%s-languagetool-%s", var.project_name, var.environment_name)
1919
image = "erikvl87/languagetool:6.5"
2020
cpu = 1
2121
memory = "2Gi"

0 commit comments

Comments
 (0)