Created
March 27, 2019 18:37
-
-
Save guitarrapc/e54e417361d8a41d9e87eedb7bb52530 to your computer and use it in GitHub Desktop.
terraform resource to enable functionapp and msi to resource group.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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