Skip to content

Commit 7ec1951

Browse files
donovm4root
andauthored
update: vnet image fixes and vnet backup restore feature (#201)
* removing azapi components for webapp, functionapp * new functionality for vnet_image_pull_enabled and virtual_network_backup_restore_enabled features * avm scripts --------- Co-authored-by: root <[email protected]>
1 parent b9b3d83 commit 7ec1951

File tree

5 files changed

+63
-55
lines changed

5 files changed

+63
-55
lines changed

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ The following requirements are needed by this module:
1616

1717
- <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) (~> 1.11)
1818

19-
- <a name="requirement_azapi"></a> [azapi](#requirement\_azapi) (~> 2.0)
20-
2119
- <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) (~> 4.0, >= 4.8.0, >= 4.21.1, < 5.0.0)
2220

2321
- <a name="requirement_modtm"></a> [modtm](#requirement\_modtm) (~> 0.3)
@@ -28,10 +26,6 @@ The following requirements are needed by this module:
2826

2927
The following resources are used by this module:
3028

31-
- [azapi_update_resource.linux_functionapp](https://registry.terraform.io/providers/Azure/azapi/latest/docs/resources/update_resource) (resource)
32-
- [azapi_update_resource.linux_webapp](https://registry.terraform.io/providers/Azure/azapi/latest/docs/resources/update_resource) (resource)
33-
- [azapi_update_resource.windows_functionapp](https://registry.terraform.io/providers/Azure/azapi/latest/docs/resources/update_resource) (resource)
34-
- [azapi_update_resource.windows_webapp](https://registry.terraform.io/providers/Azure/azapi/latest/docs/resources/update_resource) (resource)
3529
- [azurerm_app_service_certificate.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/app_service_certificate) (resource)
3630
- [azurerm_app_service_custom_hostname_binding.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/app_service_custom_hostname_binding) (resource)
3731
- [azurerm_app_service_slot_custom_hostname_binding.slot](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/app_service_slot_custom_hostname_binding) (resource)
@@ -2132,6 +2126,14 @@ Type: `bool`
21322126

21332127
Default: `true`
21342128

2129+
### <a name="input_virtual_network_backup_restore_enabled"></a> [virtual\_network\_backup\_restore\_enabled](#input\_virtual\_network\_backup\_restore\_enabled)
2130+
2131+
Description: Should backup and restore operations over the linked virtual network are enabled? Defaults to `false`.
2132+
2133+
Type: `bool`
2134+
2135+
Default: `false`
2136+
21352137
### <a name="input_virtual_network_subnet_id"></a> [virtual\_network\_subnet\_id](#input\_virtual\_network\_subnet\_id)
21362138

21372139
Description: The ID of the subnet to deploy the Function App in.
@@ -2142,7 +2144,7 @@ Default: `null`
21422144

21432145
### <a name="input_vnet_image_pull_enabled"></a> [vnet\_image\_pull\_enabled](#input\_vnet\_image\_pull\_enabled)
21442146

2145-
Description: Should the App Service pull images from a Virtual Network? Defaults to `false`.
2147+
Description: Should the traffic for the image pull be routed over virtual network enabled? Defaults to `false`.
21462148

21472149
Type: `bool`
21482150

main.function_app.tf

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ resource "azurerm_windows_function_app" "this" {
2323
storage_key_vault_secret_id = var.storage_key_vault_secret_id
2424
storage_uses_managed_identity = var.storage_uses_managed_identity == true && var.storage_account_access_key == null ? var.storage_uses_managed_identity : null
2525
tags = var.tags
26+
virtual_network_backup_restore_enabled = var.virtual_network_backup_restore_enabled
2627
virtual_network_subnet_id = var.virtual_network_subnet_id
28+
vnet_image_pull_enabled = var.vnet_image_pull_enabled
2729
webdeploy_publish_basic_authentication_enabled = var.site_config.ftps_state == "Disabled" ? false : var.webdeploy_publish_basic_authentication_enabled
2830
zip_deploy_file = var.zip_deploy_file
2931

@@ -412,17 +414,17 @@ resource "azurerm_windows_function_app" "this" {
412414
}
413415
}
414416

415-
resource "azapi_update_resource" "windows_functionapp" {
416-
count = var.kind == "functionapp" && var.os_type == "Windows" && var.vnet_image_pull_enabled ? 1 : 0
417+
# resource "azapi_update_resource" "windows_functionapp" {
418+
# count = var.kind == "functionapp" && var.os_type == "Windows" && var.vnet_image_pull_enabled ? 1 : 0
417419

418-
resource_id = azurerm_windows_function_app.this[0].id
419-
type = "Microsoft.Web/sites@2024-04-01"
420-
body = {
421-
properties = {
422-
vnetImagePullEnabled = var.vnet_image_pull_enabled
423-
}
424-
}
425-
}
420+
# resource_id = azurerm_windows_function_app.this[0].id
421+
# type = "Microsoft.Web/sites@2024-04-01"
422+
# body = {
423+
# properties = {
424+
# vnetImagePullEnabled = var.vnet_image_pull_enabled
425+
# }
426+
# }
427+
# }
426428

427429
resource "azurerm_linux_function_app" "this" {
428430
count = var.kind == "functionapp" && var.os_type == "Linux" && var.function_app_uses_fc1 == false ? 1 : 0
@@ -449,7 +451,9 @@ resource "azurerm_linux_function_app" "this" {
449451
storage_key_vault_secret_id = var.storage_key_vault_secret_id
450452
storage_uses_managed_identity = var.storage_uses_managed_identity == true && var.storage_account_access_key == null ? var.storage_uses_managed_identity : null
451453
tags = var.tags
454+
virtual_network_backup_restore_enabled = var.virtual_network_backup_restore_enabled
452455
virtual_network_subnet_id = var.virtual_network_subnet_id
456+
vnet_image_pull_enabled = var.vnet_image_pull_enabled
453457
webdeploy_publish_basic_authentication_enabled = var.site_config.ftps_state == "Disabled" ? false : var.webdeploy_publish_basic_authentication_enabled
454458
zip_deploy_file = var.zip_deploy_file
455459

@@ -853,17 +857,17 @@ resource "azurerm_linux_function_app" "this" {
853857
}
854858
}
855859

856-
resource "azapi_update_resource" "linux_functionapp" {
857-
count = var.kind == "functionapp" && var.os_type == "Linux" && var.vnet_image_pull_enabled ? 1 : 0
858-
859-
resource_id = azurerm_linux_function_app.this[0].id
860-
type = "Microsoft.Web/sites@2024-04-01"
861-
body = {
862-
properties = {
863-
vnetImagePullEnabled = var.vnet_image_pull_enabled
864-
}
865-
}
866-
}
860+
# resource "azapi_update_resource" "linux_functionapp" {
861+
# count = var.kind == "functionapp" && var.os_type == "Linux" && var.vnet_image_pull_enabled ? 1 : 0
862+
863+
# resource_id = azurerm_linux_function_app.this[0].id
864+
# type = "Microsoft.Web/sites@2024-04-01"
865+
# body = {
866+
# properties = {
867+
# vnetImagePullEnabled = var.vnet_image_pull_enabled
868+
# }
869+
# }
870+
# }
867871

868872
resource "azurerm_function_app_flex_consumption" "this" {
869873
count = var.kind == "functionapp" && var.os_type == "Linux" && var.function_app_uses_fc1 == true ? 1 : 0

main.web_app.tf

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -527,17 +527,17 @@ resource "azurerm_windows_web_app" "this" {
527527
}
528528
}
529529

530-
resource "azapi_update_resource" "windows_webapp" {
531-
count = var.kind == "webapp" && var.os_type == "Windows" && var.vnet_image_pull_enabled ? 1 : 0
532-
533-
resource_id = azurerm_windows_web_app.this[0].id
534-
type = "Microsoft.Web/sites@2024-04-01"
535-
body = {
536-
properties = {
537-
vnetImagePullEnabled = var.vnet_image_pull_enabled
538-
}
539-
}
540-
}
530+
# resource "azapi_update_resource" "windows_webapp" {
531+
# count = var.kind == "webapp" && var.os_type == "Windows" && var.vnet_image_pull_enabled ? 1 : 0
532+
533+
# resource_id = azurerm_windows_web_app.this[0].id
534+
# type = "Microsoft.Web/sites@2024-04-01"
535+
# body = {
536+
# properties = {
537+
# vnetImagePullEnabled = var.vnet_image_pull_enabled
538+
# }
539+
# }
540+
# }
541541

542542
resource "azurerm_linux_web_app" "this" {
543543
count = var.kind == "webapp" && var.os_type == "Linux" ? 1 : 0
@@ -1044,14 +1044,14 @@ resource "azurerm_linux_web_app" "this" {
10441044
}
10451045
}
10461046

1047-
resource "azapi_update_resource" "linux_webapp" {
1048-
count = var.kind == "webapp" && var.os_type == "Linux" && var.vnet_image_pull_enabled ? 1 : 0
1049-
1050-
resource_id = azurerm_linux_web_app.this[0].id
1051-
type = "Microsoft.Web/sites@2024-04-01"
1052-
body = {
1053-
properties = {
1054-
vnetImagePullEnabled = var.vnet_image_pull_enabled
1055-
}
1056-
}
1057-
}
1047+
# resource "azapi_update_resource" "linux_webapp" {
1048+
# count = var.kind == "webapp" && var.os_type == "Linux" && var.vnet_image_pull_enabled ? 1 : 0
1049+
1050+
# resource_id = azurerm_linux_web_app.this[0].id
1051+
# type = "Microsoft.Web/sites@2024-04-01"
1052+
# body = {
1053+
# properties = {
1054+
# vnetImagePullEnabled = var.vnet_image_pull_enabled
1055+
# }
1056+
# }
1057+
# }

terraform.tf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
terraform {
22
required_version = "~> 1.11"
33
required_providers {
4-
azapi = {
5-
source = "Azure/azapi"
6-
version = "~> 2.0"
7-
}
84
azurerm = {
95
source = "hashicorp/azurerm"
106
version = "~> 4.0, >= 4.8.0, >= 4.21.1, < 5.0.0"

variables.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1498,6 +1498,12 @@ variable "use_extension_bundle" {
14981498
description = "Should the extension bundle be used? (Logic App)"
14991499
}
15001500

1501+
variable "virtual_network_backup_restore_enabled" {
1502+
type = bool
1503+
default = false
1504+
description = "Should backup and restore operations over the linked virtual network are enabled? Defaults to `false`."
1505+
}
1506+
15011507
variable "virtual_network_subnet_id" {
15021508
type = string
15031509
default = null
@@ -1507,7 +1513,7 @@ variable "virtual_network_subnet_id" {
15071513
variable "vnet_image_pull_enabled" {
15081514
type = bool
15091515
default = false
1510-
description = "Should the App Service pull images from a Virtual Network? Defaults to `false`."
1516+
description = "Should the traffic for the image pull be routed over virtual network enabled? Defaults to `false`."
15111517
}
15121518

15131519
variable "webdeploy_publish_basic_authentication_enabled" {

0 commit comments

Comments
 (0)