Skip to content

Commit

Permalink
Fix for sentinel alert rule scheduled
Browse files Browse the repository at this point in the history
  • Loading branch information
WodansSon committed May 8, 2020
1 parent 0ca6ce6 commit 44fca85
Showing 1 changed file with 6 additions and 6 deletions.
Expand Up @@ -171,7 +171,7 @@ func resourceArmSentinelAlertRuleScheduledCreateUpdate(d *schema.ResourceData, m
}

if d.IsNewResource() {
resp, err := client.Get(ctx, workspaceID.ResourceGroup, workspaceID.Name, name)
resp, err := client.Get(ctx, workspaceID.ResourceGroup, "Microsoft.OperationalInsights", workspaceID.Name, name)
if err != nil {
if !utils.ResponseWasNotFound(resp.Response) {
return fmt.Errorf("checking for existing Sentinel Alert Rule Scheduled %q (Resource Group %q / Workspace %q): %+v", name, workspaceID.ResourceGroup, workspaceID.Name, err)
Expand Down Expand Up @@ -226,7 +226,7 @@ func resourceArmSentinelAlertRuleScheduledCreateUpdate(d *schema.ResourceData, m

// Service avoid concurrent update of this resource via checking the "etag" to guarantee it is the same value as last Read.
if !d.IsNewResource() {
resp, err := client.Get(ctx, workspaceID.ResourceGroup, workspaceID.Name, name)
resp, err := client.Get(ctx, workspaceID.ResourceGroup, "Microsoft.OperationalInsights", workspaceID.Name, name)
if err != nil {
return fmt.Errorf("retrieving Sentinel Alert Rule Scheduled %q (Resource Group %q / Workspace %q): %+v", name, workspaceID.ResourceGroup, workspaceID.Name, err)
}
Expand All @@ -237,11 +237,11 @@ func resourceArmSentinelAlertRuleScheduledCreateUpdate(d *schema.ResourceData, m
param.Etag = resp.Value.(securityinsight.ScheduledAlertRule).Etag
}

if _, err := client.CreateOrUpdate(ctx, workspaceID.ResourceGroup, workspaceID.Name, name, param); err != nil {
if _, err := client.CreateOrUpdate(ctx, workspaceID.ResourceGroup, "Microsoft.OperationalInsights", workspaceID.Name, name, securityinsight.BasicAlertRule(param)); err != nil {
return fmt.Errorf("creating Sentinel Alert Rule Scheduled %q (Resource Group %q / Workspace %q): %+v", name, workspaceID.ResourceGroup, workspaceID.Name, err)
}

resp, err := client.Get(ctx, workspaceID.ResourceGroup, workspaceID.Name, name)
resp, err := client.Get(ctx, workspaceID.ResourceGroup, "Microsoft.OperationalInsights", workspaceID.Name, name)
if err != nil {
return fmt.Errorf("retrieving Sentinel Alert Rule Scheduled %q (Resource Group %q / Workspace %q): %+v", name, workspaceID.ResourceGroup, workspaceID.Name, err)
}
Expand All @@ -266,7 +266,7 @@ func resourceArmSentinelAlertRuleScheduledRead(d *schema.ResourceData, meta inte
return err
}

resp, err := client.Get(ctx, id.ResourceGroup, id.Workspace, id.Name)
resp, err := client.Get(ctx, id.ResourceGroup, "Microsoft.OperationalInsights", id.Workspace, id.Name)
if err != nil {
if utils.ResponseWasNotFound(resp.Response) {
log.Printf("[DEBUG] Sentinel Alert Rule Scheduled %q was not found in Workspace %q in Resource Group %q - removing from state!", id.Name, id.Workspace, id.ResourceGroup)
Expand Down Expand Up @@ -326,7 +326,7 @@ func resourceArmSentinelAlertRuleScheduledDelete(d *schema.ResourceData, meta in
return err
}

if _, err := client.Delete(ctx, id.ResourceGroup, id.Workspace, id.Name); err != nil {
if _, err := client.Delete(ctx, id.ResourceGroup, "Microsoft.OperationalInsights", id.Workspace, id.Name); err != nil {
return fmt.Errorf("deleting Sentinel Alert Rule Scheduled %q (Resource Group %q / Workspace %q): %+v", id.Name, id.ResourceGroup, id.Workspace, err)
}

Expand Down

0 comments on commit 44fca85

Please sign in to comment.