Skip to content
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.
/ pg-audit-lambda Public archive
forked from joer14/pg-audit-lambda

Deploy an AWS lambda function that backs up pg-audit log files to aws glacier automatically.

Notifications You must be signed in to change notification settings

agilemd/pg-audit-lambda

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lambda PG Audit

This repo allows one to deploy a cloud formation stack with a lambda function that will automatically backup pg_audit logs from an AWS rds instance. Every 24 hours the lambda will turn on, and download all logs that have been written to in the last 24 hours, except for the most recent log. It will then compress those files, and upload them as an archive to AWS glacier. It does not download the most recently modified log, because that log file is not complete (yet), and we don't want to download and upload duplicate data.

This repo also provides a helpful utility script for installing pg_audit on AWS RDS.

Required AWS Resources

Before deploying you must create the following resources:

  • AWS Glacier Vault (in the same region as the RDS instance)
  • AWS RDS Instance (Postgres or Aurora)
  • AWS S3 Bucket (for storing the packaged lambda)

Required environment variables

Variable Description
DB_INSTANCE_IDENTIFIER The RDS identifier for the database
DB_INSTANCE_ARN The ARN for the RDS instance
GLACIER_VAULT_NAME The name of the glacier vault in which to store the logs.
GLACIER_VAULT_ARN The ARN of the glacier vault in which to store the logs.
LAMBDA_BUCKET The name of the S3 bucket you created to be used to store the packaged lambda.

Reference

Installing PG Audit

Build and deploy

Run the following NPM command to build lambdas and CloudFormation template

$ npm run build

Run the following script to deploy the CloudFormation

$ npm run deploy

About

Deploy an AWS lambda function that backs up pg-audit log files to aws glacier automatically.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 42.6%
  • Python 37.1%
  • Shell 12.3%
  • EJS 8.0%