Where ${DB_IDENTIFIER_FROM}
is the RDS DB identifier for the database your are duplicating and ${DB_IDENTIFIER_TO}
will be the new database's identifier.
"sg-GROUP1"
"sg-GROUP2"
"sg-GROUP3"
should be modified to the security groups you want.
sleep
is unfortunately necessary as I've found it sometimes takes a bit for AWS to realize something is changing.
echo "[INFO] Spinning up new RDS from latest production snapshot"
aws rds restore-db-instance-to-point-in-time --source-db-instance-identifier ${DB_IDENTIFIER_FROM} --target-db-instance-identifier ${DB_IDENTIFIER_TO} --use-latest-restorable-time --db-subnet-group-name prodinado --multi-az --no-publicly-accessible --tags Key=workload-type,Value=other
echo "[INFO] Waiting RDS instance to spin up"
sleep 5; aws rds wait db-instance-available --db-instance-identifier ${DB_IDENTIFIER_TO}
echo "[INFO] Configuring the spun up RDS"
aws rds modify-db-instance --db-instance-identifier ${DB_IDENTIFIER_TO} --vpc-security-group-ids "sg-GROUP1" "sg-GROUP2" "sg-GROUP3" --apply-immediately --backup-retention-period 0
echo "[INFO] Waiting RDS instance configuration to finish"
sleep 5; aws rds wait db-instance-available --db-instance-identifier ${DB_IDENTIFIER_TO}