MSK Ops Client¶
MSK Ops Client is a utility that manages the transformation of events/messages from Amazon Managed Streaming for Apache Kafka (MSK) and sends them to the Ops Server.
Event driven flow¶
sequenceDiagram
participant AWS Managed Kafka
participant AWS Lambda
participant PrivaceraOpsServer
participant PrivaceraConnector
AWS Managed Kafka ->> AWS Lambda: Filter event by as per rules
AWS Lambda ->> PrivaceraOpsServer: Forward event after pre-processed
PrivaceraConnector ->> PrivaceraOpsServer: Pull event/task details
PrivaceraConnector ->> As per the event/task details: Sync resources/ Audit/ Permissions etc Overview¶
This document provides a comprehensive guide on configuring the MSK Ops Client with the Privacera Platform using Privacera Manager. It includes detailed steps for setting up the MSK Ops Client, creating and deploying a Lambda function, configuring a Kafka client.
Prerequisites¶
Before configuring the MSK Ops Client, ensure the following prerequisites are met:
- The Privacera Ops Server is enabled.
- On-Demand Sync is configured.
- An MSK Cluster is deployed.
- You have the necessary AWS permissions to deploy a Lambda function.
Setup¶
- SSH to the machine where Privacera Manager is installed.
- Edit the vars.ops-bridge.yaml file:
- Update the following properties in the vars.ops-bridge.yaml file:
Property Descriptions¶
| Property | Description | Default Value |
|---|---|---|
OPS_CONNECTOR_MSK_ENABLED | Enable MSK | false |
OPS_CONNECTOR_MSK_AWS_ACCOUNT_ID | AWS account ID where the resources will be deployed | N/A |
OPS_CONNECTOR_MSK_AWS_REGION | AWS region where the resources will be deployed | N/A |
OPS_CONNECTOR_MSK_VPC_ID | ID of the VPC in which to create the resources | N/A |
OPS_CONNECTOR_MSK_SUBNET_IDS | Comma-separated list of subnet IDs within the specified VPC | N/A |
OPS_CONNECTOR_MSK_SECURITY_GROUP_ID | Security group ID to associate with the resources | N/A |
OPS_CONNECTOR_MSK_CLUSTER_NAME | Name of the MSK cluster | N/A |
OPS_CONNECTOR_MSK_CLUSTER_UUID | UUID of the MSK cluster | N/A |
OPS_CONNECTOR_MSK_TOPIC_NAME | Name of the MSK topic | N/A |
OPS_CONNECTOR_MSK_CLOUDFORMATION_RESOURCE_PREFIX | Prefix for naming CloudFormation resources | privacera |
OPS_CONNECTOR_MSK_LOG_LEVEL | Log level for MSK Connector | INFO |
OPS_CONNECTOR_MSK_USE_MTLS_AUTH | Is mTLS authentication for MSK cluster | false |
OPS_CONNECTOR_MSK_MTLS_SECRET_ARN | ARN of the mTLS AWS secret | N/A |
OPS_CONNECTOR_MSK_LOG_ONLY_MODE | Log the messages only and skip the call to the Ops Server. Useful for debugging. | false |
OPS_CONNECTOR_MSK_LAMBDA_TIMEOUT | Lambda function timeout in seconds | 60 |
OPS_CONNECTOR_MSK_LAMBDA_MEMORY_SIZE | Memory in MB allocated to the Lambda function | 128 |
Lambda Sizing¶
The Lambda function defaults to a 60 second timeout and 128 MB of memory. The AWS default timeout of 3 seconds is too low, because each invocation normalizes a batch of records and then makes a synchronous call to the Ops Server.
Increase OPS_CONNECTOR_MSK_LAMBDA_TIMEOUT if you process large batches or see Task timed out errors in the Lambda logs. Increase OPS_CONNECTOR_MSK_LAMBDA_MEMORY_SIZE if you see out-of-memory errors; raising the memory also increases the CPU share the function receives.
Batching and Resource Type Controls¶
The following are CloudFormation template parameters rather than Privacera Manager variables. Set them by editing ops-msk-cloudformation-env.json in the generated output folder before deploying the stack.
| Parameter | Description | Default Value |
|---|---|---|
SplitBatchByResourceType | When true, resources are batched into separate requests per resource type, so a single request never mixes table with database or schema. A request that mixes resource types can cause the connector to perform a full resource sync instead of a scoped on-demand sync. The parameter value is matched without regard to letter case: true, 1, yes, and on all enable it, and any other value disables it. | false |
BatchSize | Number of resources per request sent to the Ops Server. -1 or 0 sends them all in a single request. | -1 |
ResourceType | Comma-separated resource types to process. Events of any other type are dropped and logged. | table,database,schema |
Tip
If on-demand sync requests appear to trigger a full resource sync in the connector, set SplitBatchByResourceType to true and redeploy the stack.
-
Execute the following commands to update your Privacera Manager platform instance:
a. Generate the helm charts.
b. Apply the helm charts.c. Generate Plugin tar ball, update Route 53 DNS, etc.Bash 5. After the update, the CloudFormation template files will be available at:Bash Bash
Creating Lambda Function using CloudFormation Template¶
Upgrading from a release earlier than 9.2.36.1
The Lambda handler is now v2.handler.lambda_handler. The earlier handler (mskHandler.lambda_handler) and its modules have been removed from the deployment package. If you previously edited ops-connector-msk.yml by hand or pinned the earlier handler, regenerate the template from Privacera Manager before deploying. A template that still references the earlier handler causes the function to fail to load.
-
Copy CloudFormation templates to ~/privacera/msk-connector:
Bash -
Deploy the Lambda function using the CloudFormation CLI:
Bash If you want to update te stack, use:
-
MSK Ops Connector Validation¶
Fields¶
This section describes the fields used in the request payload.
General Fields¶
appType: Specifies the application type. Here, it is set to"PS_CONNECTOR".type: Defines the type of operation. In this case, it is"RESOURCE_SYNC".source: Indicates the source of the event, which is"MSK".
Request Information (requestInfo)¶
Contains detailed information about the request.
requestor_id: The unique ID of the requestor initiating the sync request.requestor_create_time: The epoch timestamp (in milliseconds) when the request was created.
Resources (resources)¶
A list of resources to be synced.
type: The type of the resource. In this example, it is"table".-
values: Contains specific attributes of the resource.database: The name of the database.- Example:
"privacera"
- Example:
table: The name of the table.- Example:
"customer_data"
- Example:
Example JSON Representation¶
| JSON | |
|---|---|
Sending a Test Event to a Kafka Topic¶
This section explains how to send a test event to a Kafka topic using the Kafka console producer.
Prerequisites¶
Before proceeding, ensure you have the following:
- MSK Kafka installed and configured.
- Access to the Kafka cluster.
- The necessary permissions to publish messages.
Step 1: Configure the Kafka Client¶
Create a producer configuration file (client.properties):
| Properties | |
|---|---|
Step 2: Create a Console Producer¶
-
Export the Kafka bootstrap server:
Bash -
Run the Kafka console producer command:
Step 3: Send a Test Event¶
Enter the following JSON message into the console and press Enter to send it to the Kafka topic:
| JSON | |
|---|---|
Step 4 : Verification¶
a. Confirm the message is published to the Kafka topic.
b. The message is consumed by the Lambda function based on the configured batching behaviour.
c. The Lambda function processes the message and sends it to the Ops Server to initiate the sync in connector.
Example: If you have configured databricks_sql_analytics connector for on-demand sync, then you will see the icon on Privacera portal -> Resource Policies -> databricks_sql_analytics repository.
Notes
- Replace
<PLEASE_CHANGE>placeholders with actual values. - Ensure the Kafka broker address is correct.
- If using a secured Kafka cluster, update client.properties accordingly (e.g., SASL_SSL, authentication settings).
- Prev topic: Advance Configuration