Skip to content

Commit

Permalink
fix(sns): sns subscription filter policy condition limit should be 150 (
Browse files Browse the repository at this point in the history
#24269)

The [Filter policy constraints docs](https://docs.aws.amazon.com/sns/latest/dg/subscription-filter-policy-constraints.html) says:

> For the complexity of the filter policy, the total combination of values must not exceed 150. Calculate the total combination by multiplying the number of values in each array.

This PR sets the complexity limit to the correct value.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
eliasbrange committed Feb 22, 2023
1 parent e47646c commit 1e1131c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-sns/lib/subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ export class Subscription extends Resource {

let total = 1;
Object.values(this.filterPolicy).forEach(filter => { total *= filter.length; });
if (total > 100) {
throw new Error(`The total combination of values (${total}) must not exceed 100.`);
if (total > 150) {
throw new Error(`The total combination of values (${total}) must not exceed 150.`);
}
}

Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-sns/test/subscription.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ describe('Subscription', () => {

});

test('throws with more than 100 conditions in a filter policy', () => {
test('throws with more than 150 conditions in a filter policy', () => {
// GIVEN
const stack = new cdk.Stack();
const topic = new sns.Topic(stack, 'Topic');
Expand All @@ -269,9 +269,9 @@ describe('Subscription', () => {
filterPolicy: {
a: { conditions: [...Array.from(Array(2).keys())] },
b: { conditions: [...Array.from(Array(10).keys())] },
c: { conditions: [...Array.from(Array(6).keys())] },
c: { conditions: [...Array.from(Array(8).keys())] },
},
})).toThrow(/\(120\) must not exceed 100/);
})).toThrow(/\(160\) must not exceed 150/);

});

Expand Down

0 comments on commit 1e1131c

Please sign in to comment.