80 lines
2.1 KiB
HCL
80 lines
2.1 KiB
HCL
resource "random_pet" "rg_name" {
|
|
prefix = var.resource_group_name_prefix
|
|
}
|
|
|
|
resource "azurerm_resource_group" "rg" {
|
|
location = var.resource_group_location
|
|
name = random_pet.rg_name.id
|
|
}
|
|
|
|
resource "random_string" "unique_id" {
|
|
length = 8
|
|
lower = true
|
|
numeric = false
|
|
special = false
|
|
upper = false
|
|
}
|
|
|
|
resource "azurerm_storage_account" "storageAccount" {
|
|
name = random_string.unique_id.result
|
|
resource_group_name = azurerm_resource_group.rg.name
|
|
location = azurerm_resource_group.rg.location
|
|
account_tier = "Standard"
|
|
account_replication_type = "LRS"
|
|
}
|
|
|
|
resource "azurerm_service_plan" "hostingPlan" {
|
|
name = random_string.unique_id.result
|
|
resource_group_name = azurerm_resource_group.rg.name
|
|
location = azurerm_resource_group.rg.location
|
|
os_type = "Linux"
|
|
sku_name = "P1v2"
|
|
}
|
|
|
|
resource "azurerm_linux_function_app" "example" {
|
|
name = "fnapp${random_string.unique_id.result}"
|
|
location = azurerm_resource_group.rg.location
|
|
resource_group_name = azurerm_resource_group.rg.name
|
|
service_plan_id = azurerm_service_plan.hostingPlan.id
|
|
storage_account_name = azurerm_storage_account.storageAccount.name
|
|
storage_account_access_key = azurerm_storage_account.storageAccount.primary_access_key
|
|
|
|
identity {
|
|
type = "SystemAssigned"
|
|
}
|
|
|
|
site_config {
|
|
application_stack {
|
|
python_version = "3.9"
|
|
}
|
|
}
|
|
}
|
|
|
|
resource "azurerm_function_app_function" "example" {
|
|
name = "fnappfcn${random_string.unique_id.result}"
|
|
function_app_id = azurerm_linux_function_app.example.id
|
|
language = "Python"
|
|
test_data = jsonencode({
|
|
"name" = "Azure"
|
|
})
|
|
config_json = jsonencode({
|
|
"bindings" = [
|
|
{
|
|
"authLevel" = "function"
|
|
"direction" = "in"
|
|
"methods" = [
|
|
"get",
|
|
"post",
|
|
]
|
|
"name" = "req"
|
|
"type" = "httpTrigger"
|
|
},
|
|
{
|
|
"direction" = "out"
|
|
"name" = "$return"
|
|
"type" = "http"
|
|
},
|
|
]
|
|
})
|
|
}
|