⚠️ Warning: Make sure to delete resources in the correct order to avoid dependency errors. Resources with dependencies must be deleted after their dependent resources.
aws ec2 delete-security-group --group-id <SECURITY_GROUP_ID>
aws ec2 delete-subnet --subnet-id <SUBNET_ID>
aws ec2 delete-route-table --route-table-id <ROUTE_TABLE_ID>
💡 Pro Tip: You must detach the Internet Gateway from the VPC before you can delete it.
aws ec2 detach-internet-gateway --internet-gateway-id <INTERNET_GATEWAY_ID> --vpc-id <VPC_ID>
aws ec2 delete-internet-gateway --internet-gateway-id <INTERNET_GATEWAY_ID>
ℹ️ Information: This should be the final step after all resources within the VPC have been deleted.
aws ec2 delete-vpc --vpc-id <VPC_ID>
🔒 Security Note: To ensure complete cleanup and prevent unexpected charges, verify all resources have been successfully deleted by checking the AWS Management Console or using the CLI list commands.