<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Azidin Shairi</title>
    <description>The latest articles on DEV Community by Azidin Shairi (@azidin).</description>
    <link>https://dev.to/azidin</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1179499%2F49ba9bd9-eb00-4e78-a626-77dc035974c0.png</url>
      <title>DEV Community: Azidin Shairi</title>
      <link>https://dev.to/azidin</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/azidin"/>
    <language>en</language>
    <item>
      <title>Zero Trust GKE Control Plane Access with DNS Endpoints</title>
      <dc:creator>Azidin Shairi</dc:creator>
      <pubDate>Tue, 10 Nov 2026 08:18:33 +0000</pubDate>
      <link>https://dev.to/gde/zero-trust-gke-control-plane-access-with-dns-endpoints-1fba</link>
      <guid>https://dev.to/gde/zero-trust-gke-control-plane-access-with-dns-endpoints-1fba</guid>
      <description>&lt;h2&gt;
  
  
  Secure Your GKE Control Plane: Migrating from IP-Based Authorized Networks to IAM-Based DNS Endpoint&amp;nbsp;Access
&lt;/h2&gt;

&lt;p&gt;The GKE DNS-based endpoint provides a cluster-unique FQDN (Fully Qualified Domain Name) for the Kubernetes control plane, allowing for simplified, IAM-based access control instead of relying on static IP-based authorized networks. This guide outlines the steps to enable this feature and transition your access methods.&lt;/p&gt;

&lt;p&gt;The DNS-Based Endpoint offers several advantages over the IP-Based Endpoint with Authorized Networks for accessing Google Cloud clusters. While IP-based access relies on source IP CIDR blocks and often requires bastion hosts or VPN for private clusters, the DNS-based approach uses Google Cloud IAM and is accessible from any network that can reach Google Cloud APIs. This provides a more flexible and dynamic access control model, integrated with IAM and VPC Service Controls for enhanced security, compared to the primarily network-layer security of IP-based endpoints.&lt;/p&gt;




&lt;p&gt;This guide walks through the steps to enable the DNS endpoint on an existing GKE cluster and migrate the access to it. We'll use a GKE cluster named &lt;code&gt;gke-test-cluster-1&lt;/code&gt;, deployed in the GCP Finland region, zone &lt;code&gt;europe-north1-a&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Enable the DNS-Based Endpoint
&lt;/h3&gt;

&lt;p&gt;You can enable the DNS-based endpoint on an existing GKE Standard or Autopilot cluster using the gcloud CLI.&lt;/p&gt;

&lt;p&gt;First, let's review the GKE Control Plane configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcloud container clusters describe gke-test-cluster-1 \
--zone europe-north1-a --format=&lt;span class="s2"&gt;"yaml(controlPlaneEndpointsConfig)"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output should look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;controlPlaneEndpointsConfig&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;dnsEndpointConfig&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;allowExternalTraffic&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
    &lt;span class="na"&gt;enableK8sCertsViaDns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
    &lt;span class="na"&gt;enableK8sTokensViaDns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
    &lt;span class="na"&gt;endpoint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gke-CLUSTER_ID-PROJECT.europe-north1-a.gke.goog&lt;/span&gt;
  &lt;span class="na"&gt;ipEndpointsConfig&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;authorizedNetworksConfig&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;cidrBlocks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;cidrBlock&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ALLOWED_IP_ADDR&lt;/span&gt;
        &lt;span class="na"&gt;displayName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;office-network&lt;/span&gt;
      &lt;span class="na"&gt;enabled&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
      &lt;span class="na"&gt;gcpPublicCidrsAccessEnabled&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="na"&gt;enablePublicEndpoint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="na"&gt;enabled&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="na"&gt;privateEndpoint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;PRV_IP_ADDR&lt;/span&gt;
    &lt;span class="na"&gt;publicEndpoint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;PUB_IP_ADDR&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the current GKE Control Plane configuration. The IP-based Endpoint is enabled for both Public and Private IPs and Authorized Network is also enabled allowing "office-network" IP addresses.&lt;br&gt;
The GKE DNS Endpoint FQDN follows this format:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;gke-CLUSTER_ID-PROJECT.europe-north1-a.gke.goog&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;However, it is currently disabled.&lt;/p&gt;

&lt;p&gt;So let's update the cluster to enable DNS-based access.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcloud container clusters update gke-test-cluster-1 \
--zone europe-north1-a --enable-dns-access
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It may take a few minutes for the GKE Control Plane to update with DNS Endpoint.&lt;br&gt;
Once the operation is completed, you can run &lt;code&gt;gcloud&lt;/code&gt; container clusters describe command again and should see &lt;code&gt;allowExternalTraffic&lt;/code&gt; is enabled for &lt;code&gt;dnsEndpointConfig&lt;/code&gt;&amp;nbsp;.&lt;/p&gt;

&lt;p&gt;Now, both IP-based and DNS-based endpoints are enabled. Both coexist at this point while we work on the next steps migrating the access from IP-based to DNS-based.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 2: Configure IAM Access
&lt;/h3&gt;

&lt;p&gt;Access to the DNS endpoint is controlled by IAM. The specific IAM permission required for DNS-based access is &lt;code&gt;container.clusters.connect&lt;/code&gt;&lt;br&gt;
The permission &lt;code&gt;container.clusters.connect&lt;/code&gt; is included in many predefined IAM roles such as "Kubernetes Engine Admin" and "Kubernetes Engine Developer". It's most likely your IAM user already has the permission through existing IAM roles, otherwise you were not able to update the GKE cluster in the previous step.&lt;/p&gt;

&lt;p&gt;For other users however, your fellow developers, CI/CD pipelines and such might use other IAM roles or custom roles. In this case you need to update those roles to include the IAM permission.&lt;/p&gt;

&lt;p&gt;As an example here if you need to add another GKE admin user, you can grant the IAM role as follow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcloud projects add-iam-policy-binding &lt;span class="nv"&gt;$PROJECT&lt;/span&gt; \
--member=&lt;span class="s2"&gt;"user:$GKE_ADMIN"&lt;/span&gt; --role=&lt;span class="s2"&gt;"roles/container.admin"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3: Test and Migrate Client Access
&lt;/h3&gt;

&lt;p&gt;Now that the GKE Control Plane DNS Endpoint is enabled and IAM roles are configured, it's time to update clients to use the FQDN.&lt;br&gt;
To make use of the DNS Endpoint in kubectl you need to refresh the kubeconfig file by fetching the new GKE cluster's credentials:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcloud container clusters get-credentials gke-test-cluster-1 \
--zone europe-north1-a --dns-endpoint
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Take note of the &lt;code&gt;--dns-endpoint&lt;/code&gt; parameter. This updates the kubeconfig and replaces the configuration for accessing your GKE Control Plane using FQDN instead of public IP address.&lt;br&gt;
You can view the kubeconfig configuration using command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="s"&gt;kubectl config view --minify&lt;/span&gt;
&lt;span class="na"&gt;Output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;clusters&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;cluster&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;server&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;https://gke-CLUSTER_ID-PROJECT.europe-north1-a.gke.goog&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gke_PROJECT_europe-north1-a_gke-test-cluster-1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, run your favourite &lt;code&gt;kubectl&lt;/code&gt; command as usual like &lt;code&gt;kubectl get namespaces&lt;/code&gt;. If the command executed successfully it means our setup now works correctly.&lt;/p&gt;

&lt;p&gt;Once you verified it's working, it's time to update all your CI/CD tools, pipelines to include &lt;code&gt;--dns-endpoint&lt;/code&gt; parameter when fetching GKE cluster credentials, and inform your fellow GKE admins and developers to refresh their GKE cluster credentials.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Disable IP-Based Authorized Networks
&lt;/h3&gt;

&lt;p&gt;After you have successfully migrated all clients to using DNS Endpoint you can safely remove the IP-based authorized network along with the IP-based Endpoint. This helps keep your GKE clusters configuration clean.&lt;/p&gt;

&lt;p&gt;There are 2 options here:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Disabling the Public IP Endpoint which removes the Public IP address from your GKE Control Plane.&lt;/li&gt;
&lt;li&gt;Disable IP-based Endpoint completely which removes both Public and Private IP Endpoint. If you still have some other dependency on the Private IP Endpoint, you can just remove the Public IP Endpoint which improves your Control Plane security by not exposing it directly to the public.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Please note that the DNS Endpoint also works from your VPC.&lt;br&gt;
Nonetheless to disable the Public IP Endpoint while keeping the Private IP Endpoint you can update the GKE cluster as follow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcloud container clusters update gke-test-cluster-1 \
--zone europe-north1-a --enable-private-endpoint
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To disable IP-based Endpoint completely you can disable both Public IP and Private IP Endpoints as follow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcloud container clusters update gke-test-cluster-1 \
--zone europe-north1-a --no-enable-ip-access
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your GKE Control Plane Endpoint config will look like this after the clean up.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;controlPlaneEndpointsConfig&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;dnsEndpointConfig&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;allowExternalTraffic&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="na"&gt;enableK8sCertsViaDns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
    &lt;span class="na"&gt;enableK8sTokensViaDns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
    &lt;span class="na"&gt;endpoint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gke-CLUSTER_ID-PROJECT.europe-north1-a.gke.goog&lt;/span&gt;
  &lt;span class="na"&gt;ipEndpointsConfig&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;enabled&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;With GKE Control Plane access now managed by IAM, you can use VPC Service Controls to add Context-Aware Access and further secure your GKE clusters.&lt;/p&gt;

</description>
      <category>googlecloud</category>
      <category>security</category>
      <category>kubernetes</category>
      <category>gke</category>
    </item>
    <item>
      <title>Zero Trust CI/CD: Keyless Bitbucket Deployment on Google Cloud</title>
      <dc:creator>Azidin Shairi</dc:creator>
      <pubDate>Thu, 29 Oct 2026 20:41:19 +0000</pubDate>
      <link>https://dev.to/gde/zero-trust-cicd-keyless-bitbucket-deployment-on-google-cloud-1ka1</link>
      <guid>https://dev.to/gde/zero-trust-cicd-keyless-bitbucket-deployment-on-google-cloud-1ka1</guid>
      <description>&lt;p&gt;Using static Service Account (SA) keys in CI/CD pipelines has long been a common method for authenticating to Google Cloud Platform (GCP). However, storing long-lived credentials inside external pipeline environment variables introduces severe security vulnerabilities and ongoing operational friction.&lt;/p&gt;

&lt;p&gt;Google Mandiant demonstrated in a threat intelligence blog post (&lt;a href="https://cloud.google.com/blog/topics/threat-intelligence/bitbucket-pipeline-leaking-secrets" rel="noopener noreferrer"&gt;Holes in Your Bitbucket: Why Your CI/CD Pipeline Is Leaking Secrets&lt;/a&gt;) that secret variables in Bitbucket pipelines can easily be extracted from environment variables during runtime. Moving away from static JSON keys toward Google Cloud Workload Identity Federation (WIF) provides a modern, keyless authentication mechanism that leverages OpenID Connect (OIDC) to exchange short-lived tokens, eliminating the risks associated with static credential management.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Service Account Keys Are a Bad Security&amp;nbsp;Practice
&lt;/h2&gt;

&lt;p&gt;While Atlassian Bitbucket documentation describes &lt;a href="https://support.atlassian.com/bitbucket-cloud/docs/deploy-to-google-cloud/" rel="noopener noreferrer"&gt;deployment to Google Cloud using Service Account keys&lt;/a&gt;, relying on traditional static JSON key files introduces two fundamental security and operational flaws:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;High Security Risk &amp;amp; Lack of Traceability&lt;/strong&gt;: Service account keys do not expire automatically and carry persistent security exposure. They lack strict origin traceability and can easily be copied, downloaded, or exfiltrated to execute commands anywhere outside Bitbucket without network restrictions or audit context. If a key is compromised, malicious actors gain unrestricted access until it is manually identified and revoked.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Management &amp;amp; Operational Overhead&lt;/strong&gt;: Even if key expiration limits are configured, security compliance mandates continuous key lifecycle management, including periodic rotation and distribution across multiple repositories and workspaces. This creates substantial administrative overhead for platform engineering teams and risks pipeline failures when keys expire or are revoked prematurely.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F85obpqnk0wzbaj0d3umj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F85obpqnk0wzbaj0d3umj.png" alt=" " width="800" height="308"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introducing Workload Identity Federation (WIF)
&lt;/h2&gt;

&lt;p&gt;Workload Identity Federation establishes direct federated trust between Atlassian Bitbucket, acting as the Identity Provider and Google Cloud using OpenID Connect (OIDC) over the OAuth 2.0 framework. While OAuth 2.0 handles authorization, deciding what resources can be accessed, OIDC adds authentication verifying identity.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F87yx6u0qwfo18idvbhak.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F87yx6u0qwfo18idvbhak.png" alt=" " width="799" height="251"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Key benefits of WIF include:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Short-Lived Token Exchange&lt;/strong&gt;: Bitbucket generates a temporary OIDC identity token for each pipeline step. Workload Identity Federation validates this token and exchanges it for a short-lived access token to Google Cloud, valid strictly for the duration of the job.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fine-Grained Scope Control&lt;/strong&gt;: Access permissions can be tightly scoped per Bitbucket workspace, project, repository, or down to a specific deployment environment pipeline (e.g., staging vs. production).&lt;/p&gt;




&lt;h2&gt;
  
  
  Migrating Bitbucket Pipelines from using Service Account Keys to Google Cloud Workload Identity Federation
&lt;/h2&gt;

&lt;p&gt;Before configuring Workload Identity Federation, gather your Bitbucket workspace OIDC configurations from your repository admin setting page.&lt;br&gt;
You will need the following details from Bitbucket Workspace&amp;nbsp;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Identity Provider URL: &lt;code&gt;https://api.bitbucket.org/2.0/workspaces/WORKSPACE_ID/pipelines-config/identity/oidc&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Audience: &lt;code&gt;ari:cloud:bitbucket::workspace/WORKSPACE_UUID&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Bitbucket issues an OIDC token claim payload during pipeline execution structured as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"sub"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"{REPOSITORY_UUID}:{stepUuid}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"aud"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ari:cloud:bitbucket::workspace/WORKSPACE_UUID"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"stepUuid"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"{xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"iss"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://api.bitbucket.org/2.0/workspaces/WORKSPACE_ID/pipelines-config/identity/oidc"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"repositoryUuid"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"{REPOSITORY_UUID}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"branchName"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"xxxxxxxxx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"exp"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"xxxxxxxxxx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"iat"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"xxxxxxxxxx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"pipelineUuid"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"{xxxxx-xxxxx-xxxx-xxxx-xxxxxxxxxxx}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"workspaceUuid"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"{WORKSPACE_UUID}"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Bitbucket OpenID Connect settings page looks like this: &lt;a href="https://bitbucket.org/WORKSPACE_ID/REPO_ID/admin/pipelines/openid-connect" rel="noopener noreferrer"&gt;https://bitbucket.org/WORKSPACE_ID/REPO_ID/admin/pipelines/openid-connect&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5cupz4qrhp5bf4rr3b5y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5cupz4qrhp5bf4rr3b5y.png" alt=" " width="800" height="909"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Enable and Set Up WIF in Target GCP&amp;nbsp;Projects
&lt;/h3&gt;

&lt;p&gt;To establish federated authentication between Bitbucket Pipelines and GCP, create a Workload Identity Pool and Provider in your target GCP project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.1 Create a Workload Identity Pool&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Create a global Workload Identity Pool dedicated to Bitbucket:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcloud iam workload-identity-pools create bitbucket &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--location&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"global"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Bitbucket Workload Identity Pool"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--display-name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Bitbucket"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;1.2 Create the Workload Identity Provider&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Configure an OIDC provider that trusts Bitbucket's issuer URL and maps claims (such as workspace UUID, repository UUID, and deployment environment) to Google attributes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcloud iam workload-identity-pools providers create-oidc bitbucket &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--location&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"global"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--display-name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Bitbucket"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Bitbucket Identity Provider"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--workload-identity-pool&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"bitbucket"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--issuer-uri&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"https://api.bitbucket.org/2.0/workspaces/WORKSPACE_ID/pipelines-config/identity/oidc"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--allowed-audiences&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"ari:cloud:bitbucket::workspace/WORKSPACE_UUID"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--attribute-mapping&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"google.subject=assertion.sub,attribute.workspace_uuid=assertion.workspaceUuid,attribute.repository_uuid=assertion.repositoryUuid,attribute.deployment_env_uuid=assertion.deploymentEnvironmentUuid"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fz1dixcpl2kqvw4bql638.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fz1dixcpl2kqvw4bql638.png" alt=" " width="800" height="764"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.3 Map Bitbucket Identity to the GCP Service Account&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Grant your Bitbucket Workspace permission to impersonate the target GCP existing Service Account by binding the &lt;code&gt;roles/iam.workloadIdentityUser&lt;/code&gt; role:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcloud iam service-accounts add-iam-policy-binding bitbucket-pipelines@PROJECT_ID.iam.gserviceaccount.com &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--role&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;roles/iam.workloadIdentityUser &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--member&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"principalSet://iam.googleapis.com/projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/bitbucket/attribute.workspace_uuid/{WORKSPACE_UUID}"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fonw7goktt9l94ddpywfs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fonw7goktt9l94ddpywfs.png" alt=" " width="800" height="303"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Update Bitbucket Pipelines to Use OIDC Authentication
&lt;/h3&gt;

&lt;p&gt;Once Workload Identity Federation and the Identity Pool are configured, update your &lt;code&gt;bitbucket-pipelines.yml&lt;/code&gt; configuration.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Legacy Pipeline Configuration (Using Static SA Keys):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;pipelines&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;default&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;step&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deployment Step&lt;/span&gt;
        &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;gcloud auth activate-service-account --key-file &amp;lt;(echo "${GCLOUD_DEPLOYER_KEYFILE}" | base64 --decode --ignore-garbage)&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;gcloud config set project $GCLOUD_PROJECT&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To migrate your pipeline to OIDC authentication, first update each pipeline step requiring Google Cloud access by enabling &lt;code&gt;oidc: true&lt;/code&gt;. This allows Bitbucket to generate an OIDC token during execution, which you then export from the &lt;code&gt;$BITBUCKET_STEP_OIDC_TOKEN&lt;/code&gt; environment variable to a temporary file for gcloud usage.&lt;/p&gt;

&lt;p&gt;Next, update your authentication commands by switching&lt;br&gt;
from &lt;code&gt;gcloud auth activate-service-account --key-file=file.json&lt;/code&gt;&lt;br&gt;
to &lt;code&gt;gcloud auth login --cred-file=file.json&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Finally, update your workspace variables to replace the legacy key variable (&lt;code&gt;GCLOUD_DEPLOYER_KEYFILE&lt;/code&gt;) with a reference pointing to your credential configuration file (&lt;code&gt;GCLOUD_DEPLOYER_CREDFILE&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Migrated Pipeline Configuration (Using Keyless WIF via OIDC):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;pipelines&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;default&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;step&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deployment Step with OIDC&lt;/span&gt;
        &lt;span class="na"&gt;oidc&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
        &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo $BITBUCKET_STEP_OIDC_TOKEN &amp;gt; /tmp/bitbucket-step-oidc-token.txt&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;gcloud auth login --cred-file &amp;lt;(echo "$GCLOUD_DEPLOYER_CREDFILE")&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;gcloud config set project $GCLOUD_PROJECT&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3: Remove Bitbucket Workspace Level GCP SA&amp;nbsp;Keys
&lt;/h3&gt;

&lt;p&gt;After validating that the updated pipeline runs and authenticates successfully using Workload Identity Federation, navigate to your Bitbucket Workspace or Repository Settings to permanently delete the legacy Service Account key variables, such as &lt;code&gt;GCLOUD_DEPLOYER_KEYFILE&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Finally, navigate to the Google Cloud Console or run &lt;code&gt;gcloud iam service-accounts keys delete&lt;/code&gt; to revoke and delete the corresponding static Service Account JSON keys from GCP.&lt;/p&gt;




&lt;h2&gt;
  
  
  Summary &amp;amp; Best Practices
&lt;/h2&gt;

&lt;p&gt;Migrating from static Service Account keys to Workload Identity Federation aligns your CI/CD workflows with Zero Trust security principles. By enforcing keyless authentication with short-lived OIDC tokens, you eliminate secret leakage risks, remove rotation management overhead, and gain fine-grained control over your Google Cloud deployments.&lt;/p&gt;

&lt;p&gt;To maximize your security posture during and after migration:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Apply Least Privilege&lt;/strong&gt;: Restrict IAM role permissions on target GCP Service Accounts to only the explicit roles required for deployment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Leverage Fine-Grained Attribute Mappings&lt;/strong&gt;: Use WIF attribute conditions to strictly isolate non-production environments from production infrastructure based on repository UUIDs, branch names, or deployment environments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Audit Organization Workflows&lt;/strong&gt;: Review active pipelines across your repositories to ensure all legacy gcloud auth activate-service-account commands and static key variables are fully removed.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Reference links:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://cloud.google.com/blog/topics/threat-intelligence/bitbucket-pipeline-leaking-secrets" rel="noopener noreferrer"&gt;Google Mandiant: Bitbucket Pipeline Leaking Secrets&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cloud.google.com/iam/docs/workload-identity-federation" rel="noopener noreferrer"&gt;Managing Workload Identity Federation in GCP&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://support.atlassian.com/bitbucket-cloud/docs/integrate-pipelines-with-resource-servers-using-oidc/" rel="noopener noreferrer"&gt;Atlassian Support: Integrate Bitbucket Pipelines with Resource Servers Using OIDC&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devops</category>
      <category>cicd</category>
      <category>security</category>
      <category>googlecloud</category>
    </item>
  </channel>
</rss>
