mirror of https://github.com/hashicorp/terraform
parent
b1574c6acb
commit
2cfa404236
@ -0,0 +1,5 @@
|
||||
kind: BUG FIXES
|
||||
body: 'terraform test: prevent panic when resolving incomplete references'
|
||||
time: 2025-08-25T12:50:18.511449+02:00
|
||||
custom:
|
||||
Issue: "37484"
|
||||
@ -0,0 +1,12 @@
|
||||
|
||||
variable "input" {
|
||||
type = string
|
||||
}
|
||||
|
||||
resource "test_resource" "resource" {
|
||||
value = var.input
|
||||
}
|
||||
|
||||
output "output" {
|
||||
value = test_resource.resource.value
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
|
||||
variable "input" {
|
||||
type = string
|
||||
|
||||
validation {
|
||||
condition = var.input == "allow"
|
||||
error_message = "invalid input value"
|
||||
}
|
||||
}
|
||||
|
||||
variable "followup" {
|
||||
type = string
|
||||
default = "allow"
|
||||
|
||||
validation {
|
||||
condition = var.followup == var.input
|
||||
error_message = "followup must match input"
|
||||
}
|
||||
}
|
||||
|
||||
locals {
|
||||
input = var.followup
|
||||
}
|
||||
|
||||
module "child" {
|
||||
source = "./child"
|
||||
input = var.input
|
||||
}
|
||||
|
||||
resource "test_resource" "resource" {
|
||||
value = local.input
|
||||
}
|
||||
|
||||
output "output" {
|
||||
value = var.input
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
|
||||
// this test runs assertions againsts parts of the module that should not
|
||||
// have executed because of the expected failure. this should be an error
|
||||
// in the test, but it shouldn't panic or anything like that.
|
||||
|
||||
run "fail" {
|
||||
variables {
|
||||
input = "deny"
|
||||
}
|
||||
|
||||
command = plan
|
||||
|
||||
expect_failures = [
|
||||
var.input,
|
||||
]
|
||||
|
||||
assert {
|
||||
condition = var.followup == "deny"
|
||||
error_message = "bad input"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = local.input == "deny"
|
||||
error_message = "bad local"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = module.child.output == "deny"
|
||||
error_message = "bad module output"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = test_resource.resource.value == "deny"
|
||||
error_message = "bad resource value"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = output.output == "deny"
|
||||
error_message = "bad output"
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue