Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan-Hendrik Boll committed Jul 9, 2018
1 parent 5c0ae0c commit 6ed0caf
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
35 changes: 28 additions & 7 deletions azurerm/resource_arm_monitor_diagnostics.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,14 @@ func resourceArmMonitorDiagnostics() *schema.Resource {
},

"target_resource_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
DiffSuppressFunc: ignoreCaseDiffSuppressFunc,
Type: schema.TypeString,
Required: true,
ForceNew: true,
},

"storage_account_id": {
Type: schema.TypeString,
Optional: true,
DiffSuppressFunc: ignoreCaseDiffSuppressFunc,
Type: schema.TypeString,
Optional: true,
},

"event_hub_name": {
Expand Down Expand Up @@ -67,6 +65,29 @@ func resourceArmMonitorDiagnostics() *schema.Resource {
Optional: true,
},
},

/*CustomizeDiff: func(diff *schema.ResourceDiff, v interface{}) error {
_, hasStorageAccountId := diff.GetOk("storage_account_id")
_, hasEventHubName := diff.GetOk("event_hub_name")
_, hasEventHubAuthorizationRuleId := diff.GetOk("event_hub_authorization_rule_id")
_, hasWorkspaceId := diff.GetOk("workspace_id")
_, hasRetentionDays := diff.GetOk("retention_days")
if !hasStorageAccountId && (!hasEventHubName && !hasEventHubAuthorizationRuleId) && !hasWorkspaceId {
return fmt.Errorf("You must specify at least one data sink for diagnostic settings")
}
if hasEventHubName && !hasEventHubAuthorizationRuleId || hasEventHubAuthorizationRuleId && !hasEventHubName {
return fmt.Errorf("Please set both parameters event_hub_name and event_hub_authorization_rule_id")
}
if hasRetentionDays && !hasStorageAccountId {
return fmt.Errorf("Parameter retention_days can only be set together with Storage Account ID")
}
return nil
},*/
}
}

Expand Down
7 changes: 4 additions & 3 deletions azurerm/resource_arm_monitor_diagnostics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,16 +168,17 @@ func testAccAzureRMMonitorDiagnostics_basic(randomInt int, location string) stri
location = "${azurerm_resource_group.test_rg.location}"
resource_group_name = "${azurerm_resource_group.test_rg.name}"
tenant_id = "${data.azurerm_client_config.current.tenant_id}"
sku {
name = "standard"
}
}
resource "azurerm_monitor_diagnostics" "test" {
name = "acctest%d"
target_resource_id = "${azurerm_key_vault.test_vault.id}"
storage_account_id = "${azurerm_storage_account.test_storage_logs.id}"
#storage_account_id = "${azurerm_storage_account.test_storage_logs.id}"
storage_account_id = "/subscriptions/e0f0d5d3-7fca-4ff1-84b8-0bdcf7a49fe2/resourceGroups/jbolltesting/providers/Microsoft.Storage/storageAccounts/jbolltesting"
disabled_settings = ["AuditEvent"]
}`, randomInt, location, randomInt, randomInt, randomInt)
}
Expand Down

0 comments on commit 6ed0caf

Please sign in to comment.