Hi,
I’m having a hard time getting the synthetic browser test working for datadog. Perhaps it’s because I don’t have a lot of web dev experience.
I’m having a hard time getting the browser_step.params element configured properly, I keep getting 400’s back from Datadog upstream, implying invalid syntax and I’m just not sure how to write it out.
For example:
resource "datadog_synthetics_test" "test_login" {
name = var.name
type = var.type
request_definition {
method = var.method
url = var.url
}
device_ids = var.device_ids
locations = var.locations
options_list {
tick_every = var.tick_every
}
message = var.message
tags = var.tags
status = var.status
browser_step {
name = var.browser_step_name
type = var.browser_step_type
allow_failure = var.browser_step_allow_failure
# force_element_update = var.browser_step_force_element_update
# timeout = var.browser_step_timeout
params {
element = jsonencode({
"username"="test123"
})
}
}
}
I know this not the proper code as it fails. However I used a selenium python script on a website I’m trying to make sure UI login works. I’ve identified the element as “username”, which is why I used it above
This is the error:
2021-03-10T17:07:00.855-0600 [DEBUG] plugin.terraform-provider-datadog_v2.21.0: HTTP/1.1 400 Bad Request
2021-03-10T17:07:00.855-0600 [DEBUG] plugin.terraform-provider-datadog_v2.21.0: Content-Length: 73
2021-03-10T17:07:00.855-0600 [DEBUG] plugin.terraform-provider-datadog_v2.21.0: Cache-Control: no-cache
2021-03-10T17:07:00.855-0600 [DEBUG] plugin.terraform-provider-datadog_v2.21.0: Connection: keep-alive
2021-03-10T17:07:00.855-0600 [DEBUG] plugin.terraform-provider-datadog_v2.21.0: Content-Security-Policy: frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report
2021-03-10T17:07:00.855-0600 [DEBUG] plugin.terraform-provider-datadog_v2.21.0: Content-Type: application/json
2021-03-10T17:07:00.855-0600 [DEBUG] plugin.terraform-provider-datadog_v2.21.0: Date: Wed, 10 Mar 2021 23:07:00 GMT
2021-03-10T17:07:00.855-0600 [DEBUG] plugin.terraform-provider-datadog_v2.21.0: Pragma: no-cache
2021-03-10T17:07:00.855-0600 [DEBUG] plugin.terraform-provider-datadog_v2.21.0: Strict-Transport-Security: max-age=15724800;
2021-03-10T17:07:00.855-0600 [DEBUG] plugin.terraform-provider-datadog_v2.21.0: X-Content-Type-Options: nosniff
2021-03-10T17:07:00.855-0600 [DEBUG] plugin.terraform-provider-datadog_v2.21.0: X-Dd-Version: 35.4073548
2021-03-10T17:07:00.855-0600 [DEBUG] plugin.terraform-provider-datadog_v2.21.0: X-Frame-Options: SAMEORIGIN
2021-03-10T17:07:00.855-0600 [DEBUG] plugin.terraform-provider-datadog_v2.21.0: X-Ratelimit-Limit: 120
2021-03-10T17:07:00.855-0600 [DEBUG] plugin.terraform-provider-datadog_v2.21.0: X-Ratelimit-Period: 60
2021-03-10T17:07:00.855-0600 [DEBUG] plugin.terraform-provider-datadog_v2.21.0: X-Ratelimit-Remaining: 119
2021-03-10T17:07:00.855-0600 [DEBUG] plugin.terraform-provider-datadog_v2.21.0: X-Ratelimit-Reset: 60
2021-03-10T17:07:00.855-0600 [DEBUG] plugin.terraform-provider-datadog_v2.21.0:
2021-03-10T17:07:00.855-0600 [DEBUG] plugin.terraform-provider-datadog_v2.21.0: {"errors": ["Step 0 has invalid params: 'value' is a required property"]}
2021/03/10 17:07:00 [DEBUG] datadog_synthetics_test.test_login: apply errored, but we're indicating that via the Error pointer rather than returning it: error creating synthetics test: 400 Bad Request: {"errors": ["Step 0 has invalid params: 'value' is a required property"]}
Error: error creating synthetics test: 400 Bad Request: {"errors": ["Step 0 has invalid params: 'value' is a required property"]}
on main.tf line 1, in resource "datadog_synthetics_test" "test_login":
1: resource "datadog_synthetics_test" "test_login" {
2021-03-10T17:07:00.884-0600 [WARN] plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2021-03-10T17:07:00.887-0600 [DEBUG] plugin: plugin process exited: path=.terraform/providers/registry.terraform.io/datadog/datadog/2.21.0/darwin_amd64/terraform-provider-datadog_v2.21.0 pid=61095
2021-03-10T17:07:00.887-0600 [DEBUG] plugin: plugin exited
And if I try (and fail miserable) to use a value, I get an error stating value is unexpected. I just can’t figure this out.
datadog = {
source = "DataDog/datadog",
version = ">= 2.21.0"
TF version 0.14.6
The documentation is not clear to me.
Overall, lets say “example.com” has an element username and an element password. I’m simply trying to get a synthetic test created that lets me simulate logging in and out.
here is the html of the element for username, if I can figure out how to code that into terraform I can for sure figure out the password element syntax:
<input _ngcontent-xwa-c13="" autocomplete="off" autofocus="" class="input_login ng-pristine ng-invalid ng-touched" formcontrolname="username" item-id="login-username" name="username" required="" tabindex="0" type="text" placeholder="User ID">
I just can’t find any info I need and I’ve exhausted my searches.
Please help teach me how to reference elements, thanks!