Skip to content

Instantly share code, notes, and snippets.

@andgineer
Created March 1, 2024 08:07
Show Gist options
  • Save andgineer/913e7d6b85a1c34db7c8eeca64a8574f to your computer and use it in GitHub Desktop.
Save andgineer/913e7d6b85a1c34db7c8eeca64a8574f to your computer and use it in GitHub Desktop.
Send CloudWatch logs to OpenSech with Kinesis Firehose
const firehoseRole = new iam.Role(this, 'FirehoseDeliveryRole', {
assumedBy: new iam.ServicePrincipal('firehose.amazonaws.com'),
});
domain.grantWrite(firehoseRole);
// Create a Kinesis Data Firehose delivery stream
const deliveryStream = new firehose.CfnDeliveryStream(this, 'LogsDeliveryStream', {
deliveryStreamType: 'DirectPut',
openSearchDestinationConfiguration: {
domainArn: domain.domainArn,
roleArn: firehoseRole.roleArn,
indexName: 'cloudwatch-logs',
typeName: '_doc',
bufferingHints: {
intervalInSeconds: 300,
sizeInMBs: 5
},
s3BackupMode: 'FailedDocumentsOnly',
s3Configuration: {
bucketArn: 'arn:aws:s3:::your-backup-bucket-name',
roleArn: firehoseRole.roleArn
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment