Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_windows[linux]_function[web]_app, azurerm_windows[linux]_function[web]_app_slot - add description property for ip_restriction block #24527

Merged
merged 9 commits into from
Mar 6, 2024
25 changes: 25 additions & 0 deletions internal/services/appservice/helpers/shared_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type IpRestriction struct {
Priority int64 `tfschema:"priority"`
Action string `tfschema:"action"`
Headers []IpRestrictionHeaders `tfschema:"headers"`
Description string `tfschema:"description"`
}

type IpRestrictionHeaders struct {
Expand Down Expand Up @@ -104,6 +105,13 @@ func IpRestrictionSchema() *pluginsdk.Schema {
},

"headers": IpRestrictionHeadersSchema(),

"description": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: validation.StringIsNotEmpty,
Description: "The description of the IP restriction rule.",
},
},
},
}
Expand Down Expand Up @@ -153,6 +161,12 @@ func IpRestrictionSchemaComputed() *pluginsdk.Schema {
},

"headers": IpRestrictionHeadersSchemaComputed(),

"description": {
Type: pluginsdk.TypeString,
Computed: true,
Description: "The description of the ip restriction rule.",
},
},
},
}
Expand Down Expand Up @@ -1157,6 +1171,12 @@ func ExpandIpRestrictions(restrictions []IpRestriction) (*[]webapps.IPSecurityRe

restriction.Priority = pointer.To(v.Priority)

if v.Description != "" {
restriction.Description = utils.String(v.Description)
}

restriction.Priority = utils.Int64(v.Priority)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we replace these with pointer.To() as we're aiming to remove the utils package?

Suggested change
restriction.Description = utils.String(v.Description)
}
restriction.Priority = utils.Int64(v.Priority)
restriction.Description = pointer.To(v.Description)
}
restriction.Priority = pointer.To(v.Priority)


restriction.Action = pointer.To(v.Action)

restriction.Headers = expandIpRestrictionHeaders(v.Headers)
Expand Down Expand Up @@ -1492,6 +1512,11 @@ func FlattenIpRestrictions(ipRestrictionsList *[]webapps.IPSecurityRestriction)
ipRestriction.Action = *v.Action
}

ipRestriction.Headers = flattenIpRestrictionHeaders(pointer.From(v.Headers))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line appears to have been duplicated? (L1520 below)

if v.Description != nil {
ipRestriction.Description = *v.Description
}

ipRestriction.Headers = flattenIpRestrictionHeaders(pointer.From(v.Headers))

ipRestrictions = append(ipRestrictions, ipRestriction)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1858,6 +1858,7 @@ resource "azurerm_linux_function_app" "test" {
x_forwarded_for = ["9.9.9.9/32", "2002::1234:abcd:ffff:c0a8:101/64"]
x_forwarded_host = ["example.com"]
}
description = "Allow ip address linux function app"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2202,6 +2202,7 @@ resource "azurerm_linux_function_app_slot" "test" {
x_forwarded_for = ["9.9.9.9/32", "2002::1234:abcd:ffff:c0a8:101/64"]
x_forwarded_host = ["example.com"]
}
description = "Allow ip address 10.10.10.10/32"
}

load_balancing_mode = "LeastResponseTime"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2478,6 +2478,7 @@ resource "azurerm_linux_web_app" "test" {
x_forwarded_for = ["9.9.9.9/32", "2002::1234:abcd:ffff:c0a8:101/64"]
x_forwarded_host = ["example.com"]
}
description = "Allow ip address 10.10.10.10/32"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2060,6 +2060,7 @@ resource "azurerm_linux_web_app_slot" "test" {
x_forwarded_for = ["9.9.9.9/32", "2002::1234:abcd:ffff:c0a8:101/64"]
x_forwarded_host = ["example.com"]
}
description = "Allow ip address linux web app slot"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2232,6 +2232,7 @@ resource "azurerm_windows_function_app" "test" {
x_forwarded_for = ["9.9.9.9/32", "2002::1234:abcd:ffff:c0a8:101/64"]
x_forwarded_host = ["example.com"]
}
description = "Allow ip address 10.10.10.10/32"
}

load_balancing_mode = "LeastResponseTime"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,7 @@ resource "azurerm_windows_function_app_slot" "test" {
x_forwarded_for = ["9.9.9.9/32", "2002::1234:abcd:ffff:c0a8:101/64"]
x_forwarded_host = ["example.com"]
}
description = "Allow ip address windows function app slot"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1971,6 +1971,7 @@ resource "azurerm_windows_web_app" "test" {
x_forwarded_for = ["9.9.9.9/32", "2002::1234:abcd:ffff:c0a8:101/64"]
x_forwarded_host = ["example.com"]
}
description = "Allow ip address 10.10.10.10/32"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1680,6 +1680,7 @@ resource "azurerm_windows_web_app_slot" "test" {
x_forwarded_for = ["9.9.9.9/32", "2002::1234:abcd:ffff:c0a8:101/64"]
x_forwarded_host = ["example.com"]
}
description = "Allow ip address 10.10.10.10/32"
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/linux_function_app.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ An `ip_restriction` block supports the following:

~> **NOTE:** One and only one of `ip_address`, `service_tag` or `virtual_network_subnet_id` must be specified.

* `description` - (Optional) The Description of this IP Restriction.
---

A `microsoft` block supports the following:
Expand Down Expand Up @@ -633,6 +634,7 @@ A `scm_ip_restriction` block supports the following:

~> **NOTE:** One and only one of `ip_address`, `service_tag` or `virtual_network_subnet_id` must be specified.

* `description` - (Optional) The Description of this IP Restriction.
---

A `site_config` block supports the following:
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/linux_function_app_slot.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,7 @@ An `ip_restriction` block supports the following:

~> **NOTE:** One and only one of `ip_address`, `service_tag` or `virtual_network_subnet_id` must be specified.

* `description` - (Optional) The Description of this IP Restriction.
---

A `scm_ip_restriction` block supports the following:
Expand All @@ -720,6 +721,7 @@ A `scm_ip_restriction` block supports the following:

~> **NOTE:** One and only one of `ip_address`, `service_tag` or `virtual_network_subnet_id` must be specified.

* `description` - (Optional) The Description of this IP Restriction.
---

A `storage_account` block supports the following:
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/linux_web_app.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ An `ip_restriction` block supports the following:

~> **NOTE:** One and only one of `ip_address`, `service_tag` or `virtual_network_subnet_id` must be specified.

* `description` - (Optional) The Description of this IP Restriction.
---

A `logs` block supports the following:
Expand Down Expand Up @@ -668,6 +669,7 @@ A `scm_ip_restriction` block supports the following:

~> **NOTE:** One and only one of `ip_address`, `service_tag` or `virtual_network_subnet_id` must be specified.

* `description` - (Optional) The Description of this IP Restriction.
---

A `site_config` block supports the following:
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/linux_web_app_slot.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@ An `ip_restriction` block supports the following:

~> **NOTE:** One and only one of `ip_address`, `service_tag` or `virtual_network_subnet_id` must be specified.

* `description` - (Optional) The Description of this IP Restriction.
---

A `logs` block supports the following:
Expand Down Expand Up @@ -672,6 +673,7 @@ A `scm_ip_restriction` block supports the following:

~> **NOTE:** One and only one of `ip_address`, `service_tag` or `virtual_network_subnet_id` must be specified.

* `description` - (Optional) The Description of this IP Restriction.
---

A `site_config` block supports the following:
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/windows_function_app.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ An `ip_restriction` block supports the following:

~> **NOTE:** One and only one of `ip_address`, `service_tag` or `virtual_network_subnet_id` must be specified.

* `description` - (Optional) The Description of this IP Restriction.
---

A `microsoft` block supports the following:
Expand Down Expand Up @@ -613,6 +614,7 @@ A `scm_ip_restriction` block supports the following:

~> **NOTE:** One and only one of `ip_address`, `service_tag` or `virtual_network_subnet_id` must be specified.

* `description` - (Optional) The Description of this IP Restriction.
---

A `site_config` block supports the following:
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/windows_function_app_slot.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ An `ip_restriction` block supports the following:

~> **NOTE:** One and only one of `ip_address`, `service_tag` or `virtual_network_subnet_id` must be specified.

* `description` - (Optional) The Description of this IP Restriction.
---

A `scm_ip_restriction` block supports the following:
Expand All @@ -679,6 +680,7 @@ A `scm_ip_restriction` block supports the following:

~> **NOTE:** Exactly one of `ip_address`, `service_tag` or `virtual_network_subnet_id` must be specified.

* `description` - (Optional) The Description of this IP Restriction.
---

A `headers` block supports the following:
Expand Down
3 changes: 3 additions & 0 deletions website/docs/r/windows_web_app.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,8 @@ A `ip_restriction` block supports the following:

~> **NOTE:** One and only one of `ip_address`, `service_tag` or `virtual_network_subnet_id` must be specified.

* `description` - (Optional) The Description of this IP Restriction.

---

A `logs` block supports the following:
Expand Down Expand Up @@ -693,6 +695,7 @@ A `scm_ip_restriction` block supports the following:

~> **NOTE:** One and only one of `ip_address`, `service_tag` or `virtual_network_subnet_id` must be specified.

* `description` - (Optional) The Description of this IP Restriction.
---

A `site_config` block supports the following:
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/windows_web_app_slot.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ A `ip_restriction` block supports the following:

~> **NOTE:** One and only one of `ip_address`, `service_tag` or `virtual_network_subnet_id` must be specified.

* `description` - (Optional) The Description of this IP Restriction.
---

A `logs` block supports the following:
Expand Down Expand Up @@ -688,6 +689,7 @@ A `scm_ip_restriction` block supports the following:

~> **NOTE:** One and only one of `ip_address`, `service_tag` or `virtual_network_subnet_id` must be specified.

* `description` - (Optional) The Description of this IP Restriction.
---

A `site_config` block supports the following:
Expand Down
Loading