Terraform test - Override_resource on terraform_data or null_resource
I've tried override_resource in many different resources for my tests. But I'm unable to do so with terraform_data or null_resource.
For example:
resource "time_offset" "one_year" {
offset_years = 1
}
resource "null_resource" "example" {
provisioner "local-exec" {
command = "echo a"
}
}
And tftest: run "test" { command = apply assert { condition = timecmp(time_offset.one_year.rfc3339, timeadd(timestamp(), "8761h")) == -1 && timecmp(time_offset.one_year.rfc3339, timeadd(timestamp(), "8759h")) == 1 error_message = "${timestamp()} ${time_offset.one_year.rfc3339} Expiration date did not match expected" } }
override_resource {
target = null_resource.example
values = {
input = "sup"
output = "aaaa"
id = "send help"
}
}
In this example, If I do time_offset override resource I get the random 8 alphanumeric string which is expected.
Is there a way to do it? My objective is to skip it entirely so it doesn't run during tests.
Posted Jul 25, 2024, 11:12 AM UTC