Skip to content

Commit

Permalink
fix(AWS HTTP API): Ensure to log deprecation at initialization stage
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Nov 3, 2020
1 parent ebeac9d commit 8023118
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions lib/plugins/aws/package/compile/events/httpApi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,28 @@ class HttpApiEvents {
},
],
});

if (this.serverless.service.provider.name === 'aws') {
if (_.get(this.serverless.service.provider, ['httpApi', 'timeout'])) {
this.serverless._logDeprecation(
'AWS_HTTP_API_TIMEOUT',
'"provider.httpApi.timeout" is deprecated. ' +
'HTTP API endpoints are configured to follow timeout setting as set for functions.'
);
}
if (
Object.values(this.serverless.service.functions).some(
({ events }) =>
events && events.some(({ httpApi: eventObject }) => _.get(eventObject, 'timeout'))
)
) {
this.serverless._logDeprecation(
'AWS_HTTP_API_TIMEOUT',
'"functions[].events.httpApi.timeout" is deprecated. ' +
'HTTP API endpoints are configured to follow timeout setting as set for functions.'
);
}
}
}
getApiIdConfig() {
return this.config.id || { Ref: this.provider.naming.getHttpApiLogicalId() };
Expand Down Expand Up @@ -303,13 +325,6 @@ Object.defineProperties(
})}`;
}

if (userConfig.timeout) {
this.serverless._logDeprecation(
'AWS_HTTP_API_TIMEOUT',
'"provider.httpApi.timeout" is deprecated. ' +
'HTTP API endpoints are configured to follow timeout setting as set for functions.'
);
}
for (const [functionName, functionData] of _.entries(this.serverless.service.functions)) {
const routeTargetData = {
functionName,
Expand Down Expand Up @@ -441,11 +456,6 @@ Object.defineProperties(
const functionTimeout =
Number(functionData.timeout) || Number(this.serverless.service.provider.timeout) || 6;
if (routeTargetData.timeout) {
this.serverless._logDeprecation(
'AWS_HTTP_API_TIMEOUT',
`"functions[].events.httpApi.timeout" is deprecated (found one defined for '${functionName}'s endpoint). ` +
'HTTP API endpoints are configured to follow timeout setting as set for functions.'
);
if (functionTimeout >= routeTargetData.timeout) {
logWarning(
`HTTP API endpoint timeout setting (${routeTargetData.timeout}s) is ` +
Expand Down

0 comments on commit 8023118

Please sign in to comment.