I have an edge function associated with my Static ...
# help
d
I have an edge function associated with my Static Site. I’m getting a 503 error like this:
Copy code
503 ERROR
The request could not be satisfied.
The Lambda function associated with the CloudFront distribution is invalid or doesn't have the required permissions. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
So I “think” the problem is that I need to make the bucket public. But it’s not super obvious that I’m correct. I”m deploying now to test.
Copy code
const staticSite = new sst.StaticSite(this, "Site", {
      path: "website",
      errorPage: "404.html",
      buildOutput: "public",
      buildCommand: "npm run build",
      s3Bucket: {
        accessControl: BucketAccessControl.PUBLIC_READ, // added this to make it public
      },
      cfDistribution: {
        defaultBehavior: {
          allowedMethods: ["GET"],
          edgeLambdas: [
            {
              functionVersion: originRewriteHandler.currentVersion, // this is the edge function referenced above
              eventType: LambdaEdgeEventType.ORIGIN_REQUEST,
            },
          ],
        },
      },
    });
Does that seem correct? it wasn’t 😞
p
I’m not super familiar with this, but are you using the edge function to host a site with Next.js? SST has its own
NextjsSite
construct for this. Even if you’re not using building with Next, you may still want to look into that construct and see how they handle the permissions for the Lambda edge handler under the hood
d
oh that’s a good idea
I’ll check it out
f
Thanks @Patrick
@Devin, can you try setting
publicReadAccess
on the bucket, ie.
Copy code
const staticSite = new sst.StaticSite(this, "Site", {
  ...
  s3Bucket: {
    publicReadAccess: true
  },
  ...
});
d
Thanks Frank. I'm pretty sure I've tried that but I'll give it a go again. each option i test needs to be deployed so it take a lot of time. The bug ticket attached to this I also added some more information to. There's a chance that disallowing the
websiteIndexDocument
is a problem.
Hey @Frank I tried that too. No dice.
f
I see. This is a Gatsby site right? Is there a chance you can setup a sample repo that can reproduce this issue? I can give it a try on my end.