Skip to content

Commit e342e79

Browse files
authored
Merge pull request #3 from rhythmictech/ENG-4007
configure ssl certificate monitor
2 parents 713962e + ded9b2e commit e342e79

File tree

13 files changed

+510
-0
lines changed

13 files changed

+510
-0
lines changed

common/common.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,5 +255,12 @@ ${local.alert_context}
255255
{{#is_warning}} ${local.notify_on_warn} {{/is_warning}}
256256
{{#is_no_data}} ${local.notify_on_nodata} {{/is_no_data}}
257257
{{#is_recovery}} ${local.notify_on_recovery} {{/is_recovery}}
258+
END
259+
260+
synthetic_alert_base_message = <<END
261+
${local.alert_context}
262+
**Alert Information**
263+
{{#is_alert}} ${local.notify_on_alert} {{/is_alert}}
264+
{{#is_recovery}} ${local.notify_on_recovery} {{/is_recovery}}
258265
END
259266
}

synthetics/browser/.terraform.lock.hcl

Lines changed: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

synthetics/browser/README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# terraform-datadog-monitor/synthetics/browser
2+
3+
Configures Synthetic Test for Browser
4+
5+
<!-- BEGIN_TF_DOCS -->
6+
## Requirements
7+
8+
| Name | Version |
9+
|------|---------|
10+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | ~> 1.5 |
11+
| <a name="requirement_datadog"></a> [datadog](#requirement\_datadog) | >= 3.37 |
12+
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 3.1.0 |
13+
14+
## Providers
15+
16+
| Name | Version |
17+
|------|---------|
18+
| <a name="provider_datadog"></a> [datadog](#provider\_datadog) | 3.42.0 |
19+
20+
## Modules
21+
22+
No modules.
23+
24+
## Resources
25+
26+
| Name | Type |
27+
|------|------|
28+
| [datadog_synthetics_test.browser](https://registry.terraform.io/providers/datadog/datadog/latest/docs/resources/synthetics_test) | resource |
29+
30+
## Inputs
31+
32+
| Name | Description | Type | Default | Required |
33+
|------|-------------|------|---------|:--------:|
34+
| <a name="input_additional_tags"></a> [additional\_tags](#input\_additional\_tags) | Additional tags (key:value format) to add to this type of check (combined with `local.tags` and `var.base_tags`) | `list(string)` | `[]` | no |
35+
| <a name="input_alert_critical_priority"></a> [alert\_critical\_priority](#input\_alert\_critical\_priority) | Priority for alerts within critical threshold (P1-P5, uses monitor defaults if not specified) | `string` | `null` | no |
36+
| <a name="input_alert_message"></a> [alert\_message](#input\_alert\_message) | Message to prepend to alert notifications | `string` | `"Alert"` | no |
37+
| <a name="input_alert_nodata_priority"></a> [alert\_nodata\_priority](#input\_alert\_nodata\_priority) | Priority for alerts within warning threshold (P1-P5, uses monitor defaults if not specified) | `string` | `null` | no |
38+
| <a name="input_base_tags"></a> [base\_tags](#input\_base\_tags) | Base tags (key:value format) to add to this type of check (combined with `local.tags` and `var.additional_tags`, generally you should not change this) | `list(string)` | <pre>[<br> "resource:apigateway"<br>]</pre> | no |
39+
| <a name="input_browser_synthetic_device_ids"></a> [browser\_synthetic\_device\_ids](#input\_browser\_synthetic\_device\_ids) | List with the different device IDs used to run the test. Valid values are laptop\_large, tablet, mobile\_small, chrome.laptop\_large, chrome.tablet, chrome.mobile\_small, firefox.laptop\_large, firefox.tablet, firefox.mobile\_small, edge.laptop\_large, edge.tablet, edge.mobile\_small. | `list(string)` | <pre>[<br> "laptop_large"<br>]</pre> | no |
40+
| <a name="input_browser_synthetic_enabled"></a> [browser\_synthetic\_enabled](#input\_browser\_synthetic\_enabled) | Flag to enable Browser Synthetic Test. | `bool` | `true` | no |
41+
| <a name="input_browser_synthetic_locations"></a> [browser\_synthetic\_locations](#input\_browser\_synthetic\_locations) | An array of datadog locations used to run Browser Synthetic Test. | `list(string)` | <pre>[<br> "aws:us-east-1"<br>]</pre> | no |
42+
| <a name="input_browser_synthetic_request_url"></a> [browser\_synthetic\_request\_url](#input\_browser\_synthetic\_request\_url) | URL to send Browser Synthetic Test requests to. | `string` | n/a | yes |
43+
| <a name="input_browser_synthetic_steps"></a> [browser\_synthetic\_steps](#input\_browser\_synthetic\_steps) | Steps for the Browser Synthetic Test to take. | <pre>list(object({<br> name = string<br> type = string<br> params = object({<br> attribute = optional(string)<br> check = optional(string)<br> click_type = optional(string)<br> code = optional(string)<br> delay = optional(number)<br> element = optional(string)<br> element_user_locator = optional(map(string))<br> email = optional(string)<br> file = optional(string)<br> files = optional(string)<br> modifiers = optional(list(string))<br> playing_tab_id = optional(string)<br> request = optional(string)<br> subtest_public_id = optional(string)<br> value = optional(string)<br> variable = optional(map(string))<br> with_click = optional(bool)<br> x = optional(number)<br> y = optional(number)<br> })<br> }))</pre> | n/a | yes |
44+
| <a name="input_browser_synthetic_tick_every"></a> [browser\_synthetic\_tick\_every](#input\_browser\_synthetic\_tick\_every) | How often Browser Synthetic Test should run in seconds. | `number` | `900` | no |
45+
| <a name="input_cost_center"></a> [cost\_center](#input\_cost\_center) | Cost Center of the monitored resource (leave blank to omit tag) | `string` | `null` | no |
46+
| <a name="input_dashboard_link"></a> [dashboard\_link](#input\_dashboard\_link) | Dashboard link to include in message | `string` | `null` | no |
47+
| <a name="input_env"></a> [env](#input\_env) | Environment the monitored resource is in (leave blank to omit tag) | `string` | n/a | yes |
48+
| <a name="input_evaluation_delay"></a> [evaluation\_delay](#input\_evaluation\_delay) | Monitor evaluation delay (see [https://docs.datadoghq.com/monitors/configuration/?tab=thresholdalert#set-alert-conditions](Datadog Docs)) | `number` | `900` | no |
49+
| <a name="input_monitor_exclude_tags"></a> [monitor\_exclude\_tags](#input\_monitor\_exclude\_tags) | Tags to be excluded in the monitoring query. Specify in key:value format | `list(string)` | `[]` | no |
50+
| <a name="input_monitor_include_tags"></a> [monitor\_include\_tags](#input\_monitor\_include\_tags) | Tags to be included in the monitoring query. Specify in key:value format | `list(string)` | `[]` | no |
51+
| <a name="input_new_group_delay"></a> [new\_group\_delay](#input\_new\_group\_delay) | Delay in seconds before generating alerts for a new resource | `number` | `300` | no |
52+
| <a name="input_notify_alert_override"></a> [notify\_alert\_override](#input\_notify\_alert\_override) | List of notifications for alerts in critical threshold (uses `notify_default` otherwise) | `list(string)` | `[]` | no |
53+
| <a name="input_notify_default"></a> [notify\_default](#input\_notify\_default) | List of alert notifications (can be overridden based on alert type) | `list(string)` | n/a | yes |
54+
| <a name="input_notify_no_data"></a> [notify\_no\_data](#input\_notify\_no\_data) | Alert if no matching data is found | `bool` | `false` | no |
55+
| <a name="input_notify_nodata_override"></a> [notify\_nodata\_override](#input\_notify\_nodata\_override) | List of notifications for no data (uses `notify_default` otherwise) | `list(string)` | `[]` | no |
56+
| <a name="input_notify_recovery_override"></a> [notify\_recovery\_override](#input\_notify\_recovery\_override) | List of notifications for alert recovery (uses `notify_default` otherwise) | `list(string)` | `[]` | no |
57+
| <a name="input_notify_warn_override"></a> [notify\_warn\_override](#input\_notify\_warn\_override) | List of notifications for alerts in warning threshold (uses `notify_default` otherwise) | `list(string)` | `[]` | no |
58+
| <a name="input_renotify_interval"></a> [renotify\_interval](#input\_renotify\_interval) | Interval in minutes to re-send notifications about an alert | `number` | `0` | no |
59+
| <a name="input_runbook_link"></a> [runbook\_link](#input\_runbook\_link) | Runbook link to include in message | `string` | `null` | no |
60+
| <a name="input_service"></a> [service](#input\_service) | Service associated with the monitored resource (leave blank to omit tag) | `string` | `null` | no |
61+
| <a name="input_team"></a> [team](#input\_team) | Team supporting the monitored resource (leave blank to omit tag) | `string` | `null` | no |
62+
| <a name="input_timeout_h"></a> [timeout\_h](#input\_timeout\_h) | Auto-resolve alert in specified hours if condition no longer matches | `number` | `0` | no |
63+
| <a name="input_title_prefix"></a> [title\_prefix](#input\_title\_prefix) | Prefix all alerts with specified value in brackets | `string` | `null` | no |
64+
| <a name="input_title_suffix"></a> [title\_suffix](#input\_title\_suffix) | Suffix all alerts with specified value in parenthesis | `string` | `null` | no |
65+
| <a name="input_warn_priority"></a> [warn\_priority](#input\_warn\_priority) | Priority for alerts with no data (P1-P5, uses monitor defaults if not specified) | `string` | `null` | no |
66+
67+
## Outputs
68+
69+
No outputs.
70+
<!-- END_TF_DOCS -->

synthetics/browser/common.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../common/common.tf

synthetics/browser/main.tf

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
locals {
2+
# these must be defined but do not need to be overridden
3+
monitor_alert_default_priority = null
4+
monitor_warn_default_priority = null
5+
monitor_nodata_default_priority = null
6+
7+
title_prefix = "${var.title_prefix == null ? "" : "[${var.title_prefix}]"}[${var.env}] "
8+
title_suffix = var.title_suffix == null ? "" : " (${var.title_suffix})"
9+
}
10+
11+
resource "datadog_synthetics_test" "browser" {
12+
count = var.browser_synthetic_enabled ? 1 : 0
13+
14+
name = join("", [local.title_prefix, "Browser Test", local.title_suffix])
15+
type = "browser"
16+
status = "live"
17+
message = local.synthetic_alert_base_message
18+
device_ids = var.browser_synthetic_device_ids
19+
locations = var.browser_synthetic_locations
20+
tags = concat(local.common_tags, var.base_tags, var.additional_tags)
21+
22+
request_definition {
23+
method = "GET"
24+
url = var.browser_synthetic_request_url
25+
}
26+
27+
dynamic "browser_step" {
28+
for_each = var.browser_synthetic_steps
29+
content {
30+
name = browser_step.value.name
31+
type = browser_step.value.type
32+
params {
33+
attribute = lookup(browser_step.value.params, "attribute", null)
34+
check = lookup(browser_step.value.params, "check", null)
35+
click_type = lookup(browser_step.value.params, "click_type", null)
36+
code = lookup(browser_step.value.params, "code", null)
37+
delay = lookup(browser_step.value.params, "delay", null)
38+
element = lookup(browser_step.value.params, "element", null)
39+
dynamic "element_user_locator" {
40+
for_each = browser_step.value.params.element_user_locator != null ? browser_step.value.params.element_user_locator : {}
41+
content {
42+
value {
43+
value = lookup(element_user_locator.value, "value", null)
44+
type = lookup(element_user_locator.value, "type", null)
45+
}
46+
fail_test_on_cannot_locate = lookup(element_user_locator.value, "fail_test_on_cannot_locate", null)
47+
}
48+
}
49+
email = lookup(browser_step.value.params, "email", null)
50+
file = lookup(browser_step.value.params, "file", null)
51+
files = lookup(browser_step.value.params, "files", null)
52+
modifiers = lookup(browser_step.value.params, "modifiers", null)
53+
playing_tab_id = lookup(browser_step.value.params, "playing_tab_id", null)
54+
request = lookup(browser_step.value.params, "request", null)
55+
subtest_public_id = lookup(browser_step.value.params, "subtest_public_id", null)
56+
value = lookup(browser_step.value.params, "value", null)
57+
dynamic "variable" {
58+
for_each = browser_step.value.params.variable != null ? browser_step.value.params.variable : {}
59+
content {
60+
example = lookup(variable.value, "example", null)
61+
name = lookup(variable.value, "name", null)
62+
}
63+
}
64+
with_click = lookup(browser_step.value.params, "with_click", null)
65+
x = lookup(browser_step.value.params, "x", null)
66+
y = lookup(browser_step.value.params, "y", null)
67+
}
68+
}
69+
}
70+
71+
options_list {
72+
tick_every = var.browser_synthetic_tick_every
73+
}
74+
}

synthetics/browser/variables.tf

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
########################################
2+
# Global variables
3+
########################################
4+
variable "additional_tags" {
5+
default = []
6+
description = "Additional tags (key:value format) to add to this type of check (combined with `local.tags` and `var.base_tags`)"
7+
type = list(string)
8+
}
9+
10+
variable "base_tags" {
11+
default = ["resource:apigateway"]
12+
description = "Base tags (key:value format) to add to this type of check (combined with `local.tags` and `var.additional_tags`, generally you should not change this)"
13+
type = list(string)
14+
}
15+
16+
########################################
17+
# Browser Synthetic Test variables
18+
########################################
19+
variable "browser_synthetic_enabled" {
20+
description = "Flag to enable Browser Synthetic Test."
21+
type = bool
22+
default = true
23+
}
24+
25+
variable "browser_synthetic_device_ids" {
26+
description = "List with the different device IDs used to run the test. Valid values are laptop_large, tablet, mobile_small, chrome.laptop_large, chrome.tablet, chrome.mobile_small, firefox.laptop_large, firefox.tablet, firefox.mobile_small, edge.laptop_large, edge.tablet, edge.mobile_small."
27+
type = list(string)
28+
default = ["laptop_large"]
29+
}
30+
31+
variable "browser_synthetic_locations" {
32+
description = "An array of datadog locations used to run Browser Synthetic Test."
33+
type = list(string)
34+
default = ["aws:us-east-1"]
35+
}
36+
37+
variable "browser_synthetic_request_url" {
38+
description = "URL to send Browser Synthetic Test requests to."
39+
type = string
40+
}
41+
42+
variable "browser_synthetic_steps" {
43+
description = "Steps for the Browser Synthetic Test to take."
44+
type = list(object({
45+
name = string
46+
type = string
47+
params = object({
48+
attribute = optional(string)
49+
check = optional(string)
50+
click_type = optional(string)
51+
code = optional(string)
52+
delay = optional(number)
53+
element = optional(string)
54+
element_user_locator = optional(map(string))
55+
email = optional(string)
56+
file = optional(string)
57+
files = optional(string)
58+
modifiers = optional(list(string))
59+
playing_tab_id = optional(string)
60+
request = optional(string)
61+
subtest_public_id = optional(string)
62+
value = optional(string)
63+
variable = optional(map(string))
64+
with_click = optional(bool)
65+
x = optional(number)
66+
y = optional(number)
67+
})
68+
}))
69+
}
70+
71+
variable "browser_synthetic_tick_every" {
72+
description = "How often Browser Synthetic Test should run in seconds."
73+
type = number
74+
default = 900
75+
}

synthetics/browser/versions.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../common/versions.tf

synthetics/ssl/.terraform.lock.hcl

Lines changed: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)