Move static file routing to Lambda @ Edge
Closed this issue · 1 comments
huntharo commented
Motivations
- Static files, or things that look like static files, are served by some app frameworks
- URL-type apps may need static files forwarded to the URL origin
- Makes it so that more things will "just work"
To-Do
- Explore Origin Groups to route 404s on S3 to the Lambda origin
- Add setting for
static files on S3
- Default to true, allow to be set to false for a version - Set the
authMethod
field on theorigin
toorigin-access-identity
- Move the API Gateway endpoint to the lambda config file
- Switch the origin for API Gateway behaviors to S3 - This is required because an OAI is needed but an OAI cannot be added when changing from a Custom origin to an S3 origin, only when the default origin is already an S3 origin
- Lookup in the Lambda @ Edge if the static files should be forwarded to the origin or not
- Allow the static file route to be removed from the CDK stack, falling through to Lambda @ Edge
- When static files are not on S3, route them to the app, otherwise route them to S3
Proposed Request Routing to S3 and Lambda
2nd Proposal
Rejected - 1st Proposal - Can't work because Origin Groups only Support GET/HEAD/OPTIONS
Docs
Changing Custom Origin to S3 Origin
Changing S3 Origin to Custom Origin
Changing S3 Origin Region
huntharo commented
With Origin Groups the OriginRequest function can run twice. Need to detect whether this is the primary (should rewrite and sign for Function URL) or fallback origin (should not touch the request and let it fall through to S3 with OAI signing).