Reputation: 95
I'm using vRO (vRealize Orchestrator) running SSH commands in order to destroy an AWS RDS instance and its linked option group, parameter group and subnet group.
These are the commands i'd like to run (destroy rds intance first, then subnet-group, then parameter-group and finally option-group) :
$ aws rds delete-db-instance --db-instance-identifier <instance_identifier> --skip-final-snapshot --profile <account_id>
$ aws rds delete-db-subnet-group --db-subnet-group-name <sg_identifier> --profile <account_id>
$ aws rds delete-db-parameter-group --db-parameter-group-name <pg_identifier> --profile <account_id>
$ aws rds delete-option-group --option-group-name <og_identifier> --profile <account_id>
Is there a way to destroy all those resources in one time in cascade ? I don't want to set a 20min timer to destroy RDS instance and then 10min timer to destroy subnet-group, etc.
Upvotes: 1
Views: 1863
Reputation: 9412
You can use the wait
command to ensure that your instance is deleted before moving on to the next step - https://docs.aws.amazon.com/cli/latest/reference/rds/wait/index.html
$ aws rds delete-db-instance --db-instance-identifier <instance_identifier> --skip-final-snapshot --profile <account_id>
$ aws rds wait db-instance-deleted --db-instance-identifier <instance_identifier>
$ aws rds delete-db-subnet-group --db-subnet-group-name <sg_identifier> --profile <account_id>
$ aws rds delete-db-parameter-group --db-parameter-group-name <pg_identifier> --profile <account_id>
$ aws rds delete-option-group --option-group-name <og_identifier> --profile <account_id>
wait
is available for creating/deleting db instances, and for snapshot operations. For your other actions (subnet group/parameter group/option group stuff), you shouldn't need to wait in between commands.
Upvotes: 2