1

When creating a Runscope testing using the Runscope provider for Terraform, each test is created as a separate resource that references the test resource.

resource "runscope_test" "api" {
  name         = "api-test"
  description  = "checks the api is up and running"
  bucket_id    = "${runscope_bucket.main}"
}

resource "runscope_step" "step_1" {
  bucket_id      = "${runscope_bucket.bucket.id}"
  test_id        = "${runscope_test.test.id}"
  step_type      = "request"

  ...

}

resource "runscope_step" "step_2" {
  bucket_id      = "${runscope_bucket.bucket.id}"
  test_id        = "${runscope_test.test.id}"
  step_type      = "request"

  ...

}

According to Terraform, the sequence in which resources are declared does not make any difference.

How does the Runscope provider for Terraform determine step sequence for the tests?


UPDATE

Looking at implicit dependencies between resources in the Terraform documentation, I found that I could simply reference the previous step.

Terraform is able to infer a dependency, and knows it must create the instance first.

In this case I used the note attribute of the second step to refer to the first step:

resource "runscope_step" "step_2" {
  bucket_id      = "${runscope_bucket.bucket.id}"
  test_id        = "${runscope_test.test.id}"
  step_type      = "request"
  note           = "Follows step: ${runscope_step.step_1.id}"

  ...
}
Feckmore
  • 4,322
  • 6
  • 43
  • 51
  • use `depend_on`? – BMW May 24 '19 at 05:03
  • @BMW, adding the ID of the previous step in `depends_on` gives me the following error: `depends on value cannot contain interpolations: ${runscope_step.step_1.id}`. – Feckmore Jun 05 '19 at 20:06
  • yes, the error is correct. The way you reference is wrong. Change to `[runscope_step.step_1]` . Reference: https://www.terraform.io/docs/configuration/resources.html#depends_on-explicit-resource-dependencies – BMW Jun 06 '19 at 01:25
  • I thought that syntax was for 0.12 and later, I'm still on 0.11 – Feckmore Jun 06 '19 at 13:04
  • for this part, they are same usage in 0.11 and 0.12 – BMW Jun 06 '19 at 13:36
  • I've tried that syntax and other variations, but I've not had any luck getting it to work. I'm sure it's user error on my part. I got around it by using implicit dependency, which I outlined in the `UPDATE` section in the question above. – Feckmore Jun 07 '19 at 13:29

1 Answers1

0

I think you can use implicit dependencies between steps like this:

resource "runscope_step" "step_1" {
  bucket_id      = "${runscope_bucket.bucket.id}"
  test_id        = "${runscope_test.test.id}"
  step_type      = "request"

  ...

}

resource "runscope_step" "step_2" {
  bucket_id      = "${runscope_step.step_1.bucket_id}"
  test_id        = "${runscope_test.test.id}"
  step_type      = "request"

  ...

}

resource "runscope_step" "step_3" {
  bucket_id      = "${runscope_step.step_2.bucket_id}"
  test_id        = "${runscope_test.test.id}"
  step_type      = "request"

  ...

}

and you can check dependencies via [terraform graph][1] command


  [1]: https://www.terraform.io/docs/commands/graph.html
zombi_man
  • 1,804
  • 3
  • 16
  • 22