https://pulumi.com logo
#aws
Title
# aws
b

breezy-branch-28232

01/10/2022, 2:44 PM
Hello everyone! I’m trying to figure if I can use some sort of dynamic configuration when defining a Cloudfront function. Basically I want the function body to use an array with some information that’s not hardcoded within the function. Is this something that’s possible?
m

miniature-king-36473

01/10/2022, 3:38 PM
If the value is known when Pulumi runs you can capture the values you want in the body of the function (at least in javascript/typescript). Or you can set the configuration as environment variables for the deployed function.
Apologies misread your question - Cloudfront Functions, not Lambda@Edge. For CF Functions pulumi requires the source code as a string and don't do capture of the function. You can create the code string dynamically using pulumi outputs. e.g.
Copy code
const code = pulumi.apply(output) => {
return `function handler(event) { console.log("${output}");
return event.request;
}`