Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: show issue with yarn pnp + cross-region edge function #1

Draft
wants to merge 1 commit into
base: yarn
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ cdk.out
!.yarn/releases
!.yarn/sdks
!.yarn/versions

!lib/lambda-at-edge/index.js
43 changes: 32 additions & 11 deletions lib/cdk-bug-reports-stack.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
import { Stack, StackProps } from 'aws-cdk-lib';
import { Construct } from 'constructs';
// import * as sqs from 'aws-cdk-lib/aws-sqs';
import * as cloudfront from "aws-cdk-lib/aws-cloudfront";
import * as origins from "aws-cdk-lib/aws-cloudfront-origins";
import * as lambda from "aws-cdk-lib/aws-lambda";
import * as s3 from "aws-cdk-lib/aws-s3";
import * as cdk from "aws-cdk-lib";
import { join } from "path";
import { Construct } from "constructs";

export class CdkBugReportsStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
export class CdkBugReportsStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, {
env: {
region: 'us-west-2',
},
...props
});

// The code that defines your stack goes here
const bucket = new s3.Bucket(this, "HostingBucket");
const rootRedirectEdgeFunction = new cloudfront.experimental.EdgeFunction(this, "RootRedirectEdgeFunction", {
runtime: lambda.Runtime.NODEJS_14_X,
handler: "root-redirect.handler",
code: lambda.Code.fromAsset(join(__dirname, "lambda-at-edge")),
});

// example resource
// const queue = new sqs.Queue(this, 'CdkBugReportsQueue', {
// visibilityTimeout: cdk.Duration.seconds(300)
// });
new cloudfront.Distribution(this, "SiteDistribution", {
defaultBehavior: {
origin: new origins.S3Origin(bucket),
edgeLambdas: [
{
eventType: cloudfront.LambdaEdgeEventType.VIEWER_REQUEST,
functionVersion: rootRedirectEdgeFunction.currentVersion,
},
],
},
});
}
}
3 changes: 3 additions & 0 deletions lib/lambda-at-edge/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
handler() {}
}
5 changes: 1 addition & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
"inlineSourceMap": true,
"inlineSources": true,
"experimentalDecorators": true,
"strictPropertyInitialization": false,
"typeRoots": [
"./node_modules/@types"
]
"strictPropertyInitialization": false
},
"exclude": [
"node_modules",
Expand Down