Skip to content

Commit

Permalink
Redis Cache
Browse files Browse the repository at this point in the history
  • Loading branch information
harryy94 committed Jan 27, 2025
1 parent a1c290b commit 5d96061
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
21 changes: 21 additions & 0 deletions src/infrastructure/terraform/caching.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
resource "azurerm_resource_group" "caching-rg" {
name = "${local.service_prefix}-caching-rg"
location = local.location
tags = local.common_tags
}

resource "azurerm_redis_cache" "redis-cache" {
capacity = 2
family = "C"
location = local.location
name = "${local.service_prefix}-redis-cache"
resource_group_name = azurerm_resource_group.caching-rg.id
sku_name = "Standard"
minimum_tls_version = "1.2"
}

resource "azurerm_key_vault_secret" "redis-cache-connection-string" {
key_vault_id = azurerm_key_vault.key-vault.id
name = "redis-cache-connection-string"
value = azurerm_redis_cache.redis-cache.primary_access_key
}
8 changes: 0 additions & 8 deletions src/infrastructure/terraform/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,4 @@ locals {
location = "westeurope"
frontdoor_name = "${local.service_prefix}-web-fd"
frontdoor_url = "${local.frontdoor_name}.azurefd.net"

web_app_settings = {
"ContentfulOptions__DeliveryApiKey" = "@Microsoft.KeyVault(SecretUri=${azurerm_key_vault_secret.contentful-delivery-api-key.versionless_id})"
"ContentfulOptions__PreviewApiKey" = "@Microsoft.KeyVault(SecretUri=${azurerm_key_vault_secret.contentful-preview-api-key.versionless_id})"
"ContentfulOptions__SpaceId" = "@Microsoft.KeyVault(SecretUri=${azurerm_key_vault_secret.contentful-space-id.versionless_id})"
"BaseUrl" = "https://${local.frontdoor_url}"
"ApplicationInsights__ConnectionString" = "@Microsoft.KeyVault(SecretUri=${azurerm_key_vault_secret.application-insights-connection-string.versionless_id})"
}
}
13 changes: 13 additions & 0 deletions src/infrastructure/terraform/web.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
locals {
web_app_settings = {
"ContentfulOptions__DeliveryApiKey" = "@Microsoft.KeyVault(SecretUri=${azurerm_key_vault_secret.contentful-delivery-api-key.versionless_id})"
"ContentfulOptions__PreviewApiKey" = "@Microsoft.KeyVault(SecretUri=${azurerm_key_vault_secret.contentful-preview-api-key.versionless_id})"
"ContentfulOptions__SpaceId" = "@Microsoft.KeyVault(SecretUri=${azurerm_key_vault_secret.contentful-space-id.versionless_id})"
"BaseUrl" = "https://${local.frontdoor_url}"
"ApplicationInsights__ConnectionString" = "@Microsoft.KeyVault(SecretUri=${azurerm_key_vault_secret.application-insights-connection-string.versionless_id})"
}
}

resource "azurerm_resource_group" "web-rg" {
name = "${local.service_prefix}-web-rg"
location = local.location
Expand Down Expand Up @@ -27,6 +37,9 @@ resource "azurerm_linux_web_app_slot" "web-app-service-staging" {
name = "Access from Front Door"
service_tag = "AzureFrontDoor.Backend"
}

health_check_path = "/health"
health_check_eviction_time_in_min = 5
}

app_settings = local.web_app_settings
Expand Down

0 comments on commit 5d96061

Please sign in to comment.