Skip to content

Commit b32f217

Browse files
(addon): OpenSearch SIEM added CW Alarms (#1056)
* added CW Alarms * fix typo Co-authored-by: Brian969 <56414362+Brian969@users.noreply.github.com>
1 parent 07da113 commit b32f217

File tree

9 files changed

+425
-36
lines changed

9 files changed

+425
-36
lines changed

reference-artifacts/Add-ons/opensiem/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,3 +543,17 @@ The following AWS resources are retained when deleting the solution:
543543
2. In the operations account
544544
1. navigate to S3, open the S3 bucket prefixed with **opensearchsiemstack-**, and delete all the objects inside
545545
1. navigate to CloudFormation and delete the **OpenSearchSiemStack** stack
546+
547+
548+
## 11. Updates
549+
550+
### September 2022
551+
- Updated the CDK version to v2.40.0
552+
- Updated the OpenSearch cluster with the latest version 1.3 (will cause a Blue/Green Deployment)
553+
- Updated the OpenSearch cluster to use GP3 for the EBS volume type (will cause a Blue/Green Deployment)
554+
- Added 14 CloudWatch Alarms to monitor the OpenSearch cluster based on the recommendations [here](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/cloudwatch-alarms.html)
555+
- Reduced the Lambda Processor memory to 512MB and changed timeout to 2 minutes
556+
- Added a SNS queue to send alerts to registered emails.
557+
- New configurations:
558+
- "alertNotificationEmails": ["user@email.com"] CloudWatch Alarm will send notifications to emails listed here
559+
- "enableLambdaInsights": true Will enable CloudWatch Lambda Insights. This brings visibility into memory usage to have data to fine tune the Processor Lambda.

reference-artifacts/Add-ons/opensiem/SiemConfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,7 @@
5454
"s3NotificationTopicNameOrExistingArn": "----- REPLACE -----",
5555
"enableLambdaSubscription": false,
5656
"organizationId": "----- REPLACE -----",
57+
"enableLambdaInsights": false,
58+
"alertNotificationEmails": [""],
5759
"siemVersion": "v2.6.1a"
5860
}

reference-artifacts/Add-ons/opensiem/lib/open-search.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export class OpenSearchDomain extends Construct {
9898
});
9999

100100
this.resource = new opensearch.CfnDomain(this, 'Domain', {
101-
engineVersion: 'OpenSearch_1.1',
101+
engineVersion: 'OpenSearch_1.3',
102102
domainName,
103103
clusterConfig: {
104104
dedicatedMasterEnabled: true,
@@ -117,7 +117,7 @@ export class OpenSearchDomain extends Construct {
117117
ebsOptions: {
118118
ebsEnabled: true,
119119
volumeSize,
120-
volumeType: 'gp2',
120+
volumeType: 'gp3',
121121
},
122122
advancedSecurityOptions: {
123123
internalUserDatabaseEnabled: false,

reference-artifacts/Add-ons/opensiem/lib/opensearch-siem-stack.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ import { SnsEventSource } from 'aws-cdk-lib/aws-lambda-event-sources';
2323
import * as events from 'aws-cdk-lib/aws-events';
2424
import * as eventTargets from 'aws-cdk-lib/aws-events-targets';
2525
import * as sns from 'aws-cdk-lib/aws-sns';
26+
import * as snsSubscriptions from 'aws-cdk-lib/aws-sns-subscriptions';
2627
import * as sqs from 'aws-cdk-lib/aws-sqs';
2728
import * as cognito from './siem-cognito';
2829
import { SiemConfig } from './siem-config';
2930
import * as opensearch from './open-search';
3031
import { OpenSearchSiemConfigure } from './siem-configure';
3132
import { OpenSearchSiemGeoIpInit } from './siem-geoip-download';
33+
import { Alerts } from './siem-alerts';
3234

3335
export interface OpenSearchSiemStackProps extends StackProps {
3436
provisionServiceLinkedRole?: boolean;
@@ -251,14 +253,15 @@ export class OpenSearchSiemStack extends Stack {
251253
siemConfig.s3LogBuckets,
252254
siemConfig.siemVersion,
253255
siemConfig.enableLambdaSubscription,
256+
siemConfig.enableLambdaInsights,
254257
siemConfig.s3NotificationTopicNameOrExistingArn,
255258
siemBucket,
256259
);
257260

258-
this.configureSnsAlerts(this, kmsEncryptionKey);
261+
this.configureSnsAlerts(this, kmsEncryptionKey, domain.name, siemConfig.alertNotificationEmails);
259262
}
260263

261-
configureSnsAlerts(scope: Construct, kmsKey: kms.Key) {
264+
configureSnsAlerts(scope: Construct, kmsKey: kms.Key, clusterDomainName: string, alertEmails: string[]) {
262265
const snsAlertRole = new iam.Role(scope, 'SnsAlertRole', {
263266
roleName: 'opensearch-siem-sns-role',
264267
assumedBy: new iam.ServicePrincipal('es.amazonaws.com'),
@@ -270,7 +273,18 @@ export class OpenSearchSiemStack extends Stack {
270273
masterKey: kmsKey,
271274
});
272275

276+
if (alertEmails && alertEmails.length > 0) {
277+
for (const email of alertEmails) {
278+
snsAlertTopic.addSubscription(new snsSubscriptions.EmailSubscription(email));
279+
}
280+
}
281+
273282
snsAlertTopic.grantPublish(snsAlertRole);
283+
284+
new Alerts(scope, 'opensearch-siem-alerts', {
285+
alertTopic: snsAlertTopic,
286+
clusterDomainName,
287+
});
274288
}
275289

276290
configureSiemProcessor(
@@ -284,6 +298,7 @@ export class OpenSearchSiemStack extends Stack {
284298
s3LogBuckets: string[],
285299
siemVersion: string,
286300
enableTopicSubscription: boolean,
301+
enableLambdaInsights: boolean,
287302
s3NotificationTopicNameOrExistingArn: string,
288303
geoIpUploadBucket?: s3.Bucket,
289304
) {
@@ -294,9 +309,9 @@ export class OpenSearchSiemStack extends Stack {
294309
code: lambda.Code.fromAsset('lambdas/siem-processor/os-loader.zip'),
295310
role: lambdaRole,
296311
handler: 'index.lambda_handler',
297-
timeout: Duration.seconds(900),
312+
timeout: Duration.minutes(2),
298313
vpc,
299-
memorySize: 2048,
314+
memorySize: 512,
300315
vpcSubnets: {
301316
subnetFilters: [ec2.SubnetFilter.byIds(domainSubnetIds)],
302317
},
@@ -310,6 +325,7 @@ export class OpenSearchSiemStack extends Stack {
310325
GEOIP_BUCKET: geoIpUploadBucket?.bucketName || '',
311326
SIEM_VERSION: siemVersion,
312327
},
328+
insightsVersion: enableLambdaInsights ? lambda.LambdaInsightsVersion.VERSION_1_0_135_0 : undefined,
313329
});
314330

315331
for (const logBucket of s3LogBuckets) {

0 commit comments

Comments
 (0)