title: do it automatically - apply changes in rds parameter group, reboot rds, and apply another change
body: <p>Our infrastructure as code is using terraform.</p>
  
  <p>I want to create a new postgreSQL database by terraform, with <code>pgaudit</code> log enabled. </p>
  
  <p>Following aws document <a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Appendix.PostgreSQL.CommonDBATasks.html#Appendix.PostgreSQL.CommonDBATasks.pgaudit" rel="nofollow noreferrer">Working with the pgaudit Extension</a></p>
  
  <p>It has extra steps to:</p>
  
  <ul>
  <li>Step 1 <code>CREATE ROLE rds_pgaudit</code></li>
  </ul>
  
  <p>so I need to wait the rds instance status is available first, then run a sql command to this new database (in vpc)</p>
  
  <p>But how to run this sql command in terraform?</p>
  
  <ul>
  <li>Step 2. Modify the parameter group</li>
  </ul>
  
  <p>I can do this via resource <code>aws_db_parameter_group</code>, set the variable <code>parameters</code></p>
  
  <ul>
  <li>Step 3. reboot the instance</li>
  </ul>
  
  <p>Mot sure how to do this with terraform, by provisioner <code>local-exec</code> or  <code>remote-exec</code>???</p>
  
  <ul>
  <li>Step 4 ~ 6 more sql commands</li>
  </ul>
  
  <p>Seems I need wait the database back to <code>available</code> status, then I can run the sql script. Then how to run?</p>
  
  <p>Any suggestions?</p>