@@ -610,6 +610,71 @@ describe("server-side website", () => {
610610 } ) ;
611611 } ) ;
612612
613+ it ( "should treat empty string domain and certificate as unconfigured" , async ( ) => {
614+ const { cfTemplate, computeLogicalId } = await runServerless ( {
615+ command : "package" ,
616+ config : Object . assign ( baseConfig , {
617+ constructs : {
618+ backend : {
619+ type : "server-side-website" ,
620+ domain : "" ,
621+ certificate : "" ,
622+ } ,
623+ } ,
624+ } ) ,
625+ } ) ;
626+ const cfDistributionLogicalId = computeLogicalId ( "backend" , "CDN" ) ;
627+ // No Aliases or ViewerCertificate should be set
628+ expect ( cfTemplate . Resources [ cfDistributionLogicalId ] ) . not . toHaveProperty (
629+ "Properties.DistributionConfig.Aliases"
630+ ) ;
631+ expect ( cfTemplate . Resources [ cfDistributionLogicalId ] ) . not . toHaveProperty (
632+ "Properties.DistributionConfig.ViewerCertificate"
633+ ) ;
634+ } ) ;
635+
636+ it ( "should treat empty string domain with valid certificate as unconfigured" , async ( ) => {
637+ const { cfTemplate, computeLogicalId } = await runServerless ( {
638+ command : "package" ,
639+ config : Object . assign ( baseConfig , {
640+ constructs : {
641+ backend : {
642+ type : "server-side-website" ,
643+ domain : "" ,
644+ certificate :
645+ "arn:aws:acm:us-east-1:123456615250:certificate/0a28e63d-d3a9-4578-9f8b-14347bfe8123" ,
646+ } ,
647+ } ,
648+ } ) ,
649+ } ) ;
650+ const cfDistributionLogicalId = computeLogicalId ( "backend" , "CDN" ) ;
651+ // No Aliases should be set (domain is empty)
652+ expect ( cfTemplate . Resources [ cfDistributionLogicalId ] ) . not . toHaveProperty (
653+ "Properties.DistributionConfig.Aliases"
654+ ) ;
655+ } ) ;
656+
657+ it ( "should treat empty array domain as unconfigured" , async ( ) => {
658+ const { cfTemplate, computeLogicalId } = await runServerless ( {
659+ command : "package" ,
660+ config : Object . assign ( baseConfig , {
661+ constructs : {
662+ backend : {
663+ type : "server-side-website" ,
664+ domain : [ ] ,
665+ certificate :
666+ "arn:aws:acm:us-east-1:123456615250:certificate/0a28e63d-d3a9-4578-9f8b-14347bfe8123" ,
667+ } ,
668+ } ,
669+ } ) ,
670+ } ) ;
671+ const cfDistributionLogicalId = computeLogicalId ( "backend" , "CDN" ) ;
672+ // No Aliases should be set (domain is empty array)
673+ expect ( cfTemplate . Resources [ cfDistributionLogicalId ] ) . not . toHaveProperty (
674+ "Properties.DistributionConfig.Aliases"
675+ ) ;
676+ } ) ;
677+
613678 it ( "trims CloudFront function names to stay under the limit" , async ( ) => {
614679 const { cfTemplate, computeLogicalId } = await runServerless ( {
615680 command : "package" ,
0 commit comments