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_security_center_setting - Allow Sentinel to be the valid setting_name #24210

Merged
merged 2 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security" // nolint: staticcheck
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/features"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/securitycenter/azuresdkhacks"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/securitycenter/parse"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
Expand All @@ -20,6 +21,17 @@ import (
// TODO: this resource should be split into data_export_setting and alert_sync_setting

func resourceSecurityCenterSetting() *pluginsdk.Resource {
validSettingName := []string{
"MCAS",
"WDATP",
"Sentinel",
}
if !features.FourPointOhBeta() {
// This is for backward compatibility.. The swagger defines the valid enum to be "Sensinel" (see below), so this ("SENTINEL") shall be removed since 4.0.
// https://github.com/Azure/azure-rest-api-specs/blob/b52464f520b77222ac8b0bdeb80a030c0fdf5b1b/specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/settings.json#L285
validSettingName = append(validSettingName, "SENTINEL")
}

return &pluginsdk.Resource{
Create: resourceSecurityCenterSettingUpdate,
Read: resourceSecurityCenterSettingRead,
Expand All @@ -40,14 +52,10 @@ func resourceSecurityCenterSetting() *pluginsdk.Resource {

Schema: map[string]*pluginsdk.Schema{
"setting_name": {
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
"MCAS",
"WDATP",
"SENTINEL",
}, false),
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice(validSettingName, false),
},
"enabled": {
Type: pluginsdk.TypeBool,
Expand Down Expand Up @@ -146,7 +154,7 @@ func expandSecurityCenterSetting(name string, enabled bool) (security.BasicSetti
Enabled: &enabled,
},
}, nil
case "SENTINEL":
case "SENTINEL", "Sentinel":
return security.AlertSyncSettings{
AlertSyncSettingProperties: &security.AlertSyncSettingProperties{
Enabled: &enabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ func testAccSecurityCenterSetting_update(t *testing.T) {
},
data.ImportStep(),
{
Config: r.cfg("SENTINEL", true),
Config: r.cfg("Sentinel", true),
Check: acceptance.ComposeTestCheckFunc(),
},
data.ImportStep(),
{
Config: r.cfg("SENTINEL", false),
Config: r.cfg("Sentinel", false),
Check: acceptance.ComposeTestCheckFunc(),
},
data.ImportStep(),
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/security_center_setting.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ resource "azurerm_security_center_setting" "example" {

The following arguments are supported:

* `setting_name` - (Required) The setting to manage. Possible values are `MCAS` , `WDATP` and `SENTINEL`. Changing this forces a new resource to be created.
* `setting_name` - (Required) The setting to manage. Possible values are `MCAS` , `WDATP` and `Sentinel`. Changing this forces a new resource to be created.
* `enabled` - (Required) Boolean flag to enable/disable data access.

## Attributes Reference
Expand Down
Loading