Clean up resources

Clean up resources

⚠️ Warning: Make sure to delete resources in the correct order to avoid dependency errors. Resources with dependencies must be deleted after their dependent resources.

Delete Security Group

aws ec2 delete-security-group --group-id <SECURITY_GROUP_ID>

AWS CLI

Delete Subnet

aws ec2 delete-subnet --subnet-id <SUBNET_ID>

AWS CLI

Delete Route Table

aws ec2 delete-route-table --route-table-id <ROUTE_TABLE_ID>

AWS CLI

Detach Internet Gateway

💡 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 CLI

Delete Internet Gateway

aws ec2 delete-internet-gateway --internet-gateway-id <INTERNET_GATEWAY_ID>

AWS CLI

Delete VPC

ℹ️ Information: This should be the final step after all resources within the VPC have been deleted.

aws ec2 delete-vpc --vpc-id <VPC_ID>

AWS CLI

🔒 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.