Hello,
Need some help or guidance
sequence of events
Step1)
Provisioned aurora RDS cluster with below TF automation using the same workspace.
First module creates an aurora PostgreSQL instance
Second module creates a database accounts based on RDS endpoint as input from the first module.
main.tf
module "aurora-postgresql" {
source = "aurora-postgresql/aws"
version = "6.0.3"
/*Some input parameters*/
}
module "postgre-setup-db-accts" {
source = "postgresql-setup-db-accts/aws"
version = "1.1.5"
cluster_endpoint = module.aurora-postgresql.rg_write_cluster_endpoint_alias
/*Few others input parameters*/
} /* using cyrilgdn/postgresql provider */
In the end i will have a postgreSQL cluster with required DB accounts for application deployment.
Step2)
I must rebuild the RDS cluster due to an issue either from a backup snapshot or restore to a Point in time(PITR).
Step 3)
When I build a new cluster from the snapshot or PITR (any builds from Snapshot/PITR will builds a new cluster)
As database accounts already exist in the restored DB, my build is going to fail as the second module (postgre-setup-db-accts ) is trying to create the accounts again as part of deployment based on the current tf state file.
Tried refresh by running the below command with an assumption the state file will get updated with the current state of infrastructure but that is not working either.
terraform apply -refresh-only -var-file=input_vars.tfvars
How do we address these types of situations ?
Regards
rx