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

witty-king-53626

08/03/2023, 9:10 PM
Hello! I'm trying to create a Pulumi.yaml config that supports nested configuration . I see a ton of tickets on "hierarchical" support and I know alot is in flight but don't see much about the actual project template support. Can I map to config objects as a template for
pulumi new ...
calls to configure these nested values (with defaults)? I have succeeded at assigning nested objects directly with stack config, but the project template config still eludes me. In other words, after creating the stack, something like this should succeed in my
index.ts
for
pulumi preview
....
Copy code
interface nested {
    thing: string
}
interface other {
    doodad: boolean
}
interface deep {
    nested: nested
    other: other
    val: string
}
let deepCfg = config.requireObject<deep>('deep')
await <http://pulumi.log.info|pulumi.log.info>(`deep.val ${deepCfg.val}`)
await <http://pulumi.log.info|pulumi.log.info>(`deep.nested.thing ${deepCfg.nested.thing}`)
await <http://pulumi.log.info|pulumi.log.info>(`deep.other.doodad ${deepCfg.other.doodad}`)
Here is what I have been trying and I get various types of errors..I can't quite get it right.
Copy code
# Pulumi.yaml
name: sa-base
runtime:
  name: nodejs
  options:
    # See <https://github.com/TypeStrong/ts-node/issues/1007>
    # <https://stackoverflow.com/questions/62096269/cant-run-my-node-js-typescript-project-typeerror-err-unknown-file-extension>
    nodeargs: "--loader ts-node/esm --no-warnings --experimental-specifier-resolution=node"
description: A TypeScript program to deploy base resources into AWS

template:
  description: SA Base resources
  config:
    deep:
      val:
        type: string
        default: myval
      nested:
        thing:
          type: string
          default: donkey
      other:
        doodad:
          type: boolean
          default: true
Is there some special syntax to get past the variations on
configuration keys should be of the form <namespace>:<name>
errors I keep getting?