fix(AWS API Gateway): Fix support for provider.apiGateway.stage

(PR #11772)
This commit is contained in:
Charlie Benger-Stevenson 2023-03-03 16:18:54 +00:00 committed by GitHub
parent 86a55950f8
commit 6fe2ea5bc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 2 deletions

View File

@ -13,7 +13,7 @@ module.exports = {
Type: 'AWS::ApiGateway::Deployment',
Properties: {
RestApiId: this.provider.getApiGatewayRestApiId(),
StageName: this.provider.getStage(),
StageName: this.provider.getApiGatewayStage(),
Description: this.provider.getApiGatewayDescription(),
},
DependsOn: this.apiGatewayMethodLogicalIds,

View File

@ -5,4 +5,4 @@ module.exports = {
"path": "resources"
}
}
}
};

View File

@ -407,4 +407,25 @@ describe('test/unit/lib/plugins/aws/package/compile/events/apiGateway/lib/stage/
},
});
});
it('should use stage name from provider if provider.apiGateway.stage is configured', async () => {
// https://github.com/serverless/serverless/issues/11675
const { cfTemplate, awsNaming } = await runServerless({
fixture: 'api-gateway',
command: 'package',
configExt: {
provider: {
apiGateway: {
stage: 'foo',
},
},
},
});
expect(awsNaming.provider.getApiGatewayStage()).to.equal('foo');
const [apiGatewayDeploymentKey] = Object.keys(cfTemplate.Resources).filter((k) =>
k.startsWith('ApiGatewayDeployment')
);
const apiGatewayDeployment = cfTemplate.Resources[apiGatewayDeploymentKey];
expect(apiGatewayDeployment.Properties.StageName).to.equal('foo');
});
});