Merge pull request #35872 from hashicorp/locals-ephemerals

pull/37025/head
Daniel Schmidt 2 years ago committed by GitHub
commit d6cd0f965a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -376,6 +376,55 @@ module "child" {
expectValidateEphemeralResourceConfigCalled: true,
expectCloseEphemeralResourceCalled: true,
},
"locals": {
module: map[string]string{
"child/main.tf": `
ephemeral "ephem_resource" "data" {}
locals {
composedString = "prefix-${ephemeral.ephem_resource.data.value}-suffix"
composedList = ["a", ephemeral.ephem_resource.data.value, "c"]
composedObj = {
key = ephemeral.ephem_resource.data.value
foo = "bar"
}
}
# We expect this to error since it should be an ephemeral value
output "composedString" {
value = local.composedString
}
output "composedList" {
value = local.composedList
}
output "composedObj" {
value = local.composedObj
}
`,
"main.tf": `
module "child" {
source = "./child"
}
`,
},
expectValidateDiagnostics: func(m *configs.Config) (diags tfdiags.Diagnostics) {
return diags.Append(&hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: "Ephemeral value not allowed",
Detail: "This output value is not declared as returning an ephemeral value, so it cannot be set to a result derived from an ephemeral value.",
}, &hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: "Ephemeral value not allowed",
Detail: "This output value is not declared as returning an ephemeral value, so it cannot be set to a result derived from an ephemeral value.",
}, &hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: "Ephemeral value not allowed",
Detail: "This output value is not declared as returning an ephemeral value, so it cannot be set to a result derived from an ephemeral value.",
})
},
},
} {
t.Run(name, func(t *testing.T) {
if tc.toBeImplemented {

Loading…
Cancel
Save