SOLVED: `Generally you should specify paths relati...
# help
d
SOLVED:
Generally you should specify paths relative to SST.json
--- This might seem obvious but it isn’t to me so if someone knows, I’d appreciate it. I have the following directory structure:
Copy code
src/
  lambda-handler/
    rewiter.js
stacks/
  SiteStatck.js
  index.js
sst.json
Inside
StaticSite
, I’d like to attach an edge lambda function. That looks vaguely like this:
Copy code
const originRewriteHandler = new experimental.EdgeFunction(
      this,
      "OriginRewriteFunc",
      {
        runtime: lambda.Runtime.NODEJS_14_X,
        handler: "src/lambda-handler/rewriter.main",
        // this path is wrong and I can't figure it out
        code: lambda.Code.fromAsset(path.join(__dirname, "lambda-handler")), <----------------------
      }
    );
Everywhere I go with different paths I end up in
.build
t
Generally you should specify paths relative to SST.json
d
I think what that means is that
Copy code
code: lambda.Code.fromAsset(
          path.join(__dirname, "../../src/lambda-handler")
        ),
and my new error of
Copy code
TypeError: origin.bind is not a function
    at Distribution.addOrigin (/Users/devinfitzsimons/Backup/serverless-stack/comics-helper/node_modules/@serverless-stack/resources/node_modules/aws-cdk-lib/aws-cloudfront/lib/distribution.ts:207:39)
    at Distribution.addBehavior (/Users/devinfitzsimons/Backup/serverless-stack/comics-helper/node_modules/@serverless-stack/resources/node_modules/aws-cdk-lib/aws-cloudfront/lib/distribution.ts:193:27)
    at new MarketingStack (/Users/devinfitzsimons/Backup/serverless-stack/comics-helper/stacks/MarketingSiteStack.js:41:31)
    at Object.main (/Users/devinfitzsimons/Backup/serverless-stack/comics-helper/stacks/index.js:12:3)
    at Object.<anonymous> (/Users/devinfitzsimons/Backup/serverless-stack/comics-helper/.build/run.js:94:16)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
is actually a success message!
Success you are failing in a new way 🎉