mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
fix(AWS API Gateway): Ensure to log deprecation at initialization stage
This commit is contained in:
parent
0c28844188
commit
b6d033a044
@ -250,17 +250,9 @@ module.exports = {
|
||||
return `${this.provider.serverless.service.provider.apiName}`;
|
||||
}
|
||||
|
||||
if (_.get(this.provider.serverless.service.provider.apiGateway, 'shouldStartNameWithService')) {
|
||||
return `${this.provider.serverless.service.service}-${this.provider.getStage()}`;
|
||||
}
|
||||
|
||||
this.provider.serverless._logDeprecation(
|
||||
'AWS_API_GATEWAY_NAME_STARTING_WITH_SERVICE',
|
||||
'Starting with next major version, API Gateway naming will be changed from "{stage}-{service}" to "{service}-{stage}".\n' +
|
||||
'Set "provider.apiGateway.shouldStartNameWithService" to "true" to adapt to the new behavior now.'
|
||||
);
|
||||
|
||||
return `${this.provider.getStage()}-${this.provider.serverless.service.service}`;
|
||||
return _.get(this.provider.serverless.service.provider.apiGateway, 'shouldStartNameWithService')
|
||||
? `${this.provider.serverless.service.service}-${this.provider.getStage()}`
|
||||
: `${this.provider.getStage()}-${this.provider.serverless.service.service}`;
|
||||
},
|
||||
generateApiGatewayDeploymentLogicalId(id) {
|
||||
return `ApiGatewayDeployment${id}`;
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
/* eslint-disable global-require */
|
||||
|
||||
const BbPromise = require('bluebird');
|
||||
const _ = require('lodash');
|
||||
|
||||
const validate = require('./lib/validate');
|
||||
const compileRestApi = require('./lib/restApi');
|
||||
@ -207,6 +208,24 @@ class AwsCompileApigEvents {
|
||||
// used for the generated method logical ids (GET, PATCH, PUT, DELETE, OPTIONS, ...)
|
||||
this.apiGatewayMethodLogicalIds = [];
|
||||
|
||||
if (
|
||||
this.serverless.service.provider.name === 'aws' &&
|
||||
!this.serverless.service.provider.apiName &&
|
||||
!_.get(this.serverless.service.provider.apiGateway, 'shouldStartNameWithService') &&
|
||||
!_.get(this.serverless.service.provider.apiGateway, 'restApiId') &&
|
||||
Object.values(this.serverless.service.functions).some(
|
||||
({ events }) => events && events.some(({ http }) => http)
|
||||
)
|
||||
) {
|
||||
this.serverless._logDeprecation(
|
||||
'AWS_API_GATEWAY_NAME_STARTING_WITH_SERVICE',
|
||||
'Starting with next major version, API Gateway naming will be changed from ' +
|
||||
'"{stage}-{service}" to "{service}-{stage}".\n' +
|
||||
'Set "provider.apiGateway.shouldStartNameWithService" to "true" ' +
|
||||
'to adapt to the new behavior now.'
|
||||
);
|
||||
}
|
||||
|
||||
Object.assign(
|
||||
this,
|
||||
validate,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user