Hi all, I'm using Pulumi in Java to try get a lamb...
# aws
s
Hi all, I'm using Pulumi in Java to try get a lambda layer by name, and attach it to a lambda function using the layer arn, as per the example in https://www.pulumi.com/registry/packages/aws/api-docs/lambda/function/. • I am able to find the Layer, it's a
LayerVersion
object in Pulumi • I am able to get the arn using
layerVersion.arn()
this returns an
Output<String>
• I am not able to attach that value to a lambda function
Function
object. The
layers
field expects a String, not the Output<String> we have Am I doing something wrong here?
s
Hello Mo 👋 Doesn't
layers
field expect
List<String>
(with
Output<List<String>>
overload), not
String
? I wrote this piece of code that compiles (notice
Output.all
usage):
Copy code
var exampleLayerVersion = new LayerVersion("exampleLayerVersion");

var exampleFunction = new Function("exampleFunction", FunctionArgs.builder()
        .layers(Output.all(exampleLayerVersion.arn()))
        .build());
You can also use
.applyValue
if you prefer:
.layers(exampleLayerVersion.arn().applyValue(List::of))
Let me know if that helps. If not, having a code snippet (with import statements) could help me understand your issue better.
s
Hello, Indeed, it does not expect a String directly, it uses
String...
where a single String can be passed. But to the main point, that does help.
Output.all(...)
does the trick, thanks!
the online documentation probably needs to be updated, the example does not work