This Terraform configuration allows running a set of SQL commands on a new AWS RDS database instance that's operating within an AWS VPC.
The commands are executed via AWS Lambda functions - the first (rds_creation) operates outside the VPC and connects to the AWS API to determine credential information for the new database (endpoint, port, username, database). It then sends these details via SNS to another function operating within the VPC (rds_setup), which connects to the PostgreSQL database and executes the SQL commands.
The initial notification comes via SNS from the RDS events (and there is the configuration within the Terraform file here to set up that subscription).
Please note:
- There are variables defined at the top of the Terraform file - everything else should be pretty self-contained (though you should definitely read through all of the code to ensure you understand it before using it).
- The internal Lambda function is expecting a PostgreSQL database. This will need changing if you're