Our infrastructure as code is using terraform.
I want to create a new postgreSQL database by terraform, with pgaudit
log enabled.
Following aws document Working with the pgaudit Extension
It has extra steps to:
- Step 1
CREATE ROLE rds_pgaudit
so I need to wait the rds instance status is available first, then run a sql command to this new database (in vpc)
But how to run this sql command in terraform?
- Step 2. Modify the parameter group
I can do this via resource aws_db_parameter_group
, set the variable parameters
- Step 3. reboot the instance
Mot sure how to do this with terraform, by provisioner local-exec
or remote-exec
???
- Step 4 ~ 6 more sql commands
Seems I need wait the database back to available
status, then I can run the sql script. Then how to run?
Any suggestions?