15 March,2023 by Rambler
Question: When attempting the following aws cli statement I get an error message
aws rds restore-db-instance-from-db-snapshot \ --db-instance-identifier mypostgresRDS \ --db-snapshot-identifier myBACKUPcOPY \ --db-instance-class db.m6g.large \
An error occurred (InvalidSubnet) when calling the RestoreDBInstanceFromDBSnapshot operation: No default subnet detected in VPC. Please contact AWS Support to recreate default Subnets.
What options are available to fix?
Answer: The immediate reason is because the vpc is not marked as "default" . This command will supply details on the vpc and one of the filters is "Isdefault" . Here is an example of how to confirm if the vpc is marked as "default" if you execute :
aws ec2 describe-vpcs --query "Vpcs[*].[CidrBlock,IsDefault]"
{ "Vpcs": [ { "CidrBlock": "xx.xx.xxx.xx/xx", "IsDefault": false, } ] }
One option is to work with your Administrator to mark the VPC as default. If this is not possible - look for other sources to identify the db_subnet_group configurable item and the value associated with this variable.
The second option is to extract the db_subnet_group details from the snapshot or other sources such as the Terraform file or if available - extract the information from the current RDS that you're looking to replace.
The problem is if you use the describe-db-snapshots command, it won't return the db_subnet_group . Therefore you are not able to complete a workaround
aws rds describe-db-snapshots --db-snapshot-identifier myBACKUPcOPY
If the original RDS is available you can grab the db-subnet-group-name details from :
aws rds describe-db-instances --db-instance-identifier mypostgresqlinstance
What if you don't have access to the TF state file or the current RDS is unavailable? If you are backing up the RDS to the the AWS Backup Service then utilise this option is extract the metadata information .
For this step to be successfull you will need to ensure there is Point in Time - Continuous backup recovery point available , and then query the metadata
Step 1 :Identify the continuous backup which is stored in the Backup Vault and get the RecoveryPointARN
aws backup list-recovery-points-by-resource --resource-arn <replace_withe_RDS_resource_arn> --query "RecoveryPoints[?contains(RecoveryPointArn,'continuous')].[*]"
Step 2 : Get the metadata of the Recovery Point which will display the dbSubnetGroupName
aws backup get-recovery-point-restore-metadata --backup-vault-name <Replace_with_Backup_Vault_Name> --recovery-point-arn <replace_with_Recovery_Point_ARN> --query "RestoreMetadata"
This is only a preview. Your comment has not yet been posted.
As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.
Having trouble reading this image? View an alternate.
Posted by: |