Skip to content

Commit

Permalink
Incorporate schema change suggestions from code review
Browse files Browse the repository at this point in the history
Signed-off-by: Owen Farrell <[email protected]>
  • Loading branch information
owenfarrell committed Sep 15, 2021
1 parent 35bf494 commit bdd4d1a
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func resourceSynapseSqlPoolSecurityAlertPolicyRead(d *pluginsdk.ResourceData, me
d.Set("sql_pool_id", sqlPoolId.ID())

if props := resp.SecurityAlertPolicyProperties; props != nil {
d.Set("state", string(props.State))
d.Set("policy_state", string(props.State))

if props.DisabledAlerts != nil {
disabledAlerts := pluginsdk.NewSet(pluginsdk.HashString, []interface{}{})
Expand All @@ -169,7 +169,7 @@ func resourceSynapseSqlPoolSecurityAlertPolicyRead(d *pluginsdk.ResourceData, me
}

if props.EmailAccountAdmins != nil {
d.Set("email_account_admins", props.EmailAccountAdmins)
d.Set("email_account_admins_enabled", props.EmailAccountAdmins)
}

if props.EmailAddresses != nil {
Expand Down Expand Up @@ -224,11 +224,11 @@ func resourceSynapseSqlPoolSecurityAlertPolicyDelete(d *pluginsdk.ResourceData,
}

func expandSQLPoolSecurityAlertPolicy(d *pluginsdk.ResourceData) *synapse.SQLPoolSecurityAlertPolicy {
state := synapse.SecurityAlertPolicyState(d.Get("state").(string))
policyState := synapse.SecurityAlertPolicyState(d.Get("policy_state").(string))

policy := synapse.SQLPoolSecurityAlertPolicy{
SecurityAlertPolicyProperties: &synapse.SecurityAlertPolicyProperties{
State: state,
State: policyState,
},
}

Expand All @@ -250,7 +250,7 @@ func expandSQLPoolSecurityAlertPolicy(d *pluginsdk.ResourceData) *synapse.SQLPoo
props.EmailAddresses = &emailAddresses
}

if v, ok := d.GetOk("email_account_admins"); ok {
if v, ok := d.GetOk("email_account_admins_enabled"); ok {
props.EmailAccountAdmins = utils.Bool(v.(bool))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (r SynapseSqlPoolSecurityAlertPolicyResource) basic(data acceptance.TestDat
resource "azurerm_synapse_sql_pool_security_alert_policy" "test" {
sql_pool_id = azurerm_synapse_sql_pool.test.id
state = "Enabled"
policy_state = "Enabled"
storage_endpoint = azurerm_storage_account.test.primary_blob_endpoint
storage_account_access_key = azurerm_storage_account.test.primary_access_key
retention_days = 20
Expand All @@ -93,10 +93,10 @@ func (r SynapseSqlPoolSecurityAlertPolicyResource) update(data acceptance.TestDa
%[1]s
resource "azurerm_synapse_sql_pool_security_alert_policy" "test" {
sql_pool_id = azurerm_synapse_sql_pool.test.id
state = "Enabled"
email_account_admins = true
retention_days = 30
sql_pool_id = azurerm_synapse_sql_pool.test.id
policy_state = "Enabled"
email_account_admins_enabled = true
retention_days = 30
}
`, r.template(data))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ resource "azurerm_synapse_sql_pool_vulnerability_assessment" "test" {
storage_account_access_key = azurerm_storage_account.test.primary_access_key
recurring_scans {
enabled = true
email_subscription_admins = true
enabled = true
email_subscription_admins_enabled = true
emails = [
"[email protected]",
"[email protected]"
Expand Down Expand Up @@ -160,7 +160,7 @@ resource "azurerm_storage_container" "test" {
resource "azurerm_synapse_sql_pool_security_alert_policy" "test" {
sql_pool_id = azurerm_synapse_sql_pool.test.id
state = "Enabled"
policy_state = "Enabled"
storage_endpoint = azurerm_storage_account.test.primary_blob_endpoint
storage_account_access_key = azurerm_storage_account.test.primary_access_key
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func resourceSynapseWorkspaceSecurityAlertPolicyRead(d *pluginsdk.ResourceData,
d.Set("synapse_workspace_id", workspaceId.ID())

if props := resp.ServerSecurityAlertPolicyProperties; props != nil {
d.Set("state", string(props.State))
d.Set("policy_state", string(props.State))

if props.DisabledAlerts != nil {
disabledAlerts := pluginsdk.NewSet(pluginsdk.HashString, []interface{}{})
Expand All @@ -173,7 +173,7 @@ func resourceSynapseWorkspaceSecurityAlertPolicyRead(d *pluginsdk.ResourceData,
}

if props.EmailAccountAdmins != nil {
d.Set("email_account_admins", props.EmailAccountAdmins)
d.Set("email_account_admins_enabled", props.EmailAccountAdmins)
}

if props.EmailAddresses != nil {
Expand Down Expand Up @@ -232,11 +232,11 @@ func resourceSynapseWorkspaceSecurityAlertPolicyDelete(d *pluginsdk.ResourceData
}

func expandServerSecurityAlertPolicy(d *pluginsdk.ResourceData) *synapse.ServerSecurityAlertPolicy {
state := synapse.SecurityAlertPolicyState(d.Get("state").(string))
policyState := synapse.SecurityAlertPolicyState(d.Get("policy_state").(string))

policy := synapse.ServerSecurityAlertPolicy{
ServerSecurityAlertPolicyProperties: &synapse.ServerSecurityAlertPolicyProperties{
State: state,
State: policyState,
},
}

Expand All @@ -258,7 +258,7 @@ func expandServerSecurityAlertPolicy(d *pluginsdk.ResourceData) *synapse.ServerS
props.EmailAddresses = &emailAddresses
}

if v, ok := d.GetOk("email_account_admins"); ok {
if v, ok := d.GetOk("email_account_admins_enabled"); ok {
props.EmailAccountAdmins = utils.Bool(v.(bool))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (r SynapseWorkspaceSecurityAlertPolicyResource) basic(data acceptance.TestD
resource "azurerm_synapse_workspace_security_alert_policy" "test" {
synapse_workspace_id = azurerm_synapse_workspace.test.id
state = "Enabled"
policy_state = "Enabled"
storage_endpoint = azurerm_storage_account.test.primary_blob_endpoint
storage_account_access_key = azurerm_storage_account.test.primary_access_key
retention_days = 20
Expand All @@ -93,10 +93,10 @@ func (r SynapseWorkspaceSecurityAlertPolicyResource) update(data acceptance.Test
%[1]s
resource "azurerm_synapse_workspace_security_alert_policy" "test" {
synapse_workspace_id = azurerm_synapse_workspace.test.id
state = "Enabled"
email_account_admins = true
retention_days = 30
synapse_workspace_id = azurerm_synapse_workspace.test.id
policy_state = "Enabled"
email_account_admins_enabled = true
retention_days = 30
}
`, r.template(data))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func expandRecurringScans(d *pluginsdk.ResourceData) *synapse.VulnerabilityAsses
props.IsEnabled = utils.Bool(enabled.(bool))
}

if emailSubscriptionAdmins, ok := v["email_subscription_admins"]; ok {
if emailSubscriptionAdmins, ok := v["email_subscription_admins_enabled"]; ok {
props.EmailSubscriptionAdmins = utils.Bool(emailSubscriptionAdmins.(bool))
}

Expand All @@ -256,7 +256,7 @@ func flattenRecurringScans(props *synapse.VulnerabilityAssessmentRecurringScansP
}

if emailSubscriptionAdmins := props.EmailSubscriptionAdmins; emailSubscriptionAdmins != nil {
result["email_subscription_admins"] = *props.EmailSubscriptionAdmins
result["email_subscription_admins_enabled"] = *props.EmailSubscriptionAdmins
}

if props.Emails != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ resource "azurerm_synapse_workspace_vulnerability_assessment" "test" {
storage_account_access_key = azurerm_storage_account.test.primary_access_key
recurring_scans {
enabled = true
email_subscription_admins = true
enabled = true
email_subscription_admins_enabled = true
emails = [
"[email protected]",
"[email protected]"
Expand Down Expand Up @@ -153,7 +153,7 @@ resource "azurerm_storage_container" "test" {
resource "azurerm_synapse_workspace_security_alert_policy" "test" {
synapse_workspace_id = azurerm_synapse_workspace.test.id
state = "Enabled"
policy_state = "Enabled"
storage_endpoint = azurerm_storage_account.test.primary_blob_endpoint
storage_account_access_key = azurerm_storage_account.test.primary_access_key
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ resource "azurerm_storage_account" "audit_logs" {
resource "azurerm_synapse_sql_pool_security_alert_policy" "example" {
sql_pool_id = azurerm_synapse_sql_pool.example.id
state = "Enabled"
policy_state = "Enabled"
storage_endpoint = azurerm_storage_account.audit_logs.primary_blob_endpoint
storage_account_access_key = azurerm_storage_account.audit_logs.primary_access_key
disabled_alerts = [
Expand All @@ -87,11 +87,11 @@ The following arguments are supported:

* `sql_pool_id` - (Required) Specifies the ID of the Synapse SQL Pool. Changing this forces a new resource to be created.

* `state` - (Required) Specifies the state of the policy, whether it is enabled or disabled or a policy has not been applied yet on the specific SQL pool. Allowed values are: `Disabled`, `Enabled`.
* `policy_state` - (Required) Specifies the state of the policy, whether it is enabled or disabled or a policy has not been applied yet on the specific SQL pool. Allowed values are: `Disabled`, `Enabled`.

* `disabled_alerts` - (Optional) Specifies an array of alerts that are disabled. Allowed values are: `Sql_Injection`, `Sql_Injection_Vulnerability`, `Access_Anomaly`, `Data_Exfiltration`, `Unsafe_Action`.

* `email_account_admins` - (Optional) Boolean flag which specifies if the alert is sent to the account administrators or not. Defaults to `false`.
* `email_account_admins_enabled` - (Optional) Boolean flag which specifies if the alert is sent to the account administrators or not. Defaults to `false`.

* `email_addresses` - (Optional) Specifies an array of e-mail addresses to which the alert is sent.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ resource "azurerm_storage_account" "audit_logs" {
resource "azurerm_synapse_sql_pool_security_alert_policy" "example" {
sql_pool_id = azurerm_synapse_sql_pool.example.id
state = "Enabled"
policy_state = "Enabled"
storage_endpoint = azurerm_storage_account.audit_logs.primary_blob_endpoint
storage_account_access_key = azurerm_storage_account.audit_logs.primary_access_key
disabled_alerts = [
Expand All @@ -86,8 +86,8 @@ resource "azurerm_synapse_sql_pool_vulnerability_assessment" "example" {
storage_account_access_key = azurerm_storage_account.example.primary_access_key
recurring_scans {
enabled = true
email_subscription_admins = true
enabled = true
email_subscription_admins_enabled = true
emails = [
"[email protected]",
"[email protected]"
Expand Down Expand Up @@ -115,7 +115,7 @@ The following arguments are supported:
`recurring_scans` supports the following:

* `enabled` - (Optional) Boolean flag which specifies if recurring scans is enabled or disabled. Defaults to `false`.
* `email_subscription_admins` - (Optional) Boolean flag which specifies if the schedule scan notification will be sent to the subscription administrators. Defaults to `false`.
* `email_subscription_admins_enabled` - (Optional) Boolean flag which specifies if the schedule scan notification will be sent to the subscription administrators. Defaults to `false`.
* `emails` - (Optional) Specifies an array of e-mail addresses to which the scan notification is sent.

## Attributes Reference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ resource "azurerm_storage_account" "audit_logs" {
resource "azurerm_synapse_workspace_security_alert_policy" "example" {
synapse_workspace_id = azurerm_synapse_workspace.example.id
state = "Enabled"
policy_state = "Enabled"
storage_endpoint = azurerm_storage_account.audit_logs.primary_blob_endpoint
storage_account_access_key = azurerm_storage_account.audit_logs.primary_access_key
disabled_alerts = [
Expand All @@ -80,11 +80,11 @@ The following arguments are supported:

* `synapse_workspace_id` - (Required) Specifies the ID of the Synapse Workspace. Changing this forces a new resource to be created.

* `state` - (Required) Specifies the state of the policy, whether it is enabled or disabled or a policy has not been applied yet on the specific workspace. Allowed values are: `Disabled`, `Enabled`.
* `policy_state` - (Required) Specifies the state of the policy, whether it is enabled or disabled or a policy has not been applied yet on the specific workspace. Allowed values are: `Disabled`, `Enabled`.

* `disabled_alerts` - (Optional) Specifies an array of alerts that are disabled. Allowed values are: `Sql_Injection`, `Sql_Injection_Vulnerability`, `Access_Anomaly`, `Data_Exfiltration`, `Unsafe_Action`.

* `email_account_admins` - (Optional) Boolean flag which specifies if the alert is sent to the account administrators or not. Defaults to `false`.
* `email_account_admins_enabled` - (Optional) Boolean flag which specifies if the alert is sent to the account administrators or not. Defaults to `false`.

* `email_addresses` - (Optional) Specifies an array of e-mail addresses to which the alert is sent.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ resource "azurerm_storage_account" "audit_logs" {
resource "azurerm_synapse_workspace_security_alert_policy" "example" {
synapse_workspace_id = azurerm_synapse_workspace.example.id
state = "Enabled"
policy_state = "Enabled"
storage_endpoint = azurerm_storage_account.audit_logs.primary_blob_endpoint
storage_account_access_key = azurerm_storage_account.audit_logs.primary_access_key
disabled_alerts = [
Expand All @@ -79,8 +79,8 @@ resource "azurerm_synapse_workspace_vulnerability_assessment" "example" {
storage_account_access_key = azurerm_storage_account.example.primary_access_key
recurring_scans {
enabled = true
email_subscription_admins = true
enabled = true
email_subscription_admins_enabled = true
emails = [
"[email protected]",
"[email protected]"
Expand Down Expand Up @@ -108,7 +108,7 @@ The following arguments are supported:
`recurring_scans` supports the following:

* `enabled` - (Optional) Boolean flag which specifies if recurring scans is enabled or disabled. Defaults to `false`.
* `email_subscription_admins` - (Optional) Boolean flag which specifies if the schedule scan notification will be sent to the subscription administrators. Defaults to `false`.
* `email_subscription_admins_enabled` - (Optional) Boolean flag which specifies if the schedule scan notification will be sent to the subscription administrators. Defaults to `false`.
* `emails` - (Optional) Specifies an array of e-mail addresses to which the scan notification is sent.

## Attributes Reference
Expand Down

0 comments on commit bdd4d1a

Please sign in to comment.