mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
Merge pull request #7034 from serverless/limit-sdk-updates-to-local-apigw
Do not apply APIGW wide settings on externally referenced APIGW
This commit is contained in:
commit
cd76e7eb8e
@ -4,7 +4,6 @@ const _ = require('lodash');
|
||||
const BbPromise = require('bluebird');
|
||||
const ServerlessError = require('../../../../../../../../classes/Error').ServerlessError;
|
||||
|
||||
const isRestApiId = RegExp.prototype.test.bind(/^[a-z0-9]{3,}$/);
|
||||
const defaultApiGatewayLogFormat = [
|
||||
'requestId: $context.requestId',
|
||||
'ip: $context.identity.sourceIp',
|
||||
@ -52,6 +51,8 @@ module.exports = {
|
||||
.call(this)
|
||||
.then(resolveRestApiId.bind(this))
|
||||
.then(() => {
|
||||
// Do not update APIGW-wide settings, in case external APIGW is referenced
|
||||
if (this.isExternalRestApi) return null;
|
||||
if (!this.apiGatewayRestApiId) {
|
||||
// Could not resolve REST API id automatically
|
||||
|
||||
@ -110,7 +111,8 @@ function resolveRestApiId() {
|
||||
const provider = this.state.service.provider;
|
||||
const externalRestApiId = provider.apiGateway && provider.apiGateway.restApiId;
|
||||
if (externalRestApiId) {
|
||||
resolve(isRestApiId(externalRestApiId) ? externalRestApiId : null);
|
||||
this.isExternalRestApi = true;
|
||||
resolve(null);
|
||||
return;
|
||||
}
|
||||
const apiGatewayResource = resolveApiGatewayResource(
|
||||
|
||||
@ -438,21 +438,12 @@ describe('#updateStage()', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should resolve custom restApiId', () => {
|
||||
context.state.service.provider.tracing = { apiGateway: false };
|
||||
providerRequestStub
|
||||
.withArgs('APIGateway', 'getStage', {
|
||||
restApiId: 'foobarfoo1',
|
||||
stageName: 'dev',
|
||||
})
|
||||
.resolves({
|
||||
variables: {
|
||||
old: 'tag',
|
||||
},
|
||||
});
|
||||
it('should ignore external api gateway', () => {
|
||||
context.state.service.provider.apiGateway = { restApiId: 'foobarfoo1' };
|
||||
context.state.service.provider.tracing = { apiGateway: false };
|
||||
return updateStage.call(context).then(() => {
|
||||
expect(context.apiGatewayRestApiId).to.equal('foobarfoo1');
|
||||
expect(context.isExternalRestApi).to.equal(true);
|
||||
expect(context.apiGatewayRestApiId).to.equal(null);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user