Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix load generation function for Terraform 3.0 #304

Merged
merged 18 commits into from
Apr 25, 2022

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