diff --git a/.github/workflows/handle-stale-discussions.yml b/.github/workflows/handle-stale-discussions.yml index acee0ec83e409..2b89f2da15f21 100644 --- a/.github/workflows/handle-stale-discussions.yml +++ b/.github/workflows/handle-stale-discussions.yml @@ -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 diff --git a/packages/@aws-cdk/integ-runner/package.json b/packages/@aws-cdk/integ-runner/package.json index e813abd0fe939..4112e216760f4 100644 --- a/packages/@aws-cdk/integ-runner/package.json +++ b/packages/@aws-cdk/integ-runner/package.json @@ -29,6 +29,9 @@ "lib/workers/extract/index.js" ], "externals": { + "optionalDependencies": [ + "fsevents" + ], "dependencies": [ "aws-cdk" ] diff --git a/packages/aws-cdk-lib/core/lib/cfn-fn.ts b/packages/aws-cdk-lib/core/lib/cfn-fn.ts index 2441aaabe56a0..01b235a67d13b 100644 --- a/packages/aws-cdk-lib/core/lib/cfn-fn.ts +++ b/packages/aws-cdk-lib/core/lib/cfn-fn.ts @@ -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))); } /** diff --git a/packages/aws-cdk-lib/core/test/condition.test.ts b/packages/aws-cdk-lib/core/test/condition.test.ts index cfb5670394122..db7c8af4dfd10 100644 --- a/packages/aws-cdk-lib/core/test/condition.test.ts +++ b/packages/aws-cdk-lib/core/test/condition.test.ts @@ -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();