Skip to content

Commit 7b10fe4

Browse files
terraforming
1 parent 9c0e802 commit 7b10fe4

File tree

9 files changed

+107
-42
lines changed

9 files changed

+107
-42
lines changed

.claude/settings.local.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@
4545
"Bash(az storage container create:*)",
4646
"Bash(terraform import:*)",
4747
"Bash(terraform plan:*)",
48-
"Bash(terraform apply:*)"
48+
"Bash(terraform apply:*)",
49+
"Bash(nslookup:*)",
50+
"Bash(dig:*)",
51+
"Bash(terraform force-unlock:*)"
4952
]
5053
}
5154
}

.github/workflows/publish-dashboard.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ jobs:
4646
run: |
4747
cp package.json dist/
4848
cp package-lock.json dist/
49-
cd dist && npm ci --omit=dev
49+
cd dist
50+
npm pkg set scripts.start="node server/entry.mjs"
51+
npm ci --omit=dev
5052
5153
- name: Login to Azure
5254
uses: azure/login@v2

infra/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
.terraform/
33
*.tfstate
44
*.tfstate.backup
5+
*.tfvars

infra/.terraform.lock.hcl

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

infra/app-service-api.tf

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,21 @@ resource "azurerm_linux_web_app" "tgit_api" {
1111
}
1212
}
1313

14-
# TODO: Uncomment after App Services are created
15-
# # Custom domain
16-
# resource "azurerm_app_service_custom_hostname_binding" "tgit_api" {
17-
# hostname = "api.tgit.app"
18-
# app_service_name = azurerm_linux_web_app.tgit_api.name
19-
# resource_group_name = azurerm_resource_group.tgit.name
20-
# }
21-
#
22-
# # Managed SSL certificate
23-
# resource "azurerm_app_service_managed_certificate" "tgit_api" {
24-
# custom_hostname_binding_id = azurerm_app_service_custom_hostname_binding.tgit_api.id
25-
# }
26-
#
27-
# # Bind the certificate to the custom domain
28-
# resource "azurerm_app_service_certificate_binding" "tgit_api" {
29-
# hostname_binding_id = azurerm_app_service_custom_hostname_binding.tgit_api.id
30-
# certificate_id = azurerm_app_service_managed_certificate.tgit_api.id
31-
# ssl_state = "SniEnabled"
32-
# }
14+
# Custom domain
15+
resource "azurerm_app_service_custom_hostname_binding" "tgit_api" {
16+
hostname = "api.tgit.app"
17+
app_service_name = azurerm_linux_web_app.tgit_api.name
18+
resource_group_name = azurerm_resource_group.tgit.name
19+
}
20+
21+
# Managed SSL certificate
22+
resource "azurerm_app_service_managed_certificate" "tgit_api" {
23+
custom_hostname_binding_id = azurerm_app_service_custom_hostname_binding.tgit_api.id
24+
}
25+
26+
# Bind the certificate to the custom domain
27+
resource "azurerm_app_service_certificate_binding" "tgit_api" {
28+
hostname_binding_id = azurerm_app_service_custom_hostname_binding.tgit_api.id
29+
certificate_id = azurerm_app_service_managed_certificate.tgit_api.id
30+
ssl_state = "SniEnabled"
31+
}

infra/app-service-dashboard.tf

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,39 @@ resource "azurerm_linux_web_app" "tgit" {
1515
service_plan_id = azurerm_service_plan.tgit.id
1616

1717
site_config {
18+
app_command_line = "node server/entry.mjs"
19+
1820
application_stack {
1921
node_version = "20-lts"
2022
}
2123
}
24+
25+
app_settings = {
26+
"HOST" = "0.0.0.0"
27+
"COSMOS_ENDPOINT" = azurerm_cosmosdb_account.tgit.endpoint
28+
"COSMOS_KEY" = azurerm_cosmosdb_account.tgit.primary_key
29+
"COSMOS_DATABASE" = "tgit-dashboard"
30+
"WEBAUTHN_RP_NAME" = var.webauthn_rp_name
31+
"WEBAUTHN_RP_ID" = var.webauthn_rp_id
32+
"WEBAUTHN_ORIGIN" = var.webauthn_origin
33+
}
2234
}
2335

24-
# TODO: Uncomment after App Services are created
25-
# # Custom domain
26-
# resource "azurerm_app_service_custom_hostname_binding" "tgit_dashboard" {
27-
# hostname = "tgit.app"
28-
# app_service_name = azurerm_linux_web_app.tgit.name
29-
# resource_group_name = azurerm_resource_group.tgit.name
30-
# }
31-
#
32-
# # Managed SSL certificate
33-
# resource "azurerm_app_service_managed_certificate" "tgit_dashboard" {
34-
# custom_hostname_binding_id = azurerm_app_service_custom_hostname_binding.tgit_dashboard.id
35-
# }
36-
#
37-
# # Bind the certificate to the custom domain
38-
# resource "azurerm_app_service_certificate_binding" "tgit_dashboard" {
39-
# hostname_binding_id = azurerm_app_service_custom_hostname_binding.tgit_dashboard.id
40-
# certificate_id = azurerm_app_service_managed_certificate.tgit_dashboard.id
41-
# ssl_state = "SniEnabled"
42-
# }
36+
# Custom domain
37+
resource "azurerm_app_service_custom_hostname_binding" "tgit_dashboard" {
38+
hostname = "tgit.app"
39+
app_service_name = azurerm_linux_web_app.tgit.name
40+
resource_group_name = azurerm_resource_group.tgit.name
41+
}
42+
43+
# Managed SSL certificate
44+
resource "azurerm_app_service_managed_certificate" "tgit_dashboard" {
45+
custom_hostname_binding_id = azurerm_app_service_custom_hostname_binding.tgit_dashboard.id
46+
}
47+
48+
# Bind the certificate to the custom domain
49+
resource "azurerm_app_service_certificate_binding" "tgit_dashboard" {
50+
hostname_binding_id = azurerm_app_service_custom_hostname_binding.tgit_dashboard.id
51+
certificate_id = azurerm_app_service_managed_certificate.tgit_dashboard.id
52+
ssl_state = "SniEnabled"
53+
}

infra/main.tf

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Create the TGit resource group
22
resource "azurerm_resource_group" "tgit" {
33
location = "newzealandnorth"
4-
name = "TGit_terraform"
4+
name = "TGit"
5+
}
6+
7+
# Grant the GitHub deploy SP contributor access to the resource group
8+
data "azuread_service_principal" "deploy" {
9+
display_name = "VisualGit-TerraformUser"
10+
}
11+
12+
resource "azurerm_role_assignment" "deploy_contributor" {
13+
scope = azurerm_resource_group.tgit.id
14+
role_definition_name = "Contributor"
15+
principal_id = data.azuread_service_principal.deploy.object_id
516
}

infra/providers.tf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
terraform {
22

33
backend "azurerm" {
4-
resource_group_name = "TGit_terraform"
4+
resource_group_name = "TGit-State"
55
storage_account_name = "tgitterraformstate"
66
container_name = "tfstate"
77
key = "terraform.tfstate"
@@ -12,6 +12,10 @@ terraform {
1212
source = "hashicorp/azurerm"
1313
version = "~>4.0"
1414
}
15+
azuread = {
16+
source = "hashicorp/azuread"
17+
version = "~>3.0"
18+
}
1519
random = {
1620
source = "hashicorp/random"
1721
version = "~>3.0"

infra/variables.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
variable "webauthn_rp_name" {
2+
description = "WebAuthn Relying Party display name"
3+
type = string
4+
}
5+
6+
variable "webauthn_rp_id" {
7+
description = "WebAuthn Relying Party ID (domain)"
8+
type = string
9+
}
10+
11+
variable "webauthn_origin" {
12+
description = "WebAuthn expected origin URL"
13+
type = string
14+
}

0 commit comments

Comments
 (0)