@@ -308,7 +308,7 @@ export function buildCDN(
308308 cachePolicyId : disabledCachePolicy . apply ( ( policy ) => policy . id ! ) ,
309309 targetOriginId : 'httpOrigin' ,
310310 } ,
311- orderedCacheBehaviors : routes . map ( ( x ) => buildBehavior ( x , staticHeaders ) ) ,
311+ orderedCacheBehaviors : buildBehaviors ( routes , staticHeaders ) ,
312312 restrictions : {
313313 geoRestriction : {
314314 restrictionType : 'none' ,
@@ -368,9 +368,28 @@ export function buildCDN(
368368 return distribution
369369}
370370
371- function buildBehavior ( route : string , headers : string [ ] ) {
371+ interface Behavior {
372+ pathPattern : string
373+ allowedMethods : string [ ]
374+ cachedMethods : string [ ]
375+ targetOriginId : string
376+ originRequestPolicyId : pulumi . Output < string >
377+ cachePolicyId : pulumi . Output < string >
378+ viewerProtocolPolicy : string
379+ }
380+
381+ function buildBehaviors ( routes : string [ ] , headers : string [ ] ) : Behavior [ ] {
382+ const behaviors : Behavior [ ] = [ ]
383+ for ( const [ index , route ] of routes . entries ( ) ) {
384+ const behavior = buildBehavior ( route , headers , index )
385+ behaviors . push ( behavior )
386+ }
387+ return behaviors
388+ }
389+
390+ function buildBehavior ( route : string , headers : string [ ] , index : number ) : Behavior {
372391 const routeRequestPolicy = new aws . cloudfront . OriginRequestPolicy (
373- registerName ( `RouteRequestPolicy ( ${ route } ) ` ) ,
392+ registerName ( `RouteRequestPolicy${ index } ` ) ,
374393 {
375394 cookiesConfig : {
376395 cookieBehavior : 'none' ,
0 commit comments