How can I move the DB Configuration and schema creation from Terraform into AWS Lambda, and then create a cloudwatch event which can invoke the Lambda to perform the operation.
This operation can be creating the connection, schema and then running some alembic scripts.
For example:
provider "postgresql" {
host = "127.0.0.1"
database = "${var.db1_name}"
username = "my_role"
password = "foobar"
sslmode = "disable"
}
resource "postgresql_schema" "my_schema1" {
name = "my_schema"
}
If my schema.tf file looks like this,
How can these moved to lambda.py and package them together as a zip? Any help is appreciated, thank you!