Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(kinesisfirehose): add HTTP Endpoint and Datadog destination #33657

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Prev Previous commit
Next Next commit
feat: add support for tags
  • Loading branch information
Benjamin Pottier authored and benjaminpottier committed Mar 5, 2025
commit 2620aa2c4396a792c08d4ae1c88fe5ba47555423
30 changes: 30 additions & 0 deletions packages/aws-cdk-lib/aws-kinesisfirehose/lib/datadog.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Construct } from 'constructs';
import { BackupMode, CommonDestinationProps } from './common';
import { DestinationBindOptions, DestinationConfig, IDestination } from './destination';
import { CfnDeliveryStream } from './kinesisfirehose.generated';
import * as iam from '../../aws-iam';
import { ISecret } from '../../aws-secretsmanager';
import { Duration, Size } from '../../core';
@@ -105,6 +106,20 @@ export interface BufferHints {
readonly size?: Size;
}

/**
* Datadog tag
*/
export interface DatadogTag {
/**
* Tag key
*/
key: string;
/**
* Tag value
*/
value: string;
}

/**
* Props for defining a Datadog destination of a Kinesis Data Firehose delivery stream.
*/
@@ -127,6 +142,10 @@ export interface DatadogProps extends CommonDestinationProps {
* @default 60 seconds
*/
readonly retryDuration?: Duration;
/**
* Datadog tags to apply for filtering.
*/
readonly tags?: DatadogTag[];
}

/**
@@ -168,6 +187,7 @@ export class Datadog implements IDestination {
},
requestConfiguration: {
contentEncoding: 'GZIP',
commonAttributes: this.createAttributesFromTags(),
},
retryOptions: {
durationInSeconds: this.props.retryDuration?.toSeconds() ?? 60,
@@ -190,4 +210,14 @@ export class Datadog implements IDestination {
? 'Enabled'
: undefined;
}
private createAttributesFromTags(): CfnDeliveryStream.HttpEndpointCommonAttributeProperty[] {
let attributes: any = [];
this.props.tags?.forEach((tag) => {
attributes.push({
attributeName: tag.key,
attributeValue: tag.value,
});
});
return attributes;
}
}
24 changes: 24 additions & 0 deletions packages/aws-cdk-lib/aws-kinesisfirehose/test/datadog.test.ts
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@ describe('Datadog destination', () => {
},
RequestConfiguration: {
ContentEncoding: 'GZIP',
CommonAttributes: [],
},
RetryOptions: {
DurationInSeconds: 60,
@@ -79,4 +80,27 @@ describe('Datadog destination', () => {
},
});
});

it('adds attributes when tags are provided', () => {
new firehose.DeliveryStream(stack, 'DeliveryStream', {
destination: new firehose.Datadog({
apiKey: secret,
url: firehose.DatadogLogsEndpointUrl.DATADOG_LOGS_US1,
tags: [{ key: 'source', value: 'cloudfront' }],
}),
});

Template.fromStack(stack).hasResourceProperties('AWS::KinesisFirehose::DeliveryStream', {
HttpEndpointDestinationConfiguration: {
RequestConfiguration: {
CommonAttributes: [
{
AttributeName: 'source',
AttributeValue: 'cloudfront',
},
],
},
},
});
});
});