|
| 1 | +# Azure App Service (Web Apps) Terraform Module |
| 2 | + |
| 3 | +Terraform module to create Azure App Service with optional site_config, backup, connection_string, auth_settings and Storage for mount points. |
| 4 | + |
| 5 | +## Module Usage |
| 6 | + |
| 7 | +```hcl |
| 8 | +module "web-app" { |
| 9 | + source = "kumarvna/web-app/azurerm" |
| 10 | + version = "1.0.0" |
| 11 | +
|
| 12 | + # By default, this module will not create a resource group. Location will be same as existing RG. |
| 13 | + # proivde a name to use an existing resource group, specify the existing resource group name, |
| 14 | + # set the argument to `create_resource_group = true` to create new resrouce group. |
| 15 | + resource_group_name = "rg-shared-westeurope-01" |
| 16 | +
|
| 17 | + # App service plan setttings and supported arguments. Default name used by module |
| 18 | + # To specify custom name use `app_service_plan_name` with a valid name. |
| 19 | + # for Service Plans, see https://azure.microsoft.com/en-us/pricing/details/app-service/windows/ |
| 20 | + # App Service Plan for `Free` or `Shared` Tiers `use_32_bit_worker_process` must be set to `true`. |
| 21 | + service_plan = { |
| 22 | + kind = "Windows" |
| 23 | + size = "P1v2" |
| 24 | + tier = "PremiumV2" |
| 25 | + } |
| 26 | +
|
| 27 | + # App Service settings and supported arguments |
| 28 | + # Backup, connection_string, auth_settings, Storage for mounts are optional configuration |
| 29 | + app_service_name = "mypocproject" |
| 30 | + enable_client_affinity = true |
| 31 | +
|
| 32 | + # A `site_config` block to setup the application environment. |
| 33 | + # Available built-in stacks (windows_fx_version) for web apps `az webapp list-runtimes` |
| 34 | + # Runtime stacks for Linux (linux_fx_version) based web apps `az webapp list-runtimes --linux` |
| 35 | + site_config = { |
| 36 | + always_on = true |
| 37 | + dotnet_framework_version = "v2.0" |
| 38 | + ftps_state = "FtpsOnly" |
| 39 | + managed_pipeline_mode = "Integrated" |
| 40 | + use_32_bit_worker_process = true |
| 41 | + windows_fx_version = "DOTNETCORE|2.1" |
| 42 | + } |
| 43 | +
|
| 44 | + # (Optional) A key-value pair of Application Settings |
| 45 | + app_settings = { |
| 46 | + APPINSIGHTS_PROFILERFEATURE_VERSION = "1.0.0" |
| 47 | + APPINSIGHTS_SNAPSHOTFEATURE_VERSION = "1.0.0" |
| 48 | + DiagnosticServices_EXTENSION_VERSION = "~3" |
| 49 | + InstrumentationEngine_EXTENSION_VERSION = "disabled" |
| 50 | + SnapshotDebugger_EXTENSION_VERSION = "disabled" |
| 51 | + XDT_MicrosoftApplicationInsights_BaseExtensions = "disabled" |
| 52 | + XDT_MicrosoftApplicationInsights_Java = "1" |
| 53 | + XDT_MicrosoftApplicationInsights_Mode = "recommended" |
| 54 | + XDT_MicrosoftApplicationInsights_NodeJS = "1" |
| 55 | + XDT_MicrosoftApplicationInsights_PreemptSdk = "disabled" |
| 56 | + } |
| 57 | +
|
| 58 | + # The Backup feature in Azure App Service easily create app backups manually or on a schedule. |
| 59 | + # You can configure the backups to be retained up to an indefinite amount of time. |
| 60 | + # Azure storage account and container in the same subscription as the app that you want to back up. |
| 61 | + # This module creates a Storage Container to keep the all backup items. |
| 62 | + # Backup items - App configuration , File content, Database connected to your app |
| 63 | + enable_backup = true |
| 64 | + storage_account_name = "stdiagfortesting" |
| 65 | + backup_settings = { |
| 66 | + enabled = true |
| 67 | + name = "DefaultBackup" |
| 68 | + frequency_interval = 1 |
| 69 | + frequency_unit = "Day" |
| 70 | + retention_period_in_days = 90 |
| 71 | + } |
| 72 | +
|
| 73 | + # By default App Insight resource is created by this module. |
| 74 | + # Specify valid resource Id to `application_insights_id` to use existing App Insight |
| 75 | + # Specifies the type of Application by setting up `application_insights_type` with valid string |
| 76 | + # Specifies the retention period in days using `retention_in_days`. Default 90. |
| 77 | + # By default the real client ip is masked in the logs, to enable set `disable_ip_masking` to `true` |
| 78 | + app_insights_name = "otkpocshared" |
| 79 | +
|
| 80 | + # Adding TAG's to your Azure resources |
| 81 | + tags = { |
| 82 | + ProjectName = "demo-internal" |
| 83 | + Env = "dev" |
| 84 | + Owner = "user@example.com" |
| 85 | + BusinessUnit = "CORP" |
| 86 | + ServiceClass = "Gold" |
| 87 | + } |
| 88 | +} |
| 89 | +``` |
| 90 | + |
| 91 | +## Terraform Usage |
| 92 | + |
| 93 | +To run this example you need to execute following Terraform commands |
| 94 | + |
| 95 | +```hcl |
| 96 | +terraform init |
| 97 | +
|
| 98 | +terraform plan |
| 99 | +
|
| 100 | +terraform apply |
| 101 | +``` |
| 102 | + |
| 103 | +Run `terraform destroy` when you don't need these resources. |
0 commit comments