Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
terraform resource to enable functionapp and msi to resource group.
resource "azurerm_storage_account" "main" {
name = "${var.storage_account_name}"
location = "${var.location}"
resource_group_name = "${var.resource_group_name}"
account_tier = "Standard"
account_replication_type = "LRS"
tags = "${var.tags}"
}
resource "azurerm_app_service_plan" "main" {
name = "${var.name_prefix}-serviceplan"
location = "${var.location}"
resource_group_name = "${var.resource_group_name}"
kind = "FunctionApp"
sku {
tier = "Dynamic"
size = "Y1"
}
tags = "${var.tags}"
}
resource "azurerm_function_app" "main" {
name = "${var.name_prefix}-function"
location = "${var.location}"
resource_group_name = "${var.resource_group_name}"
app_service_plan_id = "${azurerm_app_service_plan.main.id}"
storage_connection_string = "${azurerm_storage_account.main.primary_connection_string}"
https_only = true
version = "${var.function_version}"
enable_builtin_logging = "${var.enable_builtin_logging}"
lifecycle {
ignore_changes = [
"app_settings.%",
"app_settings.MSDEPLOY_RENAME_LOCKED_FILES",
"app_settings.WEBSITE_RUN_FROM_PACKAGE",
]
}
identity = {
type = "SystemAssigned"
}
app_settings = "${var.app_settings}"
tags = "${var.tags}"
}
resource "azurerm_role_assignment" "main" {
scope = "${data.azurerm_resource_group.current.id}"
role_definition_name = "Contributor"
principal_id = "${lookup(azurerm_function_app.main.identity[0], "principal_id")}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.