Hi, I hope this isn't a dumb question! With the ex...
# sst
r
Hi, I hope this isn't a dumb question! With the experimental lambda@edge construct, is there a way I can use the same build system that is used for a SST function?
t
There's not an easy way to do this right now but we'll be exposing some of that functionality soon as a library
r
Awesome!! 🕺 I thought about just using a normal SST function, then point it to the build folder to package up the code. That would work right?... It would just end up deploying an extra function?
t
I think that could work
r
seems to do the trick
Copy code
new sst.Function(this, "edge-function-builder", {
    enableLiveDev: false,
    handler: "src/edge-function.handler"
});

new experimental.EdgeFunction(this, "edge-function", {
    runtime: lambda.Runtime.NODEJS_14_X,
    handler: "src/edge-function.handler",
    code: lambda.Code.fromAsset(
        ".build/" + fs.readdirSync(".build").sort().reverse().filter(dir => dir.startsWith("src-edge-function-"))[0]
    ),
    stackId: `${scope.logicalPrefixedName("edge-function")}`,
});