sparse-intern-71089
04/14/2021, 2:15 PMbored-oyster-3147
04/14/2021, 2:27 PM.concat(...). There is some variance in the method signatures for Output manipulation across SDKs.fierce-holiday-69805
04/14/2021, 2:46 PMconcat and interpolate and they’re both useful. It’d be nice if interpolate (or some equivalent) was available in Python as well.fierce-holiday-69805
04/14/2021, 2:46 PMOutput.concat(
"postgres://",
root_user,
":",
root_password.result,
"@",
cluster.endpoint,
":",
cluster.port,
"/{dbname}",
)fierce-holiday-69805
04/14/2021, 2:47 PMfierce-holiday-69805
04/14/2021, 2:47 PMinterpolate I wouldn’t have introduced that bug…)bored-oyster-3147
04/14/2021, 2:54 PMinterpolate in python. Some things are just easier in the wild wild west that is javascript/typescript. For instance the dynamic provider implementation relies on the ability to serialize functions in javascript, which is why it isn't supported in .NET..fierce-holiday-69805
04/14/2021, 3:12 PMfierce-holiday-69805
04/14/2021, 3:13 PMcluster.port which is an int I think. When I run pulumi up I get this:
File "/usr/local/lib/python3.7/site-packages/pulumi/output.py", line 178, in run
transformed: Input[U] = func(value)
TypeError: sequence item 7: expected str instance, int foundfierce-holiday-69805
04/14/2021, 3:13 PMbored-oyster-3147
04/14/2021, 3:15 PMcluster.port.apply(x => x.toString()) which turns the Output<int> to Output<string>fierce-holiday-69805
04/14/2021, 3:16 PMfierce-holiday-69805
04/14/2021, 3:16 PMOutput.concat did this automatically)bored-oyster-3147
04/14/2021, 3:17 PMOutput<int> to Output<string> though so there might be some other reason to not do thatred-match-15116
04/14/2021, 4:06 PMActually I’m having some trouble related to this expression! Looks like it’s related toDoeswhich is ancluster.portI think.int
str(cluster.port) within the Output.concat not work?fierce-holiday-69805
04/14/2021, 4:07 PM<object:pulumi.Output:address> or whatever (paraphrasing)fierce-holiday-69805
04/14/2021, 4:08 PMfierce-holiday-69805
04/14/2021, 4:08 PMcluster.port is an Outputfierce-holiday-69805
04/14/2021, 4:08 PMInput with a default value…fierce-holiday-69805
04/14/2021, 4:08 PMfierce-holiday-69805
04/14/2021, 4:08 PMred-match-15116
04/14/2021, 4:08 PMOutput . Anyway, ignore me then.fierce-holiday-69805
04/14/2021, 4:09 PMred-match-15116
04/14/2021, 4:10 PMfierce-holiday-69805
04/14/2021, 4:11 PMfierce-holiday-69805
04/14/2021, 4:16 PMOutput.all to inject output values into the value that I’m going to stringify.
Not everywhere, though; I’ve found that I can just pass a hash containing some Outputs inside it to the policy arg of the various AWS policy resources such as UserPolicy — which is great.
But in another case, e.g. the container_definitions arg of an ecs.TaskDefinition, I can’t do that — it fails. I have to do something like this:
container_definitions=Output.all(repository.repository_url, db_url_secret.arn).apply(
lambda vs: json.dumps(
[
{
"name": base_name,
"image": vs[0],
etc…fierce-holiday-69805
04/14/2021, 4:17 PMred-match-15116
04/14/2021, 4:21 PMmypy, you would get a type error for policy as well, even though it accepts the dict form. This actually isn’t just a python thing I think. There’s an issue tracking this: https://github.com/pulumi/pulumi-terraform-bridge/issues/339red-match-15116
04/14/2021, 4:23 PMOutput.all but you can use keyword args so you don’t have to refer to each value by its index. i.e.
container_definitions=Output.all(url=repository.repository_url, arn=db_url_secret.arn).apply(
lambda vs: json.dumps(
[
{
"name": base_name,
"image": vs["url"],
etc…fierce-holiday-69805
04/14/2021, 4:34 PMfierce-holiday-69805
04/14/2021, 4:34 PMfierce-holiday-69805
04/14/2021, 4:35 PMred-match-15116
04/14/2021, 4:38 PMOutput.all -> Output.all(_foo_=foo, _bar_=bar) -> Output[{"foo": foo, "bar": bar}]
But yeah, probably worth adding to the Output docs too.fierce-holiday-69805
04/14/2021, 5:04 PMfierce-holiday-69805
04/14/2021, 5:05 PMred-match-15116
04/14/2021, 5:31 PM