Is it possible to use the javascript spread operat...
# general
Is it possible to use the javascript spread operator on an input? well, i guess, more so a workaround?
Copy code
async create({
    addtOrigins = []
  }: {
    addtOrigins?: aws.cloudfront.DistributionArgs['origins'];
  }): Promise<aws.cloudfront.Distribution> {
    const apiDistribution = new aws.cloudfront.Distribution(
        origins: [
            // removed, but assume one exists here.
there is a lot more to that but essentially i am looking to add anything additional that i passed to this helper function and spread them into some existing default configuration... however, it appears that when i utilize the pulumi aws.cloudfront.DistributionArgs i am dealing with an input which will not allow me to spread this in.
hm i dont think there’s a problem with this approach. possible issue is that addtOrigins is optional which you cant spread if it’s undefined, you can use a default like `addtOrigins: <type> = []`so its an array even if nothing is passed in
oh jk you have the default there. what’s the TS error you’re getting
Type 'Input<Input<DistributionOrigin>[]>' must have a '[Symbol.iterator]()' method that returns an iterator.
hmm tricky
try this
Copy code
origins: pulumi
      .apply((addtOrigins) => [...addtOrigins, {...}]),
actually this is the right way: replace the type of
with the real object type (not wrapped in pulumi.Input):
aha! thanks 🙂
i've done that before i just could not quite remember how i had done it 🙂