https://pulumi.com logo
#general
Title
# general
p

polite-mechanic-60124

09/28/2021, 6:41 PM
Hello, I'm running into an issue where the output of pulumi.Output.all is either an
output<string>
on pulumi preview on a clean environment or is an Output<Mapping> on an incrementally updated environment.
Copy code
job_vars = pulumi.Output.all(
            _redis_endpoint=cache.endpoint, # should be an Output string
            **job_specific_inputs, # dict
            **generic_job_inputs, # dict
        )
        pulumi.export("core", job_vars)
pulumi preview on clean environment:
core                                 : output<string>
pulumi up on incrementally updated environment:
Copy code
+ core                                 : {
      + analyzer_bucket                      : "analyzers-bucket-196f898"
      + analyzer_dispatched_bucket           : "dispatched-analyzer-bucket-5177198"
Is there any recommended way to force output to be a mapping type?
r

red-match-15116

09/28/2021, 6:48 PM
Hey! The
preview
is unfortunately incorrect. At the time of preview, pulumi doesn’t know the actual type, however we incorrectly print that as
Output<string>
when it should just be
Output
. There’s an issue one sec.
p

polite-mechanic-60124

09/28/2021, 6:55 PM
Well I at least feel better knowing that my hypothesis was correct. Thank you
Are there any suggested workarounds?
r

red-match-15116

09/28/2021, 7:25 PM
Hmm… can you help me understand what the concern is? The output to
Output.all
is always either
Output[List]
or
Output[Mapping]
- it’s just that the CLI output is misleading…
Would it be better if as the issue suggests it is printed as
output<?>
or
output<T>
? Instead of
output<string>
?
p

polite-mechanic-60124

09/28/2021, 7:34 PM
So the issue is that I'm passing job_vars to a resource that requires a mapping (specifically I'm passing it to the vars field in https://www.pulumi.com/docs/reference/pkg/nomad/job/#jobhcl2). Really I'm using it to pass in parameters to a Nomad job (if you're unfamiliar with Nomad it's effectively like passing in variables to ECS/Fargate/Kubernetes)
So when the preview output is string, it can't parse the string to get the variables and any required parameters fail
r

red-match-15116

09/28/2021, 8:32 PM
But it’s never actually a string… during
preview
it’s just not resolved because each item within the Output.all is not known.
I’m guessing you don’t actually want to pass the parameters during preview though? Right? Only during an actual update?
Oh wait okay I think I understand. It’s when it’s the first update that
preview
is unknown and in all following updates it is known at preview time. So during the first preview there are no outputs… I’m still not sure you want to be passing this information to another job during
preview
as the outputs are unresolved. You can use
pulumi.runtime.is_dry_run()
to determine whether you are running a preview or not.
You could choose to export an empty dict when it’s a preview or something along those lines…
p

polite-mechanic-60124

09/28/2021, 9:50 PM
Got it. Thanks Komal, this was helpful