Skip to content

Commit

Permalink
Removed region validation and converted return value to use ternary o…
Browse files Browse the repository at this point in the history
…perator on toOriginShieldProperty method
  • Loading branch information
smguggen committed Jul 29, 2021
1 parent d1efb1d commit 482abb2
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions packages/@aws-cdk/aws-cloudfront/lib/web-distribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1149,20 +1149,13 @@ export class CloudFrontWebDistribution extends cdk.Resource implements IDistribu

/**
* Takes origin shield region from props and converts to CfnDistribution.OriginShieldProperty
*/
*/
private toOriginShieldProperty(originConfig:SourceConfigurationRender): CfnDistribution.OriginShieldProperty | undefined {
const originShieldRegion = originConfig.originShieldRegion ??
originConfig.customOriginSource?.originShieldRegion ??
originConfig.s3OriginSource?.originShieldRegion;
if (originShieldRegion) {
if (!(/^\w\w\-[a-z]*\-\d$/).test(originShieldRegion)) {
throw new Error(`originShieldRegion ${originShieldRegion} is not a valid AWS region.`);
}
return {
enabled: true,
originShieldRegion,
};
}
return undefined;
return originShieldRegion
? { enabled: true, originShieldRegion }
: undefined;
}
}

0 comments on commit 482abb2

Please sign in to comment.