Skip to content

@aws-cdk/aws-pipes-alpha: add missing L2 constructs that implement ILogDestination interface #31671

@garysassano

Description

@garysassano

Describe the feature

Current Behavior

Currently, to add a CloudWatch log group as a destination for a Pipe, developers must manually implement the ILogDestination interface:

const logGroup = new LogGroup(this, "LogGroup", {
  retention: RetentionDays.THREE_MONTHS,
  removalPolicy: RemovalPolicy.DESTROY,
});

const cwLogGroupDestination: ILogDestination = {
  bind: () => ({
    parameters: {
      cloudwatchLogsLogDestination: {
        logGroupArn: logGroup.logGroupArn,
      },
    },
  }),
  grantPush: (grantee) => {
    logGroup.grantWrite(grantee);
  },
};

new Pipe(this, "Pipe", {
  logDestinations: [cwLogGroupDestination],
});

Proposed Solution

We should introduce three new L2 constructs implementing the ILogDestination interface to improve developer experience. The expected usage would be more straightforward:

const logGroup = new LogGroup(this, "LogGroup", {
  retention: RetentionDays.THREE_MONTHS,
  removalPolicy: RemovalPolicy.DESTROY,
});

new Pipe(this, "Pipe", {
  logDestinations: [new CloudwatchLogsLogDestination(logGroup)],
});

Implementation Details

We need to create three classes that implement ILogDestination, corresponding to the options defined in the LogDestinationParameters interface:

  1. CloudwatchLogsLogDestination
  2. FirehoseLogDestination
  3. S3LogDestination

These class names align with the existing property names in the LogDestinationParameters interface:

/**
 * Log destination configuration parameters.
 */
export interface LogDestinationParameters {
    /**
     * The logging configuration settings for the pipe.
     *
     * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-pipes-pipe-pipelogconfiguration.html#cfn-pipes-pipe-pipelogconfiguration-cloudwatchlogslogdestination
     *
     * @default - none
     */
    readonly cloudwatchLogsLogDestination?: CfnPipe.CloudwatchLogsLogDestinationProperty;
    /**
     * The Amazon Kinesis Data Firehose logging configuration settings for the pipe.
     *
     * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-pipes-pipe-pipelogconfiguration.html#cfn-pipes-pipe-pipelogconfiguration-firehoselogdestination
     *
     * @default - none
     */
    readonly firehoseLogDestination?: CfnPipe.FirehoseLogDestinationProperty;
    /**
     * The Amazon S3 logging configuration settings for the pipe.
     *
     * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-pipes-pipe-pipelogconfiguration.html#cfn-pipes-pipe-pipelogconfiguration-s3logdestination
     *
     * @default - none
     */
    readonly s3LogDestination?: CfnPipe.S3LogDestinationProperty;
}

Use Case

This enhancement will significantly improve the developer experience when working with log destinations in CDK Pipes, making it more consistent with the expected L2 construct patterns.

Proposed Solution

No response

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.161.1

Environment details (OS name and version, etc.)

Ubuntu 24.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-logsRelated to Amazon CloudWatch Logseffort/mediumMedium work item – several days of effortfeature-requestA feature should be added or improved.p2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions