Ephemeral value not allowed

I’m trying to use ephemeral resource azapi_resource_action and I’m encountering a peculiar behaviour, or I’m misunderstanding how ephemeral works.

In my reusable module I ‘call’ ephemeral "azapi_resource_action" "vmss_upgrade" which does its thing from which I capture output:

# The lines 39-42 in the error output below
output "vmss_upgrade_output" {
  value = {
    for id, upgrade in ephemeral.azapi_resource_action.vmss_upgrade :
    id => upgrade.output
  }
}

In my root module, I call my reusable module.

I run terraform plan and I’m getting this

│ Error: Ephemeral value not allowed
│ 
│   on vmss-manual-upgrade/outputs.tf line 39, in output "vmss_upgrade_output":
│   39:   value = {
│   40:     for id, upgrade in ephemeral.azapi_resource_action.vmss_upgrade :
│   41:     id => upgrade.output
│   42:   }
│ 
│ This output value is not declared as returning an ephemeral value, so it cannot be set to a
│ result derived from an ephemeral value.

I go back to the docs and correct my output this way:

output "vmss_upgrade_output" {
  value = {
    for id, upgrade in ephemeral.azapi_resource_action.vmss_upgrade :
    id => upgrade.output
  }
  ephemeral = true
}

I run terraform plan again and now I’m getting this:

│ Error: Value not allowed in ephemeral output
│ 
│   on vmss-manual-upgrade/outputs.tf line 39, in output "vmss_upgrade_output":
│   39:   value = {
│   40:     for id, upgrade in ephemeral.azapi_resource_action.vmss_upgrade :
│   41:     id => upgrade.output
│   42:   }
│ 
│ This output value is declared as returning an ephemeral value, so it can only be set to an
│ ephemeral value.

I believe, I have a good reason to be confused, haven’t I?

Hi @mloskot,

I agree, that looks like an error in the validation logic to me! I don’t think there’s any way to construct a new ephemeral value for an output, so you can only assign something directly from the ephemeral resource itself.

1 Like

Thanks @jbardin for the confirmation.

Shall I copy my report from here to an issue in hashicorp/terraform repository on GitHub?

AFAIS, that validation comes from the Terraform, not AzApi provider,

Thanks @mloskot, but no need to file an issue this time around, I’m already looking into it.

1 Like