DynamodbOverCloudwatch-Guardium Logstash filter plug-in
1. Viewing the logs on CloudWatch
Procedure
- Click the Service drop down.
- On the
Recently visitedpanel, click CloudWatch. - On the left panel, click Log`.
- Click on Log groups under Logs.
- In the search box, enter the name of the log group that you created in the previous STEP 9.
- Click on the log group that appears in the search.
- All logs display under log streams in the format: <accountid>_CloudTrail
NOTE
In order to achieve load balancing of audit logs between different collectors, the audit logs must be exported from Cloudwatch to SQS. Follow step #2 to publish logs to SQS else move to step #3.
2. Exporting Cloudwatch Logs to SQS using lambda function
Creating the SQS queue
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
Creating a policy for the relevant IAM User
Perform the following 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
Creating the Lambda function
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.
Creating IAM Role
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-Dynamo-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-Dynamo-CloudWatch-to-SQS-Lambda" and click Create role.
Create the lambda function
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 a function name e.g., Export-Dynamo-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-Dynamo-CloudWatch-Logs-To-SQS).
- Click Create function and navigate to Code view.
- Add the function code from the file lambda.py.
- Click Configuration > Environment Variables.
- Create 2 variables:
Key = GROUP_NAME value = <value>e.g.,uc-dynamo-plugin-cloudwatch-groupKey = QUEUE_NAME value = <value>e.g.,https://sqs.ap-south-1.amazonaws.com/1111111111/np-dynamo-sqs
- Save the function.
- Click Deploy.
Automating the lambda function
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-Dynamo-CloudWatch-Logs-To-SQS.
- Add the tag if needed.
- Click Create Rule.
Note
- Before making any changes to the lambda function code, first disable the above rule. Deploy the change and then re-enable the rule.
- If the Management events are enabled while configuring the CloudTrail, it is possible
that the data being read by the Lambda Function would be large. In such cases the
timeoutparameter and thememoryparameters may have to be tuned properly. Below are the steps to take to configure those parameters,- Go to the created Lambda Function.
- Go to General Configurations.
- Click Edit.
- Update the value of Memory as required.
- Update the value of Timeout as required.
3. Configuring the Dynamodb filters in Guardium
The Guardium universal connector is the Guardium entry point for native audit logs. The universal connector identifies and parses received events, and then converts them to a standard Guardium format. The output of the universal connector is forwarded to the Guardium sniffer on the collector, for policy and auditing enforcements. Configure Guardium to read the native audit logs by customizing the dynamodb template.
Authorizing outgoing traffic from AWS to Guardium
Procedure
- Log in to the Guardium Collector's APIs.
- Issue the following commands:
grdapi add_domain_to_universal_connector_allowed_domains domain=amazonaws.com
grdapi add_domain_to_universal_connector_allowed_domains domain=amazon.com
Before you begin
• Configure the policies you require. See policies for more information.
• You must have permission for the S-Tap Management role. The admin user includes this role by default.
• DynamodbOverCloudwatch-Guardium Logstash filter plug-in is automatically available with Guardium Data Protection versions 12.x, 11.4 with appliance bundle 11.0p490 or later or Guardium Data Protection version 11.5 with appliance bundle 11.0p540 or later releases.
• For Guardium Data Protection version 11.0p540 and/or 11.0p6505 and/or 12.0 and/or 12p15 download the cloudwatch_logs plug-in
Note: For Guardium Data Protection version 11.4 without appliance bundle 11.0p490 or prior or Guardium Data Protection version 11.5 without appliance bundle 11.0p540 or prior,download the logstash-filter-dynamodb_guardium_plugin_filter.zip plug-in.
Procedure
- On the collector, go to Setup > Tools and Views > Configure Universal Connector.
- Enable the connector if it is already disabled, before proceeding to upload the UC.
- Click Upload File,
- Select logstash-filter-dynamodb_guardium_plugin_filter.zip plug-in. After it is uploaded, click OK. This is not necessary for Guardium Data Protection v11.0p490 or later, v11.0p540 or later, v12.0 or later.
- If you have installed Guardium Data Protection version 11.0p540 and/or 11.0p6505 and/or 12.0 and/or 12p15, select the offline cloudwatch_logs plug-in. After it is uploaded, click OK.
- Click the Plus sign to open the Connector Configuration dialog box.
- Type a name in the Connector name field.
- If the audit logs are to be fetched from CloudWatch, use the details from the dynamodbCloudwatch.conf file. If the audit logs are to be fetched from SQS, use the details from the dynamodb_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 plug-in can be found cloudwatch_logs and sqs
- If the audit logs are to be fetched from CloudWatch, use the details from the dynamodbCloudwatch.conf file. But if the audit logs are to be fetched from SQS, use the details from the dynamodbOverSqs.conf file. Update the filter section to add the details from the corresponding file's input part, omitting the keyword "filter{" at the beginning and its corresponding "}" at the end.
- The "type" fields should match in input and filter configuration sections. This field should be unique for every individual connector added.
- 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.
Configuring the dynamodb filters in Guardium Data Security Center
Depending on your environment, see the instructions for configuring the DynamoDB filters in one of the following locations,
- Guardium Data Security Center SaaS, follow this guide.
- Guardium Data Security Center on-premises, follow this guide.
In the input configuration section, refer to the CloudWatch_logs section.