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

New Resource: azurerm_monitor_action_group #1714

Closed
wants to merge 12 commits into from
Closed

Conversation

metacpp
Copy link
Contributor

@metacpp metacpp commented Aug 2, 2018

In this PR, I introduced a new simple action group resource of Azure monitor.
I enabled three receivers (Email, SMS and Webhook) which should cover most of the use cases.

This PR is a first step of #1252 , because the resource (signal based alert) proposed in it relies on Action Group.

(fixes #1252)

This PR is a follow up on #1419, and @JunyiYi will take care of it.

@metacpp metacpp requested a review from katbyte August 2, 2018 23:17
@metacpp metacpp added this to the Soon milestone Aug 2, 2018
@metacpp metacpp self-assigned this Aug 2, 2018
@tombuildsstuff tombuildsstuff changed the title [Rework]Introduce Action Group resource of Azure Monitor New Resource: azurerm_monitor_action_group Aug 3, 2018
Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

hi @metacpp

Thanks for re-opening this PR :)

I've taken a look through and left some comments in-line (most of which were from the original PR) so that we can look towards shipping this.

Thanks!

@@ -122,6 +122,7 @@ func Provider() terraform.ResourceProvider {
},

ResourcesMap: map[string]*schema.Resource{
"azurerm_action_group": resourceArmActionGroup(),
Copy link
Contributor

Choose a reason for hiding this comment

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

given this a resource within Azure Monitor this should be azurerm_monitor_action_group (we should probably update the naming for the azurerm_metric_alertrule and azurerm_autoscale_setting resources too, but we should fix this for new resources going forward)


"short_name": {
Type: schema.TypeString,
Required: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

is this only required for the SMS Receiver? if so - should this be optional?


if v, ok := d.GetOk("webhook_receiver"); ok {
parameters.ActionGroup.WebhookReceivers = expandActionGroupWebHookReceiver(v.([]interface{}))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

we can assign all of these directly:

emailReceiversRaw := d.Get("email_receiver").([]interface{})
emailReceivers = expandActionGroupEmailReceiver(emailReceiversRaw)

smsReceiversRaw := d.Get("sms_receiver").([]interface{})
smsReceivers = expandActionGroupSmsReceiver(smsReceiversRaw)

webhookReceiversRaw := d.Get("webhook_receiver").([]interface{})
webhookReceivers = expandActionGroupWebHookReceiver(webhookReceiversRaw)

parameters := insights.ActionGroupResource{
  Location: utils.String(location),
  ActionGroup: &insights.ActionGroup{
    GroupShortName: utils.String(shortName),
    Enabled:        utils.Bool(enabled),
    EmailReceivers: emailReceivers,
    SmsReceivers: smsReceivers,
    WebhookReceivers: webhookReceivers,
  },
  Tags: expandedTags,
}


id, err := parseAzureResourceID(d.Id())
if err != nil {
return fmt.Errorf("Error parsing action group resource ID \"%s\" during get: %+v", d.Id(), err)
Copy link
Contributor

Choose a reason for hiding this comment

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

since this is an unrecoverable state for users, this there's no point in wrapping it and we can return err directly here.

}

d.Set("short_name", *resp.GroupShortName)
d.Set("enabled", *resp.Enabled)
Copy link
Contributor

Choose a reason for hiding this comment

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

we can remove the pointer deference here and we should be accessing these on the .Properties block to match the Azure API Response

@@ -688,6 +688,10 @@
<li<%= sidebar_current("docs-azurerm-resource-autoscale-setting") %>>
Copy link
Contributor

Choose a reason for hiding this comment

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

now there's multiple items in here, can we update this to: docs-azurerm-resource-monitor

---
layout: "azurerm"
page_title: "Azure Resource Manager: azurerm_action_group"
sidebar_current: "docs-azurerm-resource-action-group"
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be docs-azurerm-resource-monitor-action-group

* `enabled` - (Optional) Whether this action group is enabled. If an action group is not enabled, then none of its receivers will receive communications. Defaults to `true`.
* `email_receiver` - (Optional) The list of `email_receiver` blocks as defined below that are part of this action group.
* `sms_receiver` - (Optional) The list of `sms_receiver` blocks as defined below that are part of this action group.
* `webhook_receiver` - (Optional) The list of `webhook_receiver` blocks as defined below that are part of this action group.
Copy link
Contributor

Choose a reason for hiding this comment

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

we should update these to match the newer format:

* `email_receiver` - (Optional) One or more `email_receiver` blocks as defined below.
* `sms_receiver ` - (Optional) One or more `sms_receiver ` blocks as defined below.
* `webhook_receiver ` - (Optional) One or more `webhook_receiver ` blocks as defined below.

The following arguments are supported:

* `name` - (Required) The name of the Action Group. Changing this forces a new resource to be created.
* `location` - (Required) The location of this Action Group. The only possible value is `Global`.
Copy link
Contributor

Choose a reason for hiding this comment

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

if this is the only available value, then it should be hard-coded (and not available for users to set)


The following attributes are exported:

* `id` - The Route ID.
Copy link
Contributor

Choose a reason for hiding this comment

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

The Route ID -> The ID of the Monitor Action Group

@JunyiYi
Copy link

JunyiYi commented Aug 3, 2018

Close this since @metacpp could not provide comments. I will create a new one.

@JunyiYi JunyiYi closed this Aug 3, 2018
@tombuildsstuff tombuildsstuff modified the milestones: Soon, Being Sorted Oct 25, 2018
@katbyte katbyte removed this from the Being Sorted milestone Oct 25, 2018
@ghost
Copy link

ghost commented Mar 6, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost removed the waiting-response label Mar 6, 2019
@ghost ghost locked and limited conversation to collaborators Mar 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New Resource: Azure Monitor Signal
4 participants