Skip to content

Commit

Permalink
fix(AWS APIGW): Fix Rest API id detection when no API GW involved
Browse files Browse the repository at this point in the history
Regression introduced with #7126
  • Loading branch information
medikoo committed Dec 23, 2019
1 parent d315bb4 commit a8feaaf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ module.exports = {
if (this.isExternalRestApi) return null;
if (!this.apiGatewayRestApiId) {
// Could not resolve REST API id automatically
if (!this.serverless.utils.isEventUsed(this.state.service.functions, 'http')) {
return null;
}

if (!this.hasTracingConfigured && !this.hasLogsConfigured) {
// Do crash if there are no API Gateway customizations to apply
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,18 @@ describe('#updateStage()', () => {
}
);

it(
'should not apply hack when restApiId could not be resolved and ' +
'no http events are detected',
() => {
context.state.service.provider.tracing = { apiGateway: true };
context.options.stage = 'foo';
delete context.serverless.service.provider.compiledCloudFormationTemplate.Resources
.ApiGatewayRestApi;
return updateStage.call(context);
}
);

it('should update the stage with a custom APIGW log format if given', () => {
context.state.service.provider.logs = {
restApi: {
Expand Down

0 comments on commit a8feaaf

Please sign in to comment.