diff --git a/packages/@aws-cdk/aws-apigateway/lib/restapi.ts b/packages/@aws-cdk/aws-apigateway/lib/restapi.ts index 9d74e2a1ec7a9..e213ddad7f22f 100644 --- a/packages/@aws-cdk/aws-apigateway/lib/restapi.ts +++ b/packages/@aws-cdk/aws-apigateway/lib/restapi.ts @@ -170,6 +170,16 @@ export interface RestApiBaseProps { * @default EndpointType.EDGE */ readonly endpointTypes?: EndpointType[]; + + /** + * Specifies whether clients can invoke the API using the default execute-api + * endpoint. To require that clients use a custom domain name to invoke the + * API, disable the default endpoint. + * @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html + * + * @default false + */ + readonly disableExecuteApiEndpoint?: boolean; } /** @@ -719,6 +729,7 @@ export class RestApi extends RestApiBase { apiKeySourceType: props.apiKeySourceType, cloneFrom: props.cloneFrom?.restApiId, parameters: props.parameters, + disableExecuteApiEndpoint: props.disableExecuteApiEndpoint, }); this.node.defaultChild = resource; this.restApiId = resource.ref; diff --git a/packages/@aws-cdk/aws-apigateway/test/restapi.test.ts b/packages/@aws-cdk/aws-apigateway/test/restapi.test.ts index 8a213ca5b8569..60cc707468c4c 100644 --- a/packages/@aws-cdk/aws-apigateway/test/restapi.test.ts +++ b/packages/@aws-cdk/aws-apigateway/test/restapi.test.ts @@ -1069,4 +1069,18 @@ describe('restapi', () => { expect(countMetric.color).toEqual(color); }); }); + + test('"disableExecuteApiEndpoint" can disable the default execute-api endpoint', () => { + // GIVEN + const stack = new Stack(); + + // WHEN + const api = new apigw.RestApi(stack, 'my-api', { disableExecuteApiEndpoint: true }); + api.root.addMethod('GET'); + + // THEN + expect(stack).toHaveResource('AWS::ApiGateway::RestApi', { + DisableExecuteApiEndpoint: true, + }); + }); });