# general


04/07/2020, 6:56 PM
Hm. I have a module that creates and AWS cloudfront with an edge lambda. All good and well, the problem is that on creation of the cloudfront I need to construct a reference to the edge lambda which is the arn plus the number of the last published version. In other words, I need somehow to get the arn and the version AFTER the lambda has been created. How do I do that? As it is, after running “lambda = new aws.lambda.function(…” all I get when I try to make a new arn out of “newarn = lambda.arn + ‘:’ + lambda.version” is a message about using apply, which doesn’t work. In general this is a problem, i.e. serializing execution here and there, waiting for a specific resource to be created before proceeding. I am sure there’s a general solution to this… or?


04/07/2020, 7:22 PM
While i believe this is doable with pulumi.all().apply(), for this specific use case the easiest solution is most likely with pulumi.interpolate. I'm not sure what language you're using, but in TypeScript it would look like this: `const newarn = pulumi.interpolate`${lambda.arn}:${lambda.version}`;` Note that after this operation, newarn is still of type Output<string>, it is not a string. It can be used directly as an input to other pulumi resources, but outside of .apply() it cannot be used in any functions expecting a string.
👍 1


04/07/2020, 7:29 PM
Hm. So what you are saying is that creation of the cloudfront consuming that value has to be done in an pulumi.all() in order for the value to be useful?
NO. Sorry, I got a an error from AWS… as usual they are being difficult. Your solution worked perfectly, thanks a lot!!
👍 1
(Just fyi, it turns out that “lambda.version” does not evaluate to the “latest deployed version” as per the docs, but to the string “$LATEST”… which they naturally at the same time does NOT accept as input to a cloudfront edge lambda definition… so typically annoying. Pulumi unfortunately uses terraform as the interface rather than boto, so there’s no way of getting information about what the latest version is… I see a lot problems in that regard generally)