Skip to content

Commit

Permalink
Fix load generation function for Terraform 3.0 (#304)
Browse files Browse the repository at this point in the history
* use appinsights connstring attribute

* run from package out

* run from package out

* no appsettings

* settings back

* runtime back

* node runtime out

* runtime out

* move appinsights to LAW mode

* fix law name

* rename

* try env

* back to stack

* package out

* update tf to 3.3.0

* try setting

* try ignore
  • Loading branch information
sebader authored Apr 25, 2022
1 parent 3278c58 commit 2c7ab50
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 18 deletions.
9 changes: 0 additions & 9 deletions src/testing/userload-generator/infra/application_insights.tf

This file was deleted.

2 changes: 1 addition & 1 deletion src/testing/userload-generator/infra/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "3.1.0"
version = "3.3.0"
}
}

Expand Down
20 changes: 15 additions & 5 deletions src/testing/userload-generator/infra/master_functionapp.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,28 @@ resource "azurerm_linux_function_app" "master" {
identity_ids = [azurerm_user_assigned_identity.functions.id]
}

site_config {}
site_config {
application_stack {
dotnet_version = "6.0"
}

application_insights_connection_string = azurerm_application_insights.deployment.connection_string
}

key_vault_reference_identity_id = azurerm_user_assigned_identity.functions.id

app_settings = merge(
local.function_names_per_geo,
{ for secret in azurerm_key_vault_secret.functionkeys : replace(upper(secret.name), "-", "_") => "@Microsoft.KeyVault(VaultName=${azurerm_key_vault.deployment.name};SecretName=${secret.name})" },
{
"FUNCTIONS_WORKER_RUNTIME" = "dotnet",
"APPLICATIONINSIGHTS_CONNECTION_STRING" = azurerm_application_insights.deployment.connection_string
"WEBSITE_MOUNT_ENABLED" = "1"
"WEBSITE_RUN_FROM_PACKAGE" = "" # This value will be set by the Function deployment later
"WEBSITE_MOUNT_ENABLED" = "1"
"WEBSITE_RUN_FROM_PACKAGE" = "" # This value will be set by the Function deployment later
}
)

lifecycle {
ignore_changes = [
app_settings["WEBSITE_RUN_FROM_PACKAGE"], # prevent TF reporting configuration drift after app code is deployed
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,25 @@ resource "azurerm_linux_function_app" "regional" {
application_stack {
node_version = "14"
}

application_insights_connection_string = var.application_insights_connection_string
}

app_settings = merge(
var.additional_app_settings,
{
"FUNCTIONS_WORKER_RUNTIME" = "node"
"PLAYWRIGHT_BROWSERS_PATH" = "0"
"ENABLE_ORYX_BUILD" = "true"
"SCM_DO_BUILD_DURING_DEPLOYMENT" = "true"
"WEBSITE_MOUNT_ENABLED" = "1"
"WEBSITE_RUN_FROM_PACKAGE" = "" # This value will be set by the Function deployment later
})

lifecycle {
ignore_changes = [
app_settings["WEBSITE_RUN_FROM_PACKAGE"], # prevent TF reporting configuration drift after app code is deployed
]
}
}

data "azurerm_function_app_host_keys" "regional" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ variable "function_user_managed_identity_resource_id" {
type = string
}

variable "application_insights_connection_string" {
type = string
}

variable "default_tags" {}
21 changes: 21 additions & 0 deletions src/testing/userload-generator/infra/monitoring.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
resource "azurerm_log_analytics_workspace" "deployment" {
name = "${local.prefix}-loadgen-log"
location = azurerm_resource_group.deployment.location
resource_group_name = azurerm_resource_group.deployment.name
sku = "PerGB2018"
retention_in_days = 30 # has to be between 30 and 730
daily_quota_gb = 30

tags = local.default_tags
}

resource "azurerm_application_insights" "deployment" {
name = "${local.prefix}-loadgen-appi"
location = azurerm_resource_group.deployment.location
resource_group_name = azurerm_resource_group.deployment.name
application_type = "web"
workspace_id = azurerm_log_analytics_workspace.deployment.id
daily_data_cap_in_gb = 30

tags = local.default_tags
}
4 changes: 2 additions & 2 deletions src/testing/userload-generator/infra/regional_functions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ module "regional_functions" {
prefix = local.prefix
resource_group_name = azurerm_resource_group.deployment.name
additional_app_settings = {
"APPLICATIONINSIGHTS_CONNECTION_STRING" = azurerm_application_insights.deployment.connection_string
"TEST_BASEURL" = var.targeturl
"TEST_BASEURL" = var.targeturl
}

application_insights_connection_string = azurerm_application_insights.deployment.connection_string
function_user_managed_identity_resource_id = azurerm_user_assigned_identity.functions.id

default_tags = local.default_tags
Expand Down

0 comments on commit 2c7ab50

Please sign in to comment.