- Environment: AWS
- Supported inputs: CloudWatch (pull), SQS (pull)
- Supported Guardium versions:
- Guardium Data Protection: 11.4 and above
- Supported inputs:
- Cloudwatch logs (pull)
- SQS (pull)
- Supported inputs:
- Guardium Insights: 3.2
- Supported inputs:
- Cloudwatch logs (pull)
- SQS (pull)
- Supported inputs:
- Guardium Insights SaaS: 1.0
- Supported inputs:
- Cloudwatch logs (pull)
- SQS (pull)
- Supported inputs:
- Guardium Data Protection: 11.4 and above
This is a Logstash filter plug-in for the universal connector that is featured in IBM Security Guardium. It parses S3 database events into a Guardium record instance (which is a standard structure made out of several parts). The information is then sent over to Guardium. Guardium records include the accessor (the person who tried to access the data), the session, data, and exceptions. If there are no errors, the data contains details about the query "construct". The construct details the main action (verb) and collections (objects) involved.
The plug-in is free and open-source (Apache 2.0). It can be used as a starting point to develop additional filter plug-ins for Guardium universal connector.
- The filter supports events sent through Cloudwatch or SQS.
The full AWS documentation is in https://docs.aws.amazon.com/awscloudtrail/latest/userguide/send-cloudtrail-events-to-cloudwatch-logs.html
-
Go to https://console.aws.amazon.com/cloudtrail
a. Click Trails in the left menu
b. Click Create trail and enter the trail name
c. Fill in the details
- Enable the CloudWatch logs, select the target log group, and click Next
- Select both Management events and Data events
- Select S3 as the data event source and the buckets that you want to monitor and click Next (Here we switched to basic event selectors)
- In the
Summary
screen, validate that the data is accurate and click Create
- Log in to your IAM console (https://console.aws.amazon.com/iam/).
a. Create a role
- Select
AWS service
asTrusted entity
type andEC2
as ause case
. ClickNext
- Search
“CloudWatchLogsReadOnlyAccess“
inpolicy filter
and select it. ClickNext
- Enter
RoleName
- Click
Create Role
-
Search for the created role and open it.
-
In the
Permissions
tab, click theAdd Permissions
button and selectCreate Inline Policy
-
On the
Create Policy
page, select JSON editor and add the below policy.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "sts:AssumeRole",
"Resource": [
"arn:aws:iam::<AWS Account>:role/<Role Name>/*",
"arn:aws:iam::<AWS Account>:role/<Role Name>",
"arn:aws:sts::<AWS Account>:assumed-role/<Role Name>/*",
"arn:aws:sts::<AWS Account>:assumed-role/<Role Name>/<EC2 Instance Id>"
]
}
]
}
-
Click
Review Policy
-
Enter the policy name and click
Create Policy
-
On
Role
, click theTrust relationships
tab, clickEdit trust policy
-
Add the below statement in
trust policy
and clickUpdate Policy
:
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:sts::<AWS Account>:assumed-role/<Role Name>/<EC2 Instance Id>"
},
"Action": "sts:AssumeRole"
}
- Set the role to the ec2 machine hosting Guardium
a. Go to the ec2 machine hosting Guardium and modify the IAM role to the one you created
- VPC endpoint- In cases where Cloudwatch Logs is outside the VPC of the ec2 machine hosting Guardium, you can create a VPC endpoint that will establish a private connection between your VPC and CloudWatch Logs by following the instructions in: https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/cloudwatch-logs-and-interface-VPC.html In case arn role based authentication is used in input - in addition to connection to Cloudwatch, VPC connection to STS should also be established between ec2 machine and Cloudwatch accout
In order to pull the logs from SQS, we need to push the logs originating from S3 to SQS.
Procedure
- Go to https://console.aws.amazon.com/
- Click Services.
- Search for Amazon EventBridge and click on Rules.
- Click Create Rule.
- Enter the name for the rule.
- Enter the description for the rule.
- In the Rule Type select Rule with an Event Pattern.
- Keep the rest of the default settings.
- Click on Next.
- In Event Source select AWS Events or EventBridge Partner Events.
- Skip the Sample Event.
- Keep Default settings for Creation Method.
- In the Event Pattern Select Edit Pattern and enter the below pattern
}
"source": [
"aws.s3"
]
}
- Click on Next.
- In the Target1, select Target Types as AWS Service.
- Select the target as SQS Queue.
- Select the Queue.
- Click on Next.
- Add the Tags if required.
- Review the settings and click on Create Rule.
In order to achieve load balancing of audit logs between different collectors, the audit logs must be exported from Cloudwatch to SQS.
The SQS created in these steps will contain the messages to be filled up by the lambda function (created in next section) in the queue by reading the CloudWatch logs. The messages inside the SQS will contain content from CloudWatch logs.
Procedure
- Go to https://console.aws.amazon.com/
- Click Services
- Search for SQS and click on Simple Queue Services
- Click Create Queue.
- Select the type as Standard.
- Enter the name for the queue
- Keep the rest of the default settings
Perform the below steps for the IAM user who is accessing the SQS logs in Guardium:
Procedure
- Go to https://console.aws.amazon.com/
- Go to IAM service > Policies > Create Policy.
- Select service as SQS.
- Check the following checkboxes: ListQueues, DeleteMessage, DeleteMessageBatch, GetQueueAttributes, GetQueueUrl, ReceiveMessage, ChangeMessageVisibility, ChangeMessageVisibilityBatch.
- In the resources, specify the ARN of the queue created in the above step.
- Click Review policy and specify the policy name.
- Click Create policy.
- Assign the policy to the user
- Log in to the IAM console as an IAM user (https://console.aws.amazon.com/iam/).
- Go to Users on the console and select the relevant IAM user to whom you want to give permissions. Click the username.
- In the Permissions tab, click Add permissions.
- Click Attach existing policies directly.
- Search for the policy created and check the checkbox next to it.
- Click Next: Review
- Click Add permissions
The Lambda function will read the CloudWatch Logs and send the events into the SQS queue. Follow the steps below to configure the Lambda function.
Create the IAM role that will be used in the Lambda function setup. The AWS Lambda service will require permission to log events and write to the SQS created. Create the IAM Role Export-Redshift-CloudWatch-to-SQS-Lambda with "AmazonSQSFullAccess", "CloudWatchLogsFullAccess", and "CloudWatchEventsFullAccess" policies.
Procedure
- Go to https://console.aws.amazon.com/
- Go to IAM -> Roles
- Click Create Role
- Under use case select Lambda and click Next
- Search for AmazonSQSFullAccess and select it
- Search for CloudWatchLogsFullAccess and select it
- Search for CloudWatchEventsFullAccess and select it
- Set the Role Name: e.g., "Export-Redshift-CloudWatch-Logs-To-SQS" and click Create role.
Procedure
- Go to https://console.aws.amazon.com/
- Go to Services. Search for lambda function.
- Click Functions
- Click Create Function
- Keep Author for Scratch selected
- Set Function name e.g., Export-S3-CloudWatch-Logs-To-SQS
- Under Runtime, select Python 3.x
- Under Permissions, select Use an existing role and select the IAM role that you created in the previous step (Export-S3-CloudWatch-to-SQS-Lambda)
- Click Create function and navigate to Code view
- Add the function code from the file s3Lambda.py
- Click Configuration > Environment Variables
- Create 2 variables:
- Key = GROUP_NAME value = e.g., uc-s3-plugin-cloudwatch-group
- Key = QUEUE_NAME value = e.g., https://sqs.ap-south-1.amazonaws.com/1111111111/np-s3-sqs
- Save the function
- Click on the Deploy button
The Lambda will be called by a scheduler configured inside event rules in CloudWatch.
Procedure
- Go to the CloudWatch dashboard.
- Go to Events > Rules.
- Click Create Rule.
- Enter the name for the rule e.g., cloudwatchToSqs
- Under Rule Type, select Schedule.
- Define the schedule. In schedule pattern, select a schedule that runs at a regular rate, such as every 10 minutes.
- Enter the rate expression, meaning the rate at which the function should execute. This value must match the time specified in the lambda function code that calculates the time delta. (If the function code it is set to 2 minutes, set the rate to 2 minutes unless changed in the code). Click Next.
- Select Target1. Select the Target Type as AWS Service.
- Select Target as Lambda Function.
- Select the lambda function created in the above step. e.g., Export-S3-CloudWatch-to-SQS-Lambda.
- Add the tag if needed.
- Click Create Rule.
Before making any changes to the lambda function code, first disable the above rule. Deploy the change and then re-enable the rule.
To authorize outgoing traffic from Amazon Web Services (AWS) to Guardium, run these APIs:
grdapi add_domain_to_universal_connector_allowed_domains domain=amazonaws.com
grdapi add_domain_to_universal_connector_allowed_domains domain=amazon.com
- For Guardium Data Protection version 11.0p540 and/or 11.0p6505 and/or 12p15 download the cloudwatch_logs plug-in
-
Log in to Guardium
-
Go to
Configure Universal Connector
-
If the audit logs are to be fetched from Cloudwatch directly,
-
Click Upload File, If you have installed Guardium Data Protection version 11.0p540 and/or 11.0p6505 and/or 12p15, select the offline cloudwatch_logs plug-in. After it is uploaded, click OK.
-
Select Connector template as Amazon S3 using CloudWatch
-
Fill in the log group and the role_arn that were assigned to the ec2
-
-
Note :To configure SQS on AWS, follow the steps mentioned in the SQS input plug-in readme file.
If the audit logs are to be fetched from S3 directly,
-
If the audit logs are to be fetched from SQS LAMBDA,
- Use the details from the s3-over-sqs.conf file. Update the input section to add the details from the corresponding file's input part, omitting the keyword "input{" at the beginning and its corresponding "}" at the end. More details on how to configure the relevant input plugin can be found here.
- Use the details from the s3-over-sqs.conf file. Update the filter section to add the details from the corresponding file's filter part, omitting the keyword "filter{" at the beginning and its corresponding "}" at the end. More details on how to configure the relevant input plugin can be found here.
-
The "type" fields should match in the input and the filter configuration sections. This field should be unique for every individual connector added. This is no longer required starting v12p20 and v12.1.
-
Click Save. Guardium validates the new connector, and enables the universal connector if it was disabled. After it is validated, it appears in the Configure Universal Connector page.
To configure this plug-in for Guardium Insights, follow this guide.
For the input configuration step, refer to the CloudWatch_logs section.