This message was deleted.
# general
s
This message was deleted.
b
you need to use
bucket.BucketName.Apply(name => JSON STRING HERE)
a
That doesn't seem to work as expected.. I'm getting the following as my value ...
Copy code
"value":"Calling [ToString] on an [Output<T>] is not supported.\n\nTo get the value of an Output<T> as an Output<string> consider:\n1. o.Apply(v => $\"prefix{v}suffix\")\n2. Output.Format($\"prefix{hostname}suffix\");\n\nSee <https://pulumi.io/help/outputs> for more details.\nThis function may throw in a future version of Pulumi."}]
b
please share what you have
a
I got it figured out actually.. with something like this... I think I was meant to return the entire string from the Apply method, but this got me what I needed.. Thanks!
Copy code
string bucketName;
bucket.BucketName.Apply(bName => 
{
    bucketName = bName;
    return "";
});
b
ah you should not do it like that.
bucket.BucketName
is an
Output<string>
which is sort of like a task or promise - it represents a value that does not necessarily exist yet. you cannot use an
Output<string>
of a value that does not exist (but may exist in the future) to create a
string
value that you want "now" so you setting
ContainerDefinitions = someString
will not work as you are seeing luckily, pulumi lets you easily chain and combine Outputs to create other Outputs.
ContainerDefinitions
is an
Input<string>
which allows you to pass in a
string
(for convenience), or
Input<string>
or an
Output<string>
essentially in your first example you are trying to do something like this: (putting it in 2 separate statements to show what types you are working with)
Copy code
string containerDefs = $@"[ ... ]";
ContainerDefinitions = containerDefs
there is no (good) way to take an Output<string> like bucket.BucketName and get it to appear somewhere in that
string containerDefs
what you want to do instead is something like
Copy code
Output<string> containerDefs = ... something
ContainerDefinitions = containerDefs
and to do that, you have a few options.
Apply
is one way like @billowy-army-68599 mentioned:
Copy code
Output<string> containerDefs = bucket.BucketName.Apply(x =>
{
   // here, x is a string you can use normally
   return $"some string with {x} inside";
});
ContainerDefinitions = containerDefs
you can also use the convenience helper method Output.Format
Copy code
Output<string> containerDefs = Output.Format($"some string using {bucket.BucketName} inside");
ContainerDefinitions = containerDefs
Output.Format takes in a formattable string and does the Apply for you behind the scenes