mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
Merge pull request #6402 from sameer-s/master
Changed AWS subscription filters to use function object name
This commit is contained in:
commit
d0793ee65c
@ -149,8 +149,6 @@ module.exports = {
|
||||
*/
|
||||
checkLogGroupSubscriptionFilterResourceLimitExceeded() {
|
||||
const region = this.provider.getRegion();
|
||||
const serviceName = this.serverless.service.getServiceName();
|
||||
const stage = this.provider.getStage();
|
||||
const cloudWatchLogsSdk = new this.provider.sdk.CloudWatchLogs({ region });
|
||||
|
||||
return this.provider.getAccountId().then(accountId =>
|
||||
@ -187,10 +185,8 @@ module.exports = {
|
||||
cloudWatchLogsSdk,
|
||||
accountId,
|
||||
logGroupName,
|
||||
functionName,
|
||||
functionObj,
|
||||
region,
|
||||
serviceName,
|
||||
stage,
|
||||
});
|
||||
});
|
||||
|
||||
@ -204,10 +200,8 @@ module.exports = {
|
||||
const cloudWatchLogsSdk = params.cloudWatchLogsSdk;
|
||||
const accountId = params.accountId;
|
||||
const logGroupName = params.logGroupName;
|
||||
const functionName = params.functionName;
|
||||
const functionObj = params.functionObj;
|
||||
const region = params.region;
|
||||
const serviceName = params.serviceName;
|
||||
const stage = params.stage;
|
||||
|
||||
return (
|
||||
cloudWatchLogsSdk
|
||||
@ -223,7 +217,7 @@ module.exports = {
|
||||
|
||||
const oldDestinationArn = subscriptionFilter.destinationArn;
|
||||
const filterName = subscriptionFilter.filterName;
|
||||
const newDestinationArn = `arn:aws:lambda:${region}:${accountId}:function:${serviceName}-${stage}-${functionName}`;
|
||||
const newDestinationArn = `arn:aws:lambda:${region}:${accountId}:function:${functionObj.name}`;
|
||||
|
||||
// everything is fine, just return
|
||||
if (oldDestinationArn === newDestinationArn) {
|
||||
|
||||
@ -577,6 +577,8 @@ describe('checkForChanges', () => {
|
||||
},
|
||||
};
|
||||
|
||||
awsDeploy.serverless.service.setFunctionNames();
|
||||
|
||||
describeSubscriptionFiltersResponse = {
|
||||
subscriptionFilters: [],
|
||||
};
|
||||
@ -593,6 +595,8 @@ describe('checkForChanges', () => {
|
||||
},
|
||||
};
|
||||
|
||||
awsDeploy.serverless.service.setFunctionNames();
|
||||
|
||||
describeSubscriptionFiltersResponse = {
|
||||
subscriptionFilters: [
|
||||
{
|
||||
@ -614,6 +618,8 @@ describe('checkForChanges', () => {
|
||||
},
|
||||
};
|
||||
|
||||
awsDeploy.serverless.service.setFunctionNames();
|
||||
|
||||
describeSubscriptionFiltersResponse = {
|
||||
subscriptionFilters: [
|
||||
{
|
||||
@ -627,6 +633,54 @@ describe('checkForChanges', () => {
|
||||
.checkForChanges()
|
||||
.then(() => expect(deleteSubscriptionFilterStub).to.have.been.called);
|
||||
});
|
||||
|
||||
it('should not call delete if there is a subFilter and the ARNs are the same with custom function name', () => {
|
||||
awsDeploy.serverless.service.functions = {
|
||||
first: {
|
||||
name: 'my-test-function',
|
||||
events: [{ cloudwatchLog: '/aws/lambda/hello1' }],
|
||||
},
|
||||
};
|
||||
|
||||
awsDeploy.serverless.service.setFunctionNames();
|
||||
|
||||
describeSubscriptionFiltersResponse = {
|
||||
subscriptionFilters: [
|
||||
{
|
||||
destinationArn: `arn:aws:lambda:${region}:${accountId}:function:my-test-function`,
|
||||
filterName: 'dummy-filter',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
return awsDeploy
|
||||
.checkForChanges()
|
||||
.then(() => expect(deleteSubscriptionFilterStub).to.not.have.been.called);
|
||||
});
|
||||
|
||||
it('should call delete if there is a subFilter but the ARNs are not the same with custom function name', () => {
|
||||
awsDeploy.serverless.service.functions = {
|
||||
first: {
|
||||
name: 'my-test-function',
|
||||
events: [{ cloudwatchLog: '/aws/lambda/hello1' }],
|
||||
},
|
||||
};
|
||||
|
||||
awsDeploy.serverless.service.setFunctionNames();
|
||||
|
||||
describeSubscriptionFiltersResponse = {
|
||||
subscriptionFilters: [
|
||||
{
|
||||
destinationArn: `arn:aws:lambda:${region}:${accountId}:function:my-other-test-function`,
|
||||
filterName: 'dummy-filter',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
return awsDeploy
|
||||
.checkForChanges()
|
||||
.then(() => expect(deleteSubscriptionFilterStub).to.have.been.called);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user