← Back to list

Automation Using Python on Google Cloud — IAM Service Accounts

In this real world-based project, I acted as a Cloud Specialist and used IAM services to create a Service Account. This service account…

Luis Fernando Padrão de Andrade, Esp., MBA, TOGAF® · 2026-01-27 20:21 · 5 claps · 2.8 min read
#thecloudbootcamp #python #iam-services #google-cloud-platform #sdk
Open on Medium ↗
Wiki topics: ☁️ · DevOps & Cloud

Automation Using Python on Google Cloud — IAM Service Accounts

Resources used

Resources used

In this real world-based project, I acted as a Cloud Specialist and used IAM services to create a Service Account. This service account allows communication via scripts within the architecture through Cloud SDK and Python Scripts.

Architecture Overview

Architecture Overview

First, I started by configuring my local Windows environment, where I updated Python. I uninstalled version 3.12.3 and installed the latest available version, 3.14.2. At this stage, there is a very important point to note: enabling the “Add to PATH” option. This ensures that the Python installer updates the PATH environment variable with the location of the Python interpreter and package manager.

By doing so, you will be able to work with Python from any directory in your environment using the command line (Command Prompt or PowerShell). Verify the installation by running the following commands:

  • where python (This command will show where the Python executable is located on your system)
  • python -V (This command will display the installed version of the Python language).

Checking Python installation (Windows Command)

Checking Python installation (Windows Command)

Next, I installed the Google Cloud SDK by downloading the Windows installer from the downloads section at https://cloud.google.com/sdk/docs/quickstart#windows. It is important to note that firewall and antivirus security policies may block the Google Cloud SDK installer during execution. In such cases, you may temporarily disable the firewall and antivirus software to proceed with the installation using the online installer.

If the issue persists, download the full SDK package (google-cloud-sdk.zip), extract it to a directory of your choice, and run install.bat to perform the installation locally.

Installing google-cloud-sdk (Windows Command)

Installing google-cloud-sdk (Windows Command)

This was the installation approach I adopted on my laptop.

This was the installation approach I adopted on my laptop.

After completing the Google Cloud SDK configuration, I created a service account named automation with the Storage Admin role, granting full access to bucket operations and their objects.

IAM Service Account (GCP Console)

IAM Service Account (GCP Console)

After that, I installed the Python libraries required to work with Google Cloud Storage services using the pip command in the Windows console.

pip install — upgrade google-cloud-storage

Next, I prepared a very simple program to create buckets using the SDK.

The source code is shown below:

from google.cloud import storage

# Instancia o cliente usando as credenciais padrão do gcloud
storage_client = storage.Client()

# Nome do novo bucket
bucket_name1 = "tcb-gcp-lfpadrao-01"  # Substitua por um nome único
bucket_name2 = "tcb-gcp-lfpadrao-02"  # Substitua por um nome único
bucket_name3 = "tcb-gcp-lfpadrao-03"  # Substitua por um nome único

# Cria o bucket
bucket1 = storage_client.create_bucket(bucket_name1)
bucket2 = storage_client.create_bucket(bucket_name2)
bucket3 = storage_client.create_bucket(bucket_name3)

# Listing Cloud Storage Buckets
buckets = list(storage_client.list_buckets())
print(*buckets, sep='\n')

A program that creates three buckets in my default GCP project and subsequently lists them, all performed via the Windows command line.

Execution Python Code (Windows Command)

Execution Python Code (Windows Command)

GCP Console view of the buckets created using the SDK.

GCP Console view of the buckets created using the SDK.

View of the buckets created via the SDK in the Asset Inventory.

View of the buckets created via the SDK in the Asset Inventory.


메타데이터
post_id
6e55ea85554b
slug
automation-using-python-on-google-cloud-iam-service-accounts-6e55ea85554b
url
https://medium.com/@lfpadrao/automation-using-python-on-google-cloud-iam-service-accounts-6e55ea85554b
canonical_url
https://medium.com/@lfpadrao/automation-using-python-on-google-cloud-iam-service-accounts-6e55ea85554b
author_url
https://medium.com/@lfpadrao
status
ok
fetched_at
2026-06-23 03:48:11