terraformer icon indicating copy to clipboard operation
terraformer copied to clipboard

For Datadog synthetics, browser_step blocks should be exported in step order rather than alphabetically by name

Open rajathKrishnan opened this issue 2 years ago • 5 comments

I ran terraformer import datadog --resources=synthetics_test --api-key="" --app-key="", and I generated a .tf file with all the correct browser_steps in it which was great! Unfortunately, the browser_steps export alphabetically by name rather than in step order.

As a simple example, this could be generated from the above command:

  browser_step {
    name = "Click on button \"Sign in\""
    ...
  }
  
  browser_step {
    name = "Type text on input \"email\""
    ...
  }

  browser_step {
    name = "Type text on input \"password\""
    ...
  }

We would want the synthetic to input email and password before clicking on "Sign in". Since the export orders alphabetically by name, it's not possible to do a direct import of the .tf file and have the synthetic work. I worked around this by manually re-ordering all the steps, but this can be tedious if the are test has a lot of browser steps (multiplied by X # of synthetics!).

Looking at Datadog's Synthetic API docs, it doesn't look like there are "step numbers" available as a parameter for steps on creation. This could be a Datadog issue, but I wanted to run it by you here to see if there was a simple fix that was available on this end!

rajathKrishnan avatar May 06 '22 16:05 rajathKrishnan

Hey I know this use case. terraformer sort results for preventing changes in files. HCL object by default use go map, so it's unsorted and we can get different results on 2 running. I look now in the code, maybe we need to delete this line https://github.com/GoogleCloudPlatform/terraformer/blob/master/terraformutils/hcl.go#L80 and don't sort the list, but need to test this. I think if we delete this line we get again unsorted/random sorted results, because it's go maps

sergeylanzman avatar May 06 '22 20:05 sergeylanzman

@sergeylanzman Ah ok, that's unfortunate if the issue with with Go's map libraries. Let me know if the sorting works - if not, no big deal, I'll just update docs on our side explaining the issue.

rajathKrishnan avatar May 09 '22 16:05 rajathKrishnan

hi, I think the unfortunate issue messes export outputs and should be fixed. My use case is to use the terraformer to backup browser_steps in code.

chinuy avatar May 26 '22 21:05 chinuy

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Jul 26 '22 02:07 github-actions[bot]

I ran into this issue with a recent build as well. My dirty solution was:

  1. Use Terraformer to import and create the state file.
  2. Capture the output of terraform show into a new .TF file
  3. Fix any errors that come up

This was clunky and time-consuming, but terraformer still saved me a bunch of time. Only had to do surgery on custom_log_pipelines because terraform show didn't properly output what I needed.

ivenyarovoy avatar Jul 26 '22 16:07 ivenyarovoy

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Sep 25 '22 02:09 github-actions[bot]

This issue was closed because it has been stalled for 7 days with no activity.

github-actions[bot] avatar Oct 02 '22 02:10 github-actions[bot]

Hi, The order is still not kept and this can be cumbersome when dealing with a ton of steps. That would help me a lot to have this feature. Any solution planned ? Thabk you!

AblionGE avatar Feb 28 '24 10:02 AblionGE