Terraform module which creates Azure Web App resources.
- HTTPS enforced.
- Public network access denied by default.
- Managed certificates automatically created for custom hostnames.
- Application logging enabled (automatically disabled after 12 hours, see notes).
- Audit logs sent to given Log Analytics workspace by default.
- Changes to app settings
BUILD
,BUILD_NUMBER
andBUILD_ID
ignored, allowing them to be configured outside of Terraform (commonly in a CI/CD pipeline).
-
Login to Azure:
az login
-
Create a Terraform configuration file
main.tf
and add the following example configuration:provider "azurerm" { features {} } module "web_app" { source = "equinor/web-app/azurerm" version = "~> 15.13" app_name = "example-app" resource_group_name = azurerm_resource_group.example.name location = azurerm_resource_group.example.location app_service_plan_id = module.app_service.plan_id log_analytics_workspace_id = module.log_analytics.workspace_id } resource "azurerm_resource_group" "example" { name = "example-resources" location = "northeurope" } module "app_service" { source = "equinor/app-service/azurerm" version = "~> 2.1" plan_name = "example-plan" resource_group_name = azurerm_resource_group.example.name location = azurerm_resource_group.example.location } module "log_analytics" { source = "equinor/log-analytics/azurerm" version = "~> 2.3" workspace_name = "example-workspace" resource_group_name = azurerm_resource_group.example.name location = azurerm_resource_group.example.location }
-
Install required provider plugins and modules:
terraform init
-
Apply the Terraform configuration:
terraform apply
-
Application logging is enabled by default, however it'll be automatically disabled after 12 hours.
-
It can be re-enabled at any time by running the following Azure CLI command:
az webapp log config -n <APP_NAME> -g <RESOURCE_GROUP_NAME> --application-logging filesystem
-
Login to Azure:
az login
-
Set environment variables:
export ARM_SUBSCRIPTION_ID="<SUBSCRIPTION_ID>" export TF_VAR_resource_group_name="<RESOURCE_GROUP_NAME>" export TF_VAR_location="<LOCATION>"
-
Change to the test directory:
cd test
-
Login to Azure:
az login
-
Set active subscription:
az account set -s <SUBSCRIPTION_NAME_OR_ID>
-
Run tests:
go test -timeout 60m