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

handsome-actor-1155

01/27/2020, 11:12 PM
Do you all have any examples of using default complex (read: array or object) configs in a template? I’m wanting to do
pulumi new <template>
and instantiate with default complex configs
And as a follow up to this, when accessing such complex config objects in code, do you tend to cast to a defined type? Or parse upon read?
In case you couldn’t tell, this is for typescript 🙂 My current implementation looks like this: `Pulumi.dev.yaml`:
Copy code
stream-demo-sensor-reading-producer:site:
  - consumerGroupId: consumer-group-0
    endSiteId: 9
  - consumerGroupId: consumer-group-1
    endSiteId: 19
index.ts
Copy code
type Site = {
    consumerGroupId:string
    endSiteId:number
};
const array = config.getObject("site") as Array<Site>;
console.log(array[0].consumerGroupId);
w

white-balloon-205

01/27/2020, 11:33 PM
Yep - something like the above looks like exactly what I would suggest doing given the current support for rich configuration. Was there anything about this you didn't like, or would have prefered to be different?
h

handsome-actor-1155

01/27/2020, 11:36 PM
I like the approach I have, I guess my main question is do you have any examples on how to make complex config objects defaults during a pulumi new from a template
And was also just trying to see if someone had come up with a different approach other than what I have for managing complex configs.