使用Terraform 的 Runscope 提供程序创建 Runscope 测试时,每个测试都创建为引用测试资源的单独资源。
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"
...
}
根据 Terraform,声明资源的顺序没有任何区别。
Terraform 的 Runscope 提供程序如何确定测试的步骤顺序?
更新
在 Terraform 文档中查看资源之间的隐式依赖关系,我发现我可以简单地参考上一步。
Terraform 能够推断出依赖关系,并且知道它必须首先创建实例。
在这种情况下,我使用note
第二步的属性来引用第一步:
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}"
...
}