@@ -354,6 +354,30 @@ describe("RestApiGateway validation errors", () => {
354354 executionPolicies : [ testPolicy ]
355355 } ) ) . toThrow ( "csocApiGatewayDestination must be provided when forwardCsocLogs is true" )
356356 } )
357+
358+ test ( "throws when enableServiceDomain is false and mutualTlsTrustStoreKey is provided" , ( ) => {
359+ const app = new App ( )
360+ const stack = new Stack ( app , "ValidationStack2" )
361+ const testPolicy = new ManagedPolicy ( stack , "TestPolicy" , {
362+ description : "test execution policy" ,
363+ statements : [
364+ new PolicyStatement ( {
365+ actions : [ "lambda:InvokeFunction" ] ,
366+ resources : [ "arn:aws:lambda:eu-west-2:123456789012:function:test-function" ]
367+ } )
368+ ]
369+ } )
370+
371+ expect ( ( ) => new RestApiGateway ( stack , "TestApiGateway" , {
372+ stackName : "test-stack" ,
373+ logRetentionInDays : 30 ,
374+ mutualTlsTrustStoreKey : "truststore.pem" ,
375+ forwardCsocLogs : false ,
376+ csocApiGatewayDestination : "" ,
377+ executionPolicies : [ testPolicy ] ,
378+ enableServiceDomain : false
379+ } ) ) . toThrow ( "mutualTlsTrustStoreKey should not be provided when enableServiceDomain is false" )
380+ } )
357381} )
358382
359383describe ( "RestApiGateway enableServiceDomain default behaviour" , ( ) => {
@@ -387,3 +411,36 @@ describe("RestApiGateway enableServiceDomain default behaviour", () => {
387411 template . resourceCountIs ( "AWS::Route53::RecordSet" , 2 )
388412 } )
389413} )
414+
415+ describe ( "RestApiGateway with enableServiceDomain false" , ( ) => {
416+ test ( "does not create custom domain resources when enableServiceDomain is false" , ( ) => {
417+ const app = new App ( )
418+ const stack = new Stack ( app , "DisableServiceDomainStack" )
419+ const testPolicy = new ManagedPolicy ( stack , "TestPolicy" , {
420+ description : "test execution policy" ,
421+ statements : [
422+ new PolicyStatement ( {
423+ actions : [ "lambda:InvokeFunction" ] ,
424+ resources : [ "arn:aws:lambda:eu-west-2:123456789012:function:test-function" ]
425+ } )
426+ ]
427+ } )
428+
429+ const apiGateway = new RestApiGateway ( stack , "TestApiGateway" , {
430+ stackName : "test-stack" ,
431+ logRetentionInDays : 30 ,
432+ mutualTlsTrustStoreKey : undefined ,
433+ forwardCsocLogs : false ,
434+ csocApiGatewayDestination : "" ,
435+ executionPolicies : [ testPolicy ] ,
436+ enableServiceDomain : false
437+ } )
438+
439+ apiGateway . api . root . addMethod ( "GET" )
440+
441+ const template = Template . fromStack ( stack )
442+ template . resourceCountIs ( "AWS::CertificateManager::Certificate" , 0 )
443+ template . resourceCountIs ( "AWS::ApiGateway::DomainName" , 0 )
444+ template . resourceCountIs ( "AWS::Route53::RecordSet" , 0 )
445+ } )
446+ } )
0 commit comments