Closed unya closed 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
Hi, I tried the depends_on
without success, anyone had success for ordering steps ?
@sylvainlegault can you create an issue an share an example that's not working for you please?
I would like to be able to do the following: A single step with 2 requests.
@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"]
}
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 ?
@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
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
closing due to solution highlighted above https://github.com/terraform-providers/terraform-provider-runscope/pull/18#issuecomment-450661302
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.
Introduces support for step ordering by virtue of a new
after_step
attribute, which points the the step to be executed before the resource.