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

important-leather-28796

03/07/2019, 9:21 PM
@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

lemon-spoon-91807

03/07/2019, 9:21 PM
what's up!
i

important-leather-28796

03/07/2019, 9:21 PM
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

lemon-spoon-91807

03/07/2019, 9:22 PM
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

important-leather-28796

03/07/2019, 9:24 PM
ah
l

lemon-spoon-91807

03/07/2019, 9:24 PM
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

important-leather-28796

03/07/2019, 9:25 PM
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

lemon-spoon-91807

03/07/2019, 9:27 PM
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

important-leather-28796

03/07/2019, 9:28 PM
got it, thanks
l

lemon-spoon-91807

03/07/2019, 9:29 PM
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

important-leather-28796

03/07/2019, 9:31 PM
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

lemon-spoon-91807

03/07/2019, 9:32 PM
are you sure? can you show me what the console says?
also, how is 'cors' being used?
i

important-leather-28796

03/07/2019, 9:32 PM
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

lemon-spoon-91807

03/07/2019, 9:34 PM
what is
merge
?
i

important-leather-28796

03/07/2019, 9:34 PM
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

lemon-spoon-91807

03/07/2019, 9:41 PM
oh ok 🙂
are you ok now?
i

important-leather-28796

03/07/2019, 9:41 PM
yes
l

lemon-spoon-91807

03/07/2019, 9:42 PM
great. ping me if you need anything else!
👍 1