Manage Access Audits¶
You can configure your AWS account to allow Privacera to access Amazon RDS PostgreSQL audit logs through Amazon CloudWatch Logs. This configuration enables Privacera to collect and process access audit events.
To enable access audits, complete the following tasks in your AWS account:
- Update the AWS RDS parameter group for the database
- Create an AWS SQS queue
- Specify an AWS Lambda function
- Create an IAM Policy for an IAM Role Attached to an EC2 Instance
Update the AWS RDS Parameter Group for the Database¶
To expose access audit logs, update the configuration for the data source.
Procedure¶
-
To create a role for audits, run the following SQL query with a user with administrative credentials for your data source:
SQL -
Create a new parameter group for your database and specify the following values:
- Parameter group family: Select a database from either the
aurora-postgresqlorpostgresfamilies. - Type: Select DB Parameter Group.
- Group name: Specify a group name for the parameter group.
- Description: Specify a description for the parameter group.
- Parameter group family: Select a database from either the
-
Edit the parameter group that you created in the previous step and set the following values:
pgaudit.log: Specifyall, overwriting any existing value.shared_preload_libraries: Specifypg_stat_statements,pgaudit.pgaudit.role: Specifyrds_pgaudit.
-
Associate the parameter group that you created with your database. Modify the configuration for the database instance and make the following changes:
- DB parameter group: Specify the parameter group you created in this procedure.
- PostgreSQL log: Ensure this option is set to enable logging to Amazon CloudWatch Logs.
-
When prompted, select Apply immediately to apply the changes immediately.
-
Restart the database instance.
Verification¶
To verify that your database instance logs are available, complete the following steps:
-
From the Amazon RDS console, view the database instance logs for your database instance from the RDS console.
-
From the CloudWatch console, complete the following steps:
- Navigate to Log management.
- Locate the
/aws/rds/log group that corresponds to your database instance. - Select the log group name to confirm that a log stream exists for the database instance.
- Select a log stream name to confirm that log messages are present.
Create an AWS SQS Queue¶
To create an SQS queue used by an AWS Lambda function that you will create later, complete the following steps.
- In the AWS console, create an Amazon SQS queue.
-
For Name, enter a name using the following format:
whereText Only <RDS_INSTANCE_NAME>is the name of your AWS RDS instance. -
After the queue is created, save the queue URL for later use.
Specify an AWS Lambda Function¶
To create an AWS Lambda function to interact with the SQS queue, complete the following steps. In addition to creating the function, you must create a new IAM policy and associate a new IAM role with the function. You need to know your AWS account ID and AWS region to complete this procedure.
Create IAM Policy for Lambda Function¶
-
From the IAM console, create a new IAM policy and input the following JSON:
Replace the following placeholders:<REGION>: Your AWS region<ACCOUNT_ID>: Your AWS account ID<LAMBDA_FUNCTION_NAME>: The name of the AWS Lambda function you will create (for example,privacera-postgres-instance1-audits)<SQS_QUEUE_NAME>: The name of the AWS SQS queue
-
Specify a name for the IAM policy, such as
privacera-postgres-audits-lambda-execution-policy, and then create the policy.
Create IAM Role for Lambda Function¶
-
From the IAM console, create a new IAM role and choose the Use case as Lambda.
-
Search for the IAM policy that you just created with a name that might be similar to
privacera-postgres-audits-lambda-execution-policyand select it. -
Specify a Role name, such as
privacera-postgres-audits-lambda-execution-role, and then create the role.
Create Lambda Function¶
- From the AWS Lambda console, create a new function and specify the following fields:
- Function name: Specify a name for the function, such as
privacera-postgres-instance1-audits. - Runtime: Select Node.js 24.x from the list.
- Permissions: Select Use an existing role and choose the role created earlier in this procedure, such as
privacera-postgres-audits-lambda-execution-role.
- Function name: Specify a name for the function, such as
Add CloudWatch Logs Trigger¶
- Add a trigger to the function you created in the previous step and select CloudWatch Logs from the list, and then specify the following values:
- Log group: Select the log group path for your Amazon RDS database instance, such as
/aws/rds/instance/database-1/postgresql. - Filter name: Specify
auditTrigger.
- Log group: Select the log group path for your Amazon RDS database instance, such as
Add Lambda Function Code¶
- In the Lambda source code editor, provide the following JavaScript code in the
index.mjsfile, which is open by default in the editor:
| JavaScript | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
Note on AWS SDK
The AWS SDK v3 (@aws-sdk/client-sqs) is used in this code. If your Lambda runtime doesn't include it, you may need to add it as a dependency. For Node.js 24.x runtime, you can add it via Lambda layers or include it in your deployment package.
Configure Lambda Environment Variables¶
- For the Lambda function, edit the environment variables and create the following environment variables:
REGION: Specify your AWS region.SQS_QUEUE_URL: Specify your AWS SQS queue URL.IGNORE_DATABASE: Name of database(s) whose audits you want to exclude (e.g.,privacera_db).IGNORE_USERS: Name of user(s) whose audits you want to exclude (e.g.,privacera).
Create an IAM Policy for an IAM Role Attached to an EC2 Instance¶
To enable Privacera to read messages from the AWS SQS queue, you need to create an IAM policy and attach it to the IAM role that is associated with the EC2 instance where Privacera is installed.
Procedure¶
-
From the IAM console, create a new IAM policy and input the following JSON:
where:<SQS_QUEUE_ARN>: Specifies the AWS SQS Queue ARN identifier for the SQS Queue you created earlier.
-
Specify a name for the IAM policy, such as
postgres-audits-sqs-read-policy, and create the policy. -
Attach the IAM policy to the IAM role that is attached to the AWS EC2 instance where you installed Privacera.
Configure Connector¶
-
SSH to the instance where Privacera Manager is installed.
-
Run the following command to open the
.ymlfile to be edited.If you have multiple connectors, then replace
instance1with the appropriate connector instance name.Bash -
Enable access audits by setting the following property:
-
Configure the AWS RDS PostgreSQL audit properties:
YAML Replace all placeholder values
Replace the following placeholders with your actual values:
<RDS_INSTANCE_NAME>: Your AWS RDS database instance name -
Once the properties are configured, run the following commands to update your Privacera Manager platform instance:
Step 1 - Setup which generates the helm charts. This step usually takes few minutes.
Step 2 - Apply the Privacera Manager helm charts. Step 3 - (Optional) Post-installation step which generates Plugin tar ball, updates Route 53 DNS and so on. This step is not required if you are updating only connector properties.
-
In PrivaceraCloud portal, navigate to Settings -> Applications.
-
On the Connected Applications screen, select PostgreSQL.
-
Click on the icon or the Account Name to modify the settings.
-
On the Edit Application screen, go to Access Management.
-
Under the BASIC tab:
- Enable access audits: Turn on this to fetch access audits for the connector.
- Audit source for postgres: Add value as
sqsfor AWS RDS PostgreSQL. - AWS sqs queue name: Enter your SQS queue name (privacera-postgres-
-audits`). - AWS region of sqs queue: Enter your AWS region (e.g.,
us-east-1).
-
Click SAVE to apply the changes.
- Prev topic: Advanced Configuration