Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Commit a9465e2

Browse files
Merge pull request #25 from getjerry/depeng/fix_duplicate_pathpatterns
fix(): duplicate cloudfront behavior path patterns
2 parents 0f2e688 + d7cfece commit a9465e2

File tree

1 file changed

+7
-0
lines changed
  • packages/serverless-components/aws-cloudfront/lib

1 file changed

+7
-0
lines changed

packages/serverless-components/aws-cloudfront/lib/index.js

+7
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,17 @@ const updateCloudFrontDistribution = async (cf, s3, distributionId, inputs) => {
280280
});
281281

282282
if (CacheBehaviors) {
283+
// path patterns that is updated in input
284+
const pathPatterns = CacheBehaviors.Items.map(
285+
(behavior) => behavior.PathPattern
286+
);
287+
283288
const existingCacheBehaviors = params.DistributionConfig.CacheBehaviors
284289
? params.DistributionConfig.CacheBehaviors.Items.filter(
285290
(behavior) => !inputOriginIds.includes(behavior.TargetOriginId)
286291
)
292+
// Cloudfront is not allow duplicate path patterns now
293+
.filter((behavior) => !pathPatterns.includes(behavior.PathPattern))
287294
: [];
288295
const inputCacheBehaviours = CacheBehaviors.Items.concat(
289296
existingCacheBehaviors

0 commit comments

Comments
 (0)