Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(apigateway): disable execute api endpoint #14526

Merged
merged 4 commits into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/@aws-cdk/aws-apigateway/lib/restapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 14 additions & 0 deletions packages/@aws-cdk/aws-apigateway/test/restapi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
});
});