aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.68k stars 3.93k forks source link

chore(kinesisfirehose-destinations): refactor logging to combine logGroup and logging properties into loggingConfig #31488

Closed paulhcsun closed 1 month ago

paulhcsun commented 1 month ago

Reason for this change

The logging and logGroup properties contain a restriction where a logGroup cannot be provided if logging is set to false. This was previously handled by error handling but we want to change this to make it impossible for a user to run into that scenario in the first place.

Description of changes

BREAKING CHANGE: the logging and logGroup properties in DestinationLoggingProps have been removed and replaced with a single optional property loggingConfig which accepts a class of type LoggingConfig.

Details

Combine the logging and logGroup properties into a single new optional property called loggingConfig which accepts a class of type LoggingConfig.

LoggingConfig is an abstract class which can be instantiated through either an instance of EnableLogging or DisableLogging which can be used in the following 3 ways:

import * as logs from 'aws-cdk-lib/aws-logs';

const logGroup = new logs.LogGroup(this, 'Log Group');
declare const bucket: s3.Bucket;

// 1. Enable logging with no parameters - a log group will be created for you
const destinationWithLogging = new destinations.S3Bucket(bucket, {
  loggingConfig: new destinations.EnableLogging(),
});

// 2. Enable a logging and pass in a logGroup to be used
const destinationWithLoggingAndMyLogGroup = new destinations.S3Bucket(bucket, {
  loggingConfig: new destinations.EnableLogging(logGroup),
});

// 3. Disable logging (does not accept any parameters so it is now impossible to provide a logGroup in this case)
const destinationWithoutLogging = new destinations.S3Bucket(bucket, {
  loggingConfig: new destinations.DisableLogging(),
});

Description of how you validated changes

unit + integ test

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license …yptionKey

aws-cdk-automation commented 1 month ago

AWS CodeBuild CI Report

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

mergify[bot] commented 1 month ago

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

github-actions[bot] commented 1 month ago

Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one.