From 1882d7c14745ab60cb633c232c8c4d0f1eaafd82 Mon Sep 17 00:00:00 2001 From: Ranjith FH <86655894+ranjith-jagadeesh@users.noreply.github.com> Date: Mon, 13 Jun 2022 22:37:14 +0530 Subject: [PATCH] fix(eks): add clusterLogging props to Fargate Cluster (#20707) Fixes #19302 ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-eks/lib/cluster.ts | 13 +++++---- .../@aws-cdk/aws-eks/test/fargate.test.ts | 27 +++++++++++++++++++ 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/packages/@aws-cdk/aws-eks/lib/cluster.ts b/packages/@aws-cdk/aws-eks/lib/cluster.ts index 50f994aaa0cc2..3aab173529828 100644 --- a/packages/@aws-cdk/aws-eks/lib/cluster.ts +++ b/packages/@aws-cdk/aws-eks/lib/cluster.ts @@ -612,6 +612,12 @@ export interface ClusterOptions extends CommonClusterOptions { * @default - The controller is not installed. */ readonly albController?: AlbControllerOptions; + /** + * The cluster log types which you want to enable. + * + * @default - none + */ + readonly clusterLogging?: ClusterLoggingTypes[]; } /** @@ -753,13 +759,6 @@ export interface ClusterProps extends ClusterOptions { * @default - none */ readonly tags?: { [key: string]: string }; - - /** - * The cluster log types which you want to enable. - * - * @default - none - */ - readonly clusterLogging?: ClusterLoggingTypes[]; } /** diff --git a/packages/@aws-cdk/aws-eks/test/fargate.test.ts b/packages/@aws-cdk/aws-eks/test/fargate.test.ts index ddd195c7574d4..e028981ff7bf2 100644 --- a/packages/@aws-cdk/aws-eks/test/fargate.test.ts +++ b/packages/@aws-cdk/aws-eks/test/fargate.test.ts @@ -458,4 +458,31 @@ describe('fargate', () => { }); }); + + test('supports cluster logging with FargateCluster', () => { + // GIVEN + const stack = new Stack(); + + // WHEN + + new eks.FargateCluster(stack, 'FargateCluster', { + version: CLUSTER_VERSION, + clusterLogging: [ + eks.ClusterLoggingTypes.API, + eks.ClusterLoggingTypes.AUTHENTICATOR, + eks.ClusterLoggingTypes.SCHEDULER, + ], + }); + + //THEN + Template.fromStack(stack).hasResourceProperties('Custom::AWSCDK-EKS-Cluster', { + Config: { + logging: { + clusterLogging: [ + { enabled: true, types: ['api', 'authenticator', 'scheduler'] }, + ], + }, + }, + }); + }); });