hashicorp / terraform-provider-runscope

Terraform runscope provider. Please note: This Terraform provider is archived per our provider archiving process: https://terraform.io/docs/internals/archiving.html
https://www.terraform.io/docs/providers/runscope/
Other
8 stars 25 forks source link

Step ordering #18

Closed unya closed 5 years ago

unya commented 5 years ago

Introduces support for step ordering by virtue of a new after_step attribute, which points the the step to be executed before the resource.

ewilde commented 5 years ago

@unya thank you :pray: for this PR, much appreciated.

I think you can achieve step ordering using an in-built terraform feature depends_on see explicit dependencies

Let me know if that works for you

sylvainlegault commented 5 years ago

Hi, I tried the depends_on without success, anyone had success for ordering steps ?

ewilde commented 5 years ago

@sylvainlegault can you create an issue an share an example that's not working for you please?

sylvainlegault commented 5 years ago

I would like to be able to do the following: A single step with 2 requests.

screen shot 2018-12-21 at 9 19 30 am

ewilde commented 5 years ago

@sylvainlegault @unya please see depends_on that i've added to the test example. I've also added a new assertion that checks order is applied correctly to the runscope api https://github.com/terraform-providers/terraform-provider-runscope/blob/master/runscope/resource_runscope_step_test.go#L233

@sylvainlegault the key part in the test example: when creating step b make it depend on step a

depends_on = ["runscope_step.step_a"]

Extract from the example test:

resource "runscope_test" "test_a" {
  bucket_id   = "${runscope_bucket.bucket.id}"
  name        = "runscope test a"
  description = "This is a test a"
}

resource "runscope_step" "step_b" {
  bucket_id      = "${runscope_bucket.bucket.id}"c
  test_id        = "${runscope_test.test_a.id}"
  step_type      = "request"
  note           = "Multiple step test, test b"
  url            = "http://step_b.com"
  method         = "GET"
  depends_on     = ["runscope_step.step_a"]
}
sylvainlegault commented 5 years ago

thanks for following up, strangely it doesn't work for me...terraform doesn't event detect the change when I'm applying depends_on, I'm wondering if the order is alphanumerical, could you try step_a depends on step_b instead ?

ewilde commented 5 years ago

@sylvainlegault it won't work for resource that you've already created. Try deleting the test and starting again, then the depends_on order will be respected

sylvainlegault commented 5 years ago

Hi Edwards,

looks like this does the trick, after removing all the steps apply the changes and re-inserting the steps with the depends_on tag and re-apply the changes it does work.

Thanks Sylvain

ewilde commented 5 years ago

closing due to solution highlighted above https://github.com/terraform-providers/terraform-provider-runscope/pull/18#issuecomment-450661302

wolf31o2 commented 3 years ago

We've been using the depends_on workaround for a long time. It's ridiculous to need to destroy/recreate all downstream resources to introduce a new step in the middle, which is why we had opted for making it explicit ordering, as terraform depends_on just ensures that the dependency exists.