Skip to content

Commit 0a8e622

Browse files
donovm4dave92082
andauthored
feat: fixes for auto heal settings (#185)
* Fixes for Auto Scaling Settings (#184) * Fix status code range definition * Fix missing defaults for auto_heal_setting request trigger * Update requests trigger to optional map to match other triggers * Fix slow_request dynamics and add dynamic requests for #183 * Update variable name take_taken to time_taken to match with the implementation and underlying azurerm module * linting fixes; minor bug fixes; version references; * linitng fixes 2 --------- Co-authored-by: David Suarez <1847875+dave92082@users.noreply.github.com>
1 parent afcbd5d commit 0a8e622

36 files changed

Lines changed: 211 additions & 175 deletions

File tree

README.md

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ Description:
587587
- `slow_request` - (Optional) The slow request trigger to activate the action.
588588
- `count` - (Required) The number of slow requests to trigger the action.
589589
- `interval` - (Required) The interval to trigger the action.
590-
- `take_taken` - (Required) The time taken to trigger the action.
590+
- `time_taken` - (Required) The time taken to trigger the action.
591591
- `path` - (Optional) The path to trigger the action.
592592
> NOTE: The `path` property in the `slow_request` block is deprecated and will be removed in 4.0 of provider. Please use `slow_request_with_path` to set a slow request trigger with `path` specified.
593593
- `status_code` - (Optional) The status code trigger to activate the action.
@@ -599,10 +599,7 @@ Description:
599599
- `win32_status_code` - (Optional) The Win32 status code to trigger the action.
600600

601601
```terraform
602-
site_config = {
603-
auto_heal_enabled = true # `auto_heal_enabled` deprecated in azurerm 4.x
604-
}
605-
auto_heal_setting = { # auto_heal_setting should only be specified if auto_heal_enabled is set to `true`
602+
auto_heal_setting = {
606603
setting_1 = {
607604
action = {
608605
action_type = "Recycle"
@@ -648,26 +645,26 @@ map(object({
648645
}))
649646
trigger = optional(object({
650647
private_memory_kb = optional(number)
651-
requests = optional(object({
648+
requests = optional(map(object({
652649
count = number
653650
interval = string
654-
}))
651+
})), {})
655652
slow_request = optional(map(object({
656653
count = number
657654
interval = string
658-
take_taken = string
655+
time_taken = string
659656
path = optional(string)
660657
})), {})
661658
slow_request_with_path = optional(map(object({
662659
count = number
663660
interval = string
664-
take_taken = string
661+
time_taken = string
665662
path = optional(string)
666663
})), {})
667664
status_code = optional(map(object({
668665
count = number
669666
interval = string
670-
status_code_range = number
667+
status_code_range = string
671668
path = optional(string)
672669
sub_status = optional(number)
673670
win32_status_code = optional(number)
@@ -1093,26 +1090,26 @@ map(object({
10931090
}))
10941091
trigger = optional(object({
10951092
private_memory_kb = optional(number)
1096-
requests = optional(object({
1093+
requests = optional(map(object({
10971094
count = number
10981095
interval = string
1099-
}))
1096+
})), {})
11001097
slow_request = optional(map(object({
11011098
count = number
11021099
interval = string
1103-
take_taken = string
1100+
time_taken = string
11041101
path = optional(string)
11051102
})), {})
11061103
slow_request_with_path = optional(map(object({
11071104
count = number
11081105
interval = string
1109-
take_taken = string
1106+
time_taken = string
11101107
path = optional(string)
11111108
})), {})
11121109
status_code = optional(map(object({
11131110
count = number
11141111
interval = string
1115-
status_code_range = number
1112+
status_code_range = string
11161113
path = optional(string)
11171114
sub_status = optional(number)
11181115
win32_status_code = optional(number)
@@ -1788,12 +1785,12 @@ Type:
17881785

17891786
```hcl
17901787
object({
1791-
always_on = optional(bool, true)
1792-
linux_fx_version = optional(string)
1793-
api_definition_url = optional(string)
1794-
api_management_api_id = optional(string)
1795-
app_command_line = optional(string)
1796-
auto_heal_enabled = optional(bool)
1788+
always_on = optional(bool, true)
1789+
linux_fx_version = optional(string)
1790+
api_definition_url = optional(string)
1791+
api_management_api_id = optional(string)
1792+
app_command_line = optional(string)
1793+
# auto_heal_enabled = optional(bool)
17971794
dotnet_framework_version = optional(string, "v4.0")
17981795
auto_swap_slot_name = optional(string)
17991796
app_scale_limit = optional(number)

examples/auto_heal_enabled/README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,19 @@ resource "azurerm_service_plan" "example" {
4040
}
4141
}
4242
43+
resource "azurerm_log_analytics_workspace" "example" {
44+
location = azurerm_resource_group.example.location
45+
name = "${module.naming.log_analytics_workspace.name}-auto-heal"
46+
resource_group_name = azurerm_resource_group.example.name
47+
retention_in_days = 30
48+
sku = "PerGB2018"
49+
}
50+
4351
module "avm_res_web_site" {
4452
source = "../../"
4553
4654
# source = "Azure/avm-res-web-site/azurerm"
47-
# version = "0.15.2"
55+
# version = "0.16.0"
4856
4957
enable_telemetry = var.enable_telemetry
5058
@@ -57,19 +65,26 @@ module "avm_res_web_site" {
5765
os_type = azurerm_service_plan.example.os_type
5866
service_plan_resource_id = azurerm_service_plan.example.id
5967
68+
application_insights = {
69+
workspace_resource_id = azurerm_log_analytics_workspace.example.id
70+
}
71+
6072
site_config = {
6173
6274
}
63-
auto_heal_setting = { # auto_heal_setting should only be specified if auto_heal_enabled is set to `true`
75+
76+
auto_heal_setting = {
6477
setting_1 = {
6578
action = {
6679
action_type = "Recycle"
6780
minimum_process_execution_time = "00:01:00"
6881
}
6982
trigger = {
7083
requests = {
71-
count = 100
72-
interval = "00:00:30"
84+
request = {
85+
count = 100
86+
interval = "00:00:30"
87+
}
7388
}
7489
status_code = {
7590
status_5000 = {
@@ -108,6 +123,7 @@ The following requirements are needed by this module:
108123

109124
The following resources are used by this module:
110125

126+
- [azurerm_log_analytics_workspace.example](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/log_analytics_workspace) (resource)
111127
- [azurerm_resource_group.example](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) (resource)
112128
- [azurerm_service_plan.example](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/service_plan) (resource)
113129
- [random_integer.region_index](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/integer) (resource)

examples/auto_heal_enabled/main.tf

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,19 @@ resource "azurerm_service_plan" "example" {
3434
}
3535
}
3636

37+
resource "azurerm_log_analytics_workspace" "example" {
38+
location = azurerm_resource_group.example.location
39+
name = "${module.naming.log_analytics_workspace.name}-auto-heal"
40+
resource_group_name = azurerm_resource_group.example.name
41+
retention_in_days = 30
42+
sku = "PerGB2018"
43+
}
44+
3745
module "avm_res_web_site" {
3846
source = "../../"
3947

4048
# source = "Azure/avm-res-web-site/azurerm"
41-
# version = "0.15.2"
49+
# version = "0.16.0"
4250

4351
enable_telemetry = var.enable_telemetry
4452

@@ -51,19 +59,26 @@ module "avm_res_web_site" {
5159
os_type = azurerm_service_plan.example.os_type
5260
service_plan_resource_id = azurerm_service_plan.example.id
5361

62+
application_insights = {
63+
workspace_resource_id = azurerm_log_analytics_workspace.example.id
64+
}
65+
5466
site_config = {
5567

5668
}
57-
auto_heal_setting = { # auto_heal_setting should only be specified if auto_heal_enabled is set to `true`
69+
70+
auto_heal_setting = {
5871
setting_1 = {
5972
action = {
6073
action_type = "Recycle"
6174
minimum_process_execution_time = "00:01:00"
6275
}
6376
trigger = {
6477
requests = {
65-
count = 100
66-
interval = "00:00:30"
78+
request = {
79+
count = 100
80+
interval = "00:00:30"
81+
}
6782
}
6883
status_code = {
6984
status_5000 = {
Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
terraform {
2-
required_version = "~> 1.9"
1+
terraform {
2+
required_version = "~> 1.9"
33
required_providers {
4-
azurerm = {
5-
source = "hashicorp/azurerm"
6-
version = "~> 4.0"
7-
}
8-
random = {
9-
source = "hashicorp/random"
10-
version = ">= 3.5.0, < 4.0.0"
11-
}
12-
}
13-
}
14-
15-
# tflint-ignore: terraform_module_provider_declaration, terraform_output_separate, terraform_variable_separate
16-
provider "azurerm" {
17-
features {
18-
resource_group {
19-
prevent_deletion_if_contains_resources = false
20-
}
21-
}
22-
23-
subscription_id = "<subscription-id>"
24-
25-
}
4+
azurerm = {
5+
source = "hashicorp/azurerm"
6+
version = "~> 4.0"
7+
}
8+
random = {
9+
source = "hashicorp/random"
10+
version = ">= 3.5.0, < 4.0.0"
11+
}
12+
}
13+
}
14+
15+
# tflint-ignore: terraform_module_provider_declaration, terraform_output_separate, terraform_variable_separate
16+
provider "azurerm" {
17+
features {
18+
resource_group {
19+
prevent_deletion_if_contains_resources = false
20+
}
21+
}
22+
23+
subscription_id = "<subscription_id>"
24+
25+
}

examples/basic_auth/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ module "avm_res_web_site" {
5858
source = "../../"
5959
6060
# source = "Azure/avm-res-web-site/azurerm"
61-
# version = "0.15.2"
61+
# version = "0.16.0"
6262
6363
enable_telemetry = var.enable_telemetry
6464

examples/basic_auth/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ module "avm_res_web_site" {
5151
source = "../../"
5252

5353
# source = "Azure/avm-res-web-site/azurerm"
54-
# version = "0.15.2"
54+
# version = "0.16.0"
5555

5656
enable_telemetry = var.enable_telemetry
5757

examples/custom_container/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ module "avm_res_web_site" {
6767
source = "../../"
6868
6969
# source = "Azure/avm-res-web-site/azurerm"
70-
# version = "0.15.2"
70+
# version = "0.16.0"
7171
7272
enable_telemetry = var.enable_telemetry
7373
@@ -100,7 +100,7 @@ module "avm_res_web_site" {
100100
101101
tags = {
102102
module = "Azure/avm-res-web-site/azurerm"
103-
version = "0.15.2"
103+
version = "0.16.0"
104104
}
105105
106106
}

examples/custom_container/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ module "avm_res_web_site" {
6161
source = "../../"
6262

6363
# source = "Azure/avm-res-web-site/azurerm"
64-
# version = "0.15.2"
64+
# version = "0.16.0"
6565

6666
enable_telemetry = var.enable_telemetry
6767

@@ -94,7 +94,7 @@ module "avm_res_web_site" {
9494

9595
tags = {
9696
module = "Azure/avm-res-web-site/azurerm"
97-
version = "0.15.2"
97+
version = "0.16.0"
9898
}
9999

100100
}

examples/custom_domain/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ module "avm_res_web_site" {
7070
source = "../../"
7171
7272
# source = "Azure/avm-res-web-site/azurerm"
73-
# version = "0.15.2"
73+
# version = "0.16.0"
7474
7575
enable_telemetry = var.enable_telemetry
7676

examples/custom_domain/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ module "avm_res_web_site" {
6666
source = "../../"
6767

6868
# source = "Azure/avm-res-web-site/azurerm"
69-
# version = "0.15.2"
69+
# version = "0.16.0"
7070

7171
enable_telemetry = var.enable_telemetry
7272

0 commit comments

Comments
 (0)