Skip to content

Commit a1e9827

Browse files
committed
Cost optimisation for dev/test client app, and GitHub secret integration
1 parent 4fb63cb commit a1e9827

8 files changed

Lines changed: 53 additions & 7 deletions

File tree

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
# PocketDDD
22

33
# Running terraform locally
4-
Ensure both terraform and the Azure CLI are installed
4+
Ensure the Azure, GitHub, and terraform CLIs are installed
55
```
6-
brew install terraform
76
brew install azure-cli
7+
bre install gh
8+
brew install terraform
89
```
910

10-
Login to Azure
11+
Login to Azure and GitHub
1112
```
1213
az login
14+
gh auth login
1315
```
1416

1517
From the `terraform` directory run init, plan, then apply if happy with the changes.

terraform/blazor_client.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,14 @@ resource "azurerm_static_web_app" "blazor-client" {
22
name = "${local.resource_prefix}-blazorclient"
33
location = "westeurope"
44
resource_group_name = azurerm_resource_group.rg.name
5+
6+
sku_tier = var.client_sku_tier
7+
sku_size = var.client_sku_size
8+
}
9+
10+
resource "github_actions_environment_secret" "test_secret" {
11+
repository = data.github_repository.repo.name
12+
environment = github_repository_environment.repo_environment.environment
13+
secret_name = "AZURE_STATIC_WEB_APPS_API_TOKEN"
14+
plaintext_value = azurerm_static_web_app.blazor-client.api_key
515
}

terraform/main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,11 @@ locals {
2121
db_connection_string = "Server=tcp:${local.sql_server_name}.database.windows.net,1433;Initial Catalog=pocketddd-dev-sqldatabase;Persist Security Info=False;User ID=${random_string.admin_login.result};Password=${random_password.admin_password.result};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
2222
}
2323

24+
data "github_repository" "repo" {
25+
name = "PocketDDD"
26+
}
27+
28+
resource "github_repository_environment" "repo_environment" {
29+
repository = "PocketDDD"
30+
environment = var.env
31+
}

terraform/terraform.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ terraform {
44
source = "hashicorp/azurerm"
55
version = "3.100.0"
66
}
7+
github = {
8+
source = "integrations/github"
9+
version = "6.2.1"
10+
}
711
random = {
812
source = "hashicorp/random"
913
version = "3.6.1"
@@ -16,4 +20,8 @@ provider "azurerm" {
1620
features {
1721

1822
}
23+
}
24+
25+
provider "github" {
26+
owner = "dddsw"
1927
}

terraform/variables.tf

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,16 @@ variable "api_always_on" {
2626
default = true
2727
nullable = false
2828
type = bool
29-
}
29+
}
30+
31+
variable "client_sku_tier" {
32+
default = ""
33+
nullable = false
34+
type = string
35+
}
36+
37+
variable "client_sku_size" {
38+
default = ""
39+
nullable = false
40+
type = string
41+
}

tfvars/dev.tfvars

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ env = "dev"
22
sql_db_sku = "Basic"
33
sql_max_storage = "2"
44
api_app_service_sku = "F1"
5-
api_always_on = false
5+
api_always_on = false
6+
client_sku_tier = "Free"
7+
client_sku_size = "Free"

tfvars/prod.tfvars

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ env = "prod"
22
sql_db_sku = "S0"
33
sql_max_storage = "10"
44
api_app_service_sku = "B1"
5-
api_always_on = true
5+
api_always_on = true
6+
client_sku_tier = "Standard"
7+
client_sku_size = "Standard"

tfvars/test.tfvars

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ env = "dev"
22
sql_db_sku = "Basic"
33
sql_max_storage = "2"
44
api_app_service_sku = "F1"
5-
api_always_on = false
5+
api_always_on = false
6+
client_sku_tier = "Free"
7+
client_sku_size = "Free"

0 commit comments

Comments
 (0)