Accidentally removing default service account could just “happen” from time to time, and here’s how you can get it back.
Prerequisites
- GCP Service Account
- gcloud CLI
Solution
Step 1. Find the service account (SA) ID. Go to Logging → Logs Explorer and query for any DeleteServiceAccount event. Just keep in mind, the SA should not be deleted for more than 30 days though.
Step 2. Once you have the SA ID, run the following command from the CLI:
gcloud beta iam service-accounts undelete <SA_ID>
Conclusion
If you get stuck at some step, feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.