Description
When developing a Terraform module that includes a test setup submodule using ephemeral resources and outputs, running terraform validate or terraform test at the module root fails with the following error:
$ > terraform test
tests/main.tftest.hcl... in progress
run "setup"... fail
╷
│ Error: Ephemeral output not allowed
│
│ on testing/setup/outputs.tf line 20:
│ 20: output "creds" {
│
│ Ephemeral outputs are not allowed in context of a root module
╵
run "apply"... skip
run "verify"... skip
$ > terraform validate
╷
│ Error: Ephemeral output not allowed
│
│ on testing/setup/outputs.tf line 20:
│ 20: output "creds" {
│
│ Ephemeral outputs are not allowed in context of a root module
╵
Steps to Reproduce
- Create a subdirectory
testing/setupwith:
ephemeral "vault_kv_secret_v2" "proxmox_creds" {
mount = "infra-secrets"
name = "testing/proxmox/creds"
}
locals {
proxmox_creds = ephemeral.vault_kv_secret_v2.proxmox_creds.data
}
output "creds" {
description = "Sensitive information obtained from Vault"
ephemeral = true
sensitive = true
value = {
proxmox = {
username = local.proxmox_creds.username
password = local.proxmox_creds.password
}
}
}
- Reference it from a
.tftest.hclfile:
run "setup" {
module {
source = "./testing/setup"
}
}
- Run:
terraform validate
Environment
OS: NixOS 25.05
Terraform: v1.13.1
Platform: amd64
Question
Is this the expected behavior or not? If so, what is the best way to get around it?