Pulumi TypeScript Output Map<string,string> Issue. console.log shows map output in Diagnostics
section
-
Create a new stack
pulumi stack init dev
-
Restore npm dependencies
npm install
-
Run pulumi up and deploy the changes by selecting y
Updating (dev) View Live: https://app.pulumi.com/myuser/pulumi-ts-map-string-string/dev/updates/1 Type Name Status + pulumi:pulumi:Stack pulumi-ts-map-string-string-dev created (0.45s) + └─ pkg:index:K8sExternalSecretsDeployments foo-testtestest created (0.43s) Resources: + 2 created Duration: 2s
-
View the outputs.
pulumi stack output
Results
Current stack outputs (1): OUTPUT VALUE someMapVar {}
Note This is empty due to the following reason.
For something to be used as an output, it’s
JSON.stringify’d
. For maps, this is always{}
IIRC. When printing to the console, node uses some special formatters which intercepts map types and does a pretty print on them - which is different to serializing to JSON.When writing to an output .. just use
Object.fromEntries(map.entries())
This requires the ES2019 lib in the tsconfig to workwe don't support the JS container objects Map and Set for serialization. Likely easier to use this than remembering to convert:
public readonly somethingMapVar: Record<string, string>;
-
Destroy the stack
pulumi stack destroy -y
-
Remove the stack. This will remove the Pulumi.dev.yaml file
pulumi stack rm