| 69 | ); |
| 70 | |
| 71 | const createDistribution = (route: string) => { |
| 72 | const id = route.substring(1).replace(/-\//g, ""); |
| 73 | const distribution = new aws_cloudfront.Distribution( |
| 74 | stack, |
| 75 | `${id}Distribution`, |
| 76 | { |
| 77 | defaultBehavior: { |
| 78 | origin: new aws_cloudfront_origins.HttpOrigin(httpEndpointNoProto, { |
| 79 | protocolPolicy: aws_cloudfront.OriginProtocolPolicy.HTTPS_ONLY, |
| 80 | originPath: route, |
| 81 | }), |
| 82 | allowedMethods: aws_cloudfront.AllowedMethods.ALLOW_ALL, |
| 83 | cachePolicy: aws_cloudfront.CachePolicy.CACHING_DISABLED, |
| 84 | }, |
| 85 | } |
| 86 | ); |
| 87 | new CfnOutput(stack, `DistributionOutput${id}`, { |
| 88 | value: distribution.distributionDomainName, |
| 89 | }); |
| 90 | }; |
| 91 | |
| 92 | const addRoute = (lambda: aws_lambda.Function, routePath: string) => { |
| 93 | const integration = new aws_apigatewayv2_integrations.HttpLambdaIntegration( |