Created
March 1, 2024 08:07
-
-
Save andgineer/913e7d6b85a1c34db7c8eeca64a8574f to your computer and use it in GitHub Desktop.
Send CloudWatch logs to OpenSech with Kinesis Firehose
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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