|
| 1 | + |
| 2 | +Update to a supported Python version (3.9 or higher). Consider migrating from azurerm_app_service to azurerm_linux_web_app for access to modern Python versions. |
| 3 | + |
| 4 | +```hcl |
| 5 | +# Supported Python version (3.9 or higher) |
| 6 | +resource "azurerm_app_service" "good_example_supported" { |
| 7 | + name = "example-app-service" |
| 8 | + location = azurerm_resource_group.example.location |
| 9 | + resource_group_name = azurerm_resource_group.example.name |
| 10 | + app_service_plan_id = azurerm_app_service_plan.example.id |
| 11 | +
|
| 12 | + site_config { |
| 13 | + python_version = "3.9" |
| 14 | + } |
| 15 | +} |
| 16 | +``` |
| 17 | +```hcl |
| 18 | +# Current stable version |
| 19 | +resource "azurerm_app_service" "good_example_current" { |
| 20 | + name = "example-app-service" |
| 21 | + location = azurerm_resource_group.example.location |
| 22 | + resource_group_name = azurerm_resource_group.example.name |
| 23 | + app_service_plan_id = azurerm_app_service_plan.example.id |
| 24 | +
|
| 25 | + site_config { |
| 26 | + python_version = "3.12" |
| 27 | + } |
| 28 | +} |
| 29 | +``` |
| 30 | +```hcl |
| 31 | +# No Python version specified - not using Python |
| 32 | +resource "azurerm_app_service" "good_example_no_python" { |
| 33 | + name = "example-app-service" |
| 34 | + location = azurerm_resource_group.example.location |
| 35 | + resource_group_name = azurerm_resource_group.example.name |
| 36 | + app_service_plan_id = azurerm_app_service_plan.example.id |
| 37 | +
|
| 38 | + site_config { |
| 39 | + # No Python version specified - not using Python |
| 40 | + } |
| 41 | +} |
| 42 | +``` |
| 43 | +```hcl |
| 44 | +# Modern Linux Web App with latest Python (recommended approach) |
| 45 | +resource "azurerm_linux_web_app" "good_example_modern" { |
| 46 | + name = "example-linux-webapp" |
| 47 | + location = azurerm_resource_group.example.location |
| 48 | + resource_group_name = azurerm_resource_group.example.name |
| 49 | + service_plan_id = azurerm_service_plan.example.id |
| 50 | +
|
| 51 | + site_config { |
| 52 | + application_stack { |
| 53 | + python_version = "3.12" |
| 54 | + } |
| 55 | + } |
| 56 | +} |
| 57 | +``` |
| 58 | + |
| 59 | +#### Remediation Links |
| 60 | + - https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/app_service#python_version |
| 61 | + |
| 62 | + - https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_web_app#python_version |
| 63 | + |
0 commit comments