<@UB9JVTW07> I have a problem with the simplificat...
# general
i
@lemon-spoon-91807 I have a problem with the simplification of outputs, or perhaps I am misunderstanding usage
I see a note in the console:
l
what's up!
i
Value for my bucket cors:
Copy code
[
  {
    "maxAgeSeconds": 0,
    "methods": [
      "GET"
    ],
    "origins": [
      "<http://Calling> [toString] on an [Output<T>] is not supported.\n\nTo get the value of an Output<T> as an Output<string> consider either:\n1: o.apply(v => `prefix${v}suffix`)\n2: pulumi.interpolate `prefix${v}suffix`\n\nSee <https://pulumi.io/help/outputs> for more details.\nThis function may throw in a future version of @pulumi/pulumi.",
      "<https://Calling> [toString] on an [Output<T>] is not supported.\n\nTo get the value of an Output<T> as an Output<string> consider either:\n1: o.apply(v => `prefix${v}suffix`)\n2: pulumi.interpolate `prefix${v}suffix`\n\nSee <https://pulumi.io/help/outputs> for more details.\nThis function may throw in a future version of @pulumi/pulumi.",
      "https://*.Calling [toString] on an [Output<T>] is not supported.\n\nTo get the value of an Output<T> as an Output<string> consider either:\n1: o.apply(v => `prefix${v}suffix`)\n2: pulumi.interpolate `prefix${v}suffix`\n\nSee <https://pulumi.io/help/outputs> for more details.\nThis function may throw in a future version of @pulumi/pulumi."
    ],
    "responseHeaders": []
  }
]
created by:
Copy code
cors: [
            {
              methods: ['GET'],
              origins: [`http://${domain}`, `https://${domain}`, `https://*.${domain}`],
            },
          ],
where the
domain
is
stack.identity.getOutput('domain')
l
yup!
so, her'es how to write that instead.
you have a couple of choices.
Copy code
[pulumi.interpolate `http://${domain}`, ...
normal string interpolation won't work. Since 'domain' is an 'Output' (and they are deffered, while string interpolation is prompt)
i
ah
l
a good analogy would be to think of Outputs like 'Promises'
you can't do
http://${somePromise}
instead, you do:
Copy code
somePromise.then(p => `http://${p}`)
alternatively, in this case, you can do:
Copy code
domain.apply(d => [`http://${d}`, `https://${d}`, `https://*.${d}`])
.apply is similar to .then for a Promise
i
got it, thanks
it finally clicked for me, I had read the docs but for some reason it didn’t land until just now
So I actually have a custom ComponentResource for this, perhaps I should change this to an Output instead of input?
Copy code
export interface AttachmentBucketArgs extends Omit<Partial<BucketArgs>, 'project'> {
  domain: Input<string>
  project: Input<string>
}
l
if this does represent 'args', then Inputs are a good idea
in your code, then do this:
pulumi.output(domain).apply(...)
pulumi.output
takes in any Input and makes it an Output.
i
got it, thanks
l
say it was an Input<string>
that allows you to pass in a 'string', Promise<string>, or Output<string>
so it's maximum flexiibility
👍 1
i
Still seeing the same thing in the console, cors created via:
Copy code
cors: [
            {
              methods: ['GET'],
              origins: output(domain).apply(d => [`http://${d}`, `https://${d}`, `https://*.${d}`]),
            },
          ],
l
are you sure? can you show me what the console says?
also, how is 'cors' being used?
i
console:
Copy code
[
  {
    "maxAgeSeconds": 0,
    "methods": [
      "GET"
    ],
    "origins": [
      "<http://Calling> [toString] on an [Output<T>] is not supported.\n\nTo get the value of an Output<T> as an Output<string> consider either:\n1: o.apply(v => `prefix${v}suffix`)\n2: pulumi.interpolate `prefix${v}suffix`\n\nSee <https://pulumi.io/help/outputs> for more details.\nThis function may throw in a future version of @pulumi/pulumi.",
      "<https://Calling> [toString] on an [Output<T>] is not supported.\n\nTo get the value of an Output<T> as an Output<string> consider either:\n1: o.apply(v => `prefix${v}suffix`)\n2: pulumi.interpolate `prefix${v}suffix`\n\nSee <https://pulumi.io/help/outputs> for more details.\nThis function may throw in a future version of @pulumi/pulumi.",
      "https://*.Calling [toString] on an [Output<T>] is not supported.\n\nTo get the value of an Output<T> as an Output<string> consider either:\n1: o.apply(v => `prefix${v}suffix`)\n2: pulumi.interpolate `prefix${v}suffix`\n\nSee <https://pulumi.io/help/outputs> for more details.\nThis function may throw in a future version of @pulumi/pulumi."
    ],
    "responseHeaders": []
  }
]
l
what is
merge
?
i
lodash
deep merge hash
it is defaulting bucket args while allowing overrides
I can try with object spread
oh wait!
common code, may not have re-built between runs
that was it! user error - stale code
I might look at what it would take to add tsconfig-paths to the ts-node execution inside
pulumi
so that this wouldn’t happen
l
oh ok 🙂
are you ok now?
i
yes
l
great. ping me if you need anything else!
👍 1