Skip to content

Commit

Permalink
Merge branch 'main' into iot-state-machine
Browse files Browse the repository at this point in the history
  • Loading branch information
jumic authored Jun 28, 2023
2 parents 1076898 + edad593 commit d2cb1b5
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/handle-stale-discussions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ jobs:
handle-stale-discussions:
name: Handle stale discussions
runs-on: ubuntu-latest
permissions:
discussions: write
steps:
- name: Stale discussions action
uses: aws-github-ops/handle-stale-discussions@v1
Expand Down
3 changes: 3 additions & 0 deletions packages/@aws-cdk/integ-runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
"lib/workers/extract/index.js"
],
"externals": {
"optionalDependencies": [
"fsevents"
],
"dependencies": [
"aws-cdk"
]
Expand Down
5 changes: 4 additions & 1 deletion packages/aws-cdk-lib/core/lib/cfn-fn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,10 @@ export class Fn {
if (conditions.length === 1) {
return conditions[0] as ICfnRuleConditionExpression;
}
return Fn.conditionAnd(..._inGroupsOf(conditions, 10).map(group => new FnAnd(...group)));
if (conditions.length <= 10) {
return new FnAnd(...conditions);
}
return Fn.conditionAnd(..._inGroupsOf(conditions, 10).map(group => Fn.conditionAnd(...group)));
}

/**
Expand Down
100 changes: 100 additions & 0 deletions packages/aws-cdk-lib/core/test/condition.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,106 @@ describe('condition', () => {
});
});

test('condition length is 10n + 1 in Fn.conditionAnd', () => {
// GIVEN
const stack = new cdk.Stack();
const expression = cdk.Fn.conditionAnd(
cdk.Fn.conditionEquals('a', '1'),
cdk.Fn.conditionEquals('b', '2'),
cdk.Fn.conditionEquals('c', '3'),
cdk.Fn.conditionEquals('d', '4'),
cdk.Fn.conditionEquals('e', '5'),
cdk.Fn.conditionEquals('f', '6'),
cdk.Fn.conditionEquals('g', '7'),
cdk.Fn.conditionEquals('h', '8'),
cdk.Fn.conditionEquals('i', '9'),
cdk.Fn.conditionEquals('j', '10'),
cdk.Fn.conditionEquals('k', '11'),
);

// WHEN
new cdk.CfnCondition(stack, 'Condition', { expression });

// THEN
expect(toCloudFormation(stack)).toEqual({
Conditions: {
Condition: {
'Fn::And': [
{
'Fn::And': [
{ 'Fn::Equals': ['a', '1'] },
{ 'Fn::Equals': ['b', '2'] },
{ 'Fn::Equals': ['c', '3'] },
{ 'Fn::Equals': ['d', '4'] },
{ 'Fn::Equals': ['e', '5'] },
{ 'Fn::Equals': ['f', '6'] },
{ 'Fn::Equals': ['g', '7'] },
{ 'Fn::Equals': ['h', '8'] },
{ 'Fn::Equals': ['i', '9'] },
{ 'Fn::Equals': ['j', '10'] },
],
},
{
'Fn::Equals': ['k', '11'],
},
],
},
},
});
});

test('condition length is more than 10 in Fn.conditionAnd', () => {
// GIVEN
const stack = new cdk.Stack();
const expression = cdk.Fn.conditionAnd(
cdk.Fn.conditionEquals('a', '1'),
cdk.Fn.conditionEquals('b', '2'),
cdk.Fn.conditionEquals('c', '3'),
cdk.Fn.conditionEquals('d', '4'),
cdk.Fn.conditionEquals('e', '5'),
cdk.Fn.conditionEquals('f', '6'),
cdk.Fn.conditionEquals('g', '7'),
cdk.Fn.conditionEquals('h', '8'),
cdk.Fn.conditionEquals('i', '9'),
cdk.Fn.conditionEquals('j', '10'),
cdk.Fn.conditionEquals('k', '11'),
cdk.Fn.conditionEquals('l', '12'),
);

// WHEN
new cdk.CfnCondition(stack, 'Condition', { expression });

// THEN
expect(toCloudFormation(stack)).toEqual({
Conditions: {
Condition: {
'Fn::And': [
{
'Fn::And': [
{ 'Fn::Equals': ['a', '1'] },
{ 'Fn::Equals': ['b', '2'] },
{ 'Fn::Equals': ['c', '3'] },
{ 'Fn::Equals': ['d', '4'] },
{ 'Fn::Equals': ['e', '5'] },
{ 'Fn::Equals': ['f', '6'] },
{ 'Fn::Equals': ['g', '7'] },
{ 'Fn::Equals': ['h', '8'] },
{ 'Fn::Equals': ['i', '9'] },
{ 'Fn::Equals': ['j', '10'] },
],
},
{
'Fn::And': [
{ 'Fn::Equals': ['k', '11'] },
{ 'Fn::Equals': ['l', '12'] },
],
},
],
},
},
});
});

test('condition length is 10n + 1 in Fn.conditionOr', () => {
// GIVEN
const stack = new cdk.Stack();
Expand Down

0 comments on commit d2cb1b5

Please sign in to comment.