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_datadog_monitor #16131

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
25 changes: 3 additions & 22 deletions internal/services/datadog/datadog_monitors_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,15 +250,13 @@ func resourceDatadogMonitorRead(d *pluginsdk.ResourceData, meta interface{}) err
if err := d.Set("datadog_organization", flattenMonitorOrganizationProperties(props.DatadogOrganizationProperties, d)); err != nil {
vikotha marked this conversation as resolved.
Show resolved Hide resolved
return fmt.Errorf("setting `datadog_organization`: %+v", err)
}
if err := d.Set("user", flattenMonitorUserInfo(props.UserInfo, d)); err != nil {
return fmt.Errorf("setting `user`: %+v", err)
}
d.Set("monitoring_enabled", props.MonitoringStatus == datadog.MonitoringStatusEnabled)
d.Set("resource_category", props.LiftrResourceCategory)
d.Set("marketplace_subscription_status", props.MarketplaceSubscriptionStatus)
}

d.Set("sku_name", *resp.Sku.Name)
if resp.Sku != nil {
d.Set("sku_name", *resp.Sku.Name)
}

return tags.FlattenAndSet(d, resp.Tags)
}
Expand Down Expand Up @@ -435,20 +433,3 @@ func flattenMonitorOrganizationProperties(input *datadog.OrganizationProperties,
},
}
}

func flattenMonitorUserInfo(input *datadog.UserInfo, d *pluginsdk.ResourceData) []interface{} {

userInfo := d.Get("user").([]interface{})
if len(userInfo) == 0 {
return make([]interface{}, 0)
}

v := userInfo[0].(map[string]interface{})
return []interface{}{
map[string]interface{}{
"name": utils.String(v["name"].(string)),
"email": utils.String(v["email"].(string)),
"phone_number": utils.String(v["phone_number"].(string)),
},
}
}
46 changes: 23 additions & 23 deletions website/docs/r/datadog_monitors.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ subcategory: "Datadog"
layout: "azurerm"
page_title: "Azure Resource Manager: azurerm_datadog_monitor"
description: |-
Manages a datadog Monitor.
Manages a Datadog Monitor.
---

# azurerm_datadog_monitor
Expand Down Expand Up @@ -41,11 +41,11 @@ resource "azurerm_datadog_monitor" "example" {

The following arguments are supported:

* `name` - (Required) The name which should be used for this datadog Monitor. Changing this forces a new datadog Monitor to be created.
* `name` - (Required) The name of the user that will be associated with the Datadog Monitor. Changing this forces a new Datadog Monitor to be created.

* `resource_group_name` - (Required) The name of the Resource Group where the datadog Monitor should exist. Changing this forces a new datadog Monitor to be created.
* `resource_group_name` - (Required) The name of the Resource Group where the Datadog Monitor should exist. Changing this forces a new Datadog Monitor to be created.

* `location` - (Required) The Azure Region where the datadog Monitor should exist. Changing this forces a new datadog Monitor to be created.
* `location` - (Required) The Azure Region where the Datadog Monitor should exist. Changing this forces a new Datadog Monitor to be created.

* `sku_name` - (Required) The name which should be used for this sku.

Expand All @@ -55,62 +55,62 @@ The following arguments are supported:

* `datadog_organization` - (Required) A `datadog_organization` block as defined below.

* `monitoring_enabled` - (Optional) Flag specifying if the resource monitoring is enabled or disabled. Possible values are "true" and "false" is allowed.
* `monitoring_enabled` - (Optional) Is monitoring enabled? Defaults to`true`.

* `tags` - (Optional) A mapping of tags which should be assigned to the datadog Monitor.
* `tags` - (Optional) A mapping of tags which should be assigned to the Datadog Monitor.

---

A `datadog_organization` block exports the following:

* `api_key` - (Required) Api key associated to the Datadog organization. Changing this forces a new datadog Monitor to be created.
* `api_key` - (Required) Api key associated to the Datadog organization. Changing this forces a new Datadog Monitor to be created.

* `application_key` - (Required) Application key associated to the Datadog organization. Changing this forces a new datadog Monitor to be created.
* `application_key` - (Required) Application key associated to the Datadog organization. Changing this forces a new Datadog Monitor to be created.

* `enterprise_app_id` - (Optional) The ID of the enterprise_app.

* `linking_auth_code` - (Optional) The auth code used to linking to an existing datadog organization.
* `linking_auth_code` - (Optional) The auth code used to linking to an existing Datadog organization. Changing this forces a new Datadog Monitor to be created.

* `linking_client_id` - (Optional) The ID of the linking_client.
* `linking_client_id` - (Optional) The ID of the linking_client. Changing this forces a new Datadog Monitor to be created.

* `redirect_uri` - (Optional) The redirect uri for linking.
* `redirect_uri` - (Optional) The redirect uri for linking. Changing this forces a new Datadog Monitor to be created.

---

An `identity` block supports the following:

* `type` - (Required) Specifies the identity type of the datadog Monitor. At this time the only allowed value is `SystemAssigned`.
* `type` - (Required) Specifies the identity type of the Datadog Monitor. At this time the only allowed value is `SystemAssigned`.

> **NOTE:** The assigned `principal_id` and `tenant_id` can be retrieved after the identity `type` has been set to `SystemAssigned` and the datadog Monitor has been created. More details are available below.
> **NOTE:** The assigned `principal_id` and `tenant_id` can be retrieved after the identity `type` has been set to `SystemAssigned` and the Datadog Monitor has been created. More details are available below.
---

An `user` block exports the following:

* `name` - (Required) The name which should be used for this user_info.
vikotha marked this conversation as resolved.
Show resolved Hide resolved

* `email` - (Required) Email of the user used by Datadog for contacting them if needed. Changing this forces a new datadog Monitor to be created.
* `email` - (Required) Email of the user used by Datadog for contacting them if needed. Changing this forces a new Datadog Monitor to be created.

* `phone_number` - (Optional) Phone number of the user used by Datadog for contacting them if needed.

## Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:

* `id` - The ID of the datadog Monitor.
* `id` - The ID of the Datadog Monitor.

* `identity` - A `identity` block as defined below.

* `resource_category` - The catogory of resource logs flowing.
* `resource_category` - The category of resource logs flowing.
vikotha marked this conversation as resolved.
Show resolved Hide resolved

* `marketplace_subscription_status` - Flag specifying the Marketplace Subscription Status of the resource. If payment is not made in time, the resource will go in Suspended state.

---

An `identity` block exports the following:

* `principal_id` - The Principal ID for the Service Principal associated with the Identity of this datadog Monitor.
* `principal_id` - The Principal ID for the Service Principal associated with the Identity of this Datadog Monitor.

* `tenant_id` - The Tenant ID for the Service Principal associated with the Identity of this datadog Monitor.
* `tenant_id` - The Tenant ID for the Service Principal associated with the Identity of this Datadog Monitor.

-> You can access the Principal ID via `${azurerm_datadog_monitor.example.identity.0.principal_id}` and the Tenant ID via `${azurerm_datadog_monitor.example.identity.0.tenant_id}`

Expand All @@ -130,14 +130,14 @@ resource "azurerm_role_assignment" "example" {

The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions:

* `create` - (Defaults to 30 minutes) Used when creating the datadog Monitor.
* `read` - (Defaults to 5 minutes) Used when retrieving the datadog Monitor.
* `update` - (Defaults to 30 minutes) Used when updating the datadog Monitor.
* `delete` - (Defaults to 30 minutes) Used when deleting the datadog Monitor.
* `create` - (Defaults to 30 minutes) Used when creating the Datadog Monitor.
* `read` - (Defaults to 5 minutes) Used when retrieving the Datadog Monitor.
* `update` - (Defaults to 30 minutes) Used when updating the Datadog Monitor.
* `delete` - (Defaults to 30 minutes) Used when deleting the Datadog Monitor.

## Import

datadog Monitors can be imported using the `resource id`, e.g.
Datadog Monitors can be imported using the `resource id`, e.g.

```shell
terraform import azurerm_datadog_monitor.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Datadog/monitors/monitor1
Expand Down