[{"data":1,"prerenderedAt":86},["ShallowReactive",2],{"pattern-cloudfront-s3-lambda-cdk":3},{"id":4,"title":5,"architectureURL":6,"cleanup":7,"contributors":13,"deploy":15,"description":19,"extension":20,"framework":21,"gitHub":22,"highlight":6,"introBox":31,"language":36,"level":37,"meta":38,"patternArch":39,"resources":73,"s3URL":6,"services":79,"stem":80,"testing":81,"videoId":30,"__hash__":85},"patterns\u002Fpatterns\u002Fcloudfront-s3-lambda-cdk.json","Amazon CloudFront to Amazon S3 and Amazon API Gateway",null,{"headline":8,"text":9},"Cleanup",[10,11,12],"1. In the source folder, from the command line enter:","\u003Ccode>npx cdk destroy --all\u003C\u002Fcode>","2. See additional notes in the repo.",[14],"content\u002Fcontributors\u002Fadrian-hesketh.json",{"text":16},[17,18],"npm i","npx cdk deploy --all","CloudFront to S3 and API Gateway backed by TypeScript Lambda functions","json","AWS CDK",{"template":23,"payloads":28},{"projectFolder":24,"repoURL":25,"templateURL":26,"templateFile":27},"cdk-cloudfront-to-s3-and-lambda","https:\u002F\u002Fgithub.com\u002Faws-samples\u002Fserverless-patterns\u002Ftree\u002Fmain\u002Fcdk-cloudfront-to-s3-and-lambda","serverless-patterns\u002Fcdk-cloudfront-to-s3-and-lambda","cdk\u002Flib\u002Fstatic-site-stack.ts",[29],{"headline":30,"payloadURL":30},"",{"headline":32,"text":33},"How it works",[34,35],"This pattern deploys a CloudFront distribution and routes HTTP traffic to two backend services based on the URL. Any URLs that have a path beginning with \u002Fapi\u002F are routed to an API Gateway which integrates with Lambda Functions which are written in TypeScript. All other traffic is routed to an S3 bucket.","The pattern also includes examples of using Lambda@Edge integrated with CloudFront to implement redirects, and to add CORS headers to API requests.","TypeScript","200",{},{"icon1":40,"icon2":45,"icon3":50,"icon4":52,"icon5":56,"icon6":59,"line1":62,"line2":65,"line3":67,"line4":69,"line5":71},{"x":41,"y":42,"service":43,"label":44},10,45,"cloudfront","CloudFront",{"x":46,"y":47,"service":48,"label":49},40,20,"lambda","Lambda@Edge",{"x":46,"y":51,"service":48,"label":49},70,{"x":53,"y":47,"service":54,"label":55},65,"s3","S3 bucket",{"x":53,"y":51,"service":57,"label":58},"apigw","API Gateway",{"x":60,"y":51,"service":48,"label":61},90,"AWS Lambda",{"from":63,"to":64,"label":30},"icon1","icon2",{"from":63,"to":66,"label":30},"icon3",{"from":64,"to":68,"label":30},"icon4",{"from":66,"to":70,"label":30},"icon5",{"from":70,"to":72,"label":30},"icon6",{"headline":74,"bullets":75},"Additional resources",[76],{"text":77,"link":78},"CDK Patterns","https:\u002F\u002Fcdkpatterns.com\u002F",{"from":43,"to":54},"patterns\u002Fcloudfront-s3-lambda-cdk",{"headline":82,"text":83},"Testing",[84],"You can test the solution by accessing the CloudFront distribution domain using a web browser.","pFDflxfLbNsV3XNgk9pKjKvuXthrv2KUnB1aQrNbq2E",1779273334397]