Setting up a GCP Service account
Published: 2023-03-30 06:33:50

<h2 id="heading-introduction">Introduction</h2>
<p>A service account in Google Cloud Platform (GCP) is a special type of account that allows applications running on GCP to interact with other GCP services, such as Google Cloud Storage, Google Cloud SQL, and Google Compute Engine.</p>
<p>Service accounts are typically used by applications that run on GCP, such as virtual machines, containers, and applications running on Google Kubernetes Engine. Using service accounts, applications can securely access GCP resources without requiring users to authenticate individually.</p>
<p>Each service account is associated with a set of credentials, which typically include a private key that can be used to authenticate the service account with other GCP services. Service accounts can also be granted specific permissions to access particular resources, making it easy to control access to GCP resources on a per-service basis.</p>
<p>In this blog post, I will guide you through the step-by-step process of creating a service account on the Google Cloud Platform (GCP). This account will be specifically created to be used for my future blog posts on GCP. By following this tutorial, you will be able to create a service account and obtain the necessary credentials to interact with other GCP services.</p>
<p>The instructions provided in this post will be concise and easy to follow, ensuring that you can complete the process quickly and efficiently. In case you need to create a service account in the future, you can refer back to this post for guidance. Let's get started!</p>
<h2 id="heading-creating-a-service-account">Creating a Service Account</h2>
<ol>
<li><p>Sign in to your google cloud console at <a target="_blank" href="https://console.cloud.google.com"><strong>https://console.cloud.google.com</strong></a>.</p>
</li>
<li><p>From the dropdown at the top, select the project you want your service account to be associated with.</p>
</li>
<li><p>From the navigation menu on the left-hand side, select "<strong>IAM &amp; Admin</strong>" and then select "<strong>Service accounts</strong>".</p>
</li>
<li><p>Click the "<strong>Create service account</strong>" button at the top of the page.</p>
</li>
<li><p>Enter a name for your service account and provide an optional description. Click "<strong>Create and Continue</strong>".</p>
</li>
<li><p>Under the "<strong>Grant this service account access to project</strong>", select the following roles to be assigned to the service account and click "<strong>Continue</strong>" (you can modify the roles as per your requirements):</p>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1678346726486/c723ec2f-f813-48bd-b54b-3154e4d14e24.png" alt class="image--center mx-auto" /></p>
<p> Click "<strong>Done</strong>".</p>
</li>
</ol>
<h2 id="heading-creating-a-service-account-key">Creating a Service Account Key</h2>
<ol>
<li><p>From the navigation menu on the left-hand side, select "<strong>IAM &amp; Admin</strong>" and then select "<strong>Service accounts</strong>".</p>
</li>
<li><p>Locate the service account that you created and click on its name.</p>
</li>
<li><p>Click on the "<strong>Keys</strong>" tab and then click "<strong>Add Key</strong>".</p>
</li>
<li><p>Click on the "<strong>Create new key</strong>" button, select "<strong>JSON</strong>" as the Key Type and click "<strong>Create</strong>".</p>
</li>
<li><p>This will download the JSON key file to your local machine.</p>
</li>
</ol>
<h2 id="heading-setting-up-the-environment-variable">Setting up the environment variable</h2>
<p>One last thing is to create an environment variable <code>GOOGLE_APPLICATION_CREDENTIALS</code> and point it to the path of the downloaded key file.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Now, you have a service account that can be used to interact with other GCP services and infrastructure management (through IaaC tools like Terraform etc.) as well.</p>
<p>To learn more about service accounts, you can go over the official documentation here: <a target="_blank" href="https://cloud.google.com/iam/docs/service-account-overview">https://cloud.google.com/iam/docs/service-account-overview</a></p>
<p>I hope you found this blog post helpful and informative. I'd love to hear your thoughts on the topic or any issues you've had following along. Did I miss anything important? Please leave a comment below and let me know what you think. Your feedback is valuable and can help me improve my writing and provide additional insights for other readers. Thank you for taking the time to read this post!</p>
<div class="hn-embed-widget" id="linkedin-follow"></div></br><p style="color:#757CF9;">This article is published w/ <a target="_blank" href="https://scattr.io?ref=dev">Scattr  ↗️</a></p>