Skip to content

Commit 2dfdbf8

Browse files
Document configurable token lifetime for Google Cloud OIDC accounts (#3237)
* Document token lifetime for Google Cloud OIDC authentication Covers the OpenID Connect authentication method on Google Cloud accounts, the configurable token lifetime (600-43200, default 3600), the GCP org-policy cap, and the project-variable override for generic OIDC accounts. * Fix markdownlint issues in Google Cloud docs
1 parent 0a6db5b commit 2dfdbf8

2 files changed

Lines changed: 45 additions & 13 deletions

File tree

src/pages/docs/infrastructure/accounts/google-cloud/index.md

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,42 @@
11
---
22
layout: src/layouts/Default.astro
33
pubDate: 2023-01-01
4-
modDate: 2023-01-01
4+
modDate: 2026-07-09
55
title: Google cloud accounts
66
description: Configure your infrastructure so Octopus can deploy infrastructure to GCP and run scripts against the gcloud CLI.
77
navOrder: 30
88
---
99

1010
:::div{.hint}
11-
Google Cloud Accounts were added in Octopus **2021.2**, Generic OpenId Connect Accounts were added in **2025.1**
11+
Google Cloud Accounts were added in Octopus **2021.2**, Generic OpenId Connect Accounts were added in **2025.1**, and the OpenID Connect authentication method for Google Cloud Accounts was added in **{RELEASE_VERSION}**
1212
:::
1313

14-
To deploy infrastructure to Google Cloud Platform, you can define a Google cloud or Generic OpenId Connect account in Octopus.
14+
To deploy infrastructure to Google Cloud Platform, you can define a Google Cloud account or a Generic OpenId Connect account in Octopus.
1515

16-
The Generic OpenId Connect Account generates a JWT that can be used for [OpenID Connect](/docs/infrastructure/accounts/openid-connect) authentication. The Google cloud account uses the JSON key file credentials that can be retrieved from the service account assigned to the instance that is executing the deployment.
16+
A Google Cloud account authenticates either with a JSON key file or with OpenID Connect, chosen via the account's authentication method. The OpenID Connect option and the Generic OpenId Connect account both generate a JWT that is used for [OpenID Connect](/docs/infrastructure/accounts/openid-connect) authentication against a Workload Identity Federation; the Google Cloud account's OpenID Connect option is the recommended choice for GCP as it exposes GCP-specific settings such as the token lifetime.
17+
18+
## Google Cloud OpenID Connect Account
19+
20+
Google Cloud steps can use OpenID Connect for authentication, configured on a **Google Cloud Account** by choosing the OpenID Connect authentication method. This is the recommended way to use OpenID Connect with Google Cloud.
21+
22+
1. Navigate to **Deploy ➜ Manage ➜ Accounts**, click **ADD ACCOUNT** and select **Google Cloud Account**.
23+
1. Add a memorable name for the account.
24+
1. Under **Authentication Method**, select **Use OpenID Connect**.
25+
1. Set the [Deployments and Runbooks](/docs/infrastructure/accounts/openid-connect#subject-key-parts) subject generator.
26+
1. Set an audience. This should match the audience set on the Workload Identity Federation. By default, this is `https://iam.googleapis.com/projects/{project-id}/locations/global/workloadIdentityPools/{pool-id}/providers/{provider-id}`.
27+
1. Optionally set the **Token Lifetime** (see [Token lifetime](#token-lifetime)).
28+
1. Click **SAVE**. To test the account, set it as the account on a gcloud script step.
29+
30+
### Token lifetime
31+
32+
**Token Lifetime** controls how long, in seconds, the federated Google Cloud access token is valid. Octopus passes it to gcloud as `--service-account-token-lifetime-seconds`. Valid values are **600 to 43200** seconds (10 minutes to 12 hours); the default is **3600** seconds (1 hour).
33+
34+
:::div{.hint}
35+
Google Cloud rejects lifetimes longer than 1 hour (3600 seconds) unless the organization policy constraint `iam.allowServiceAccountCredentialLifetimeExtension` lists the impersonated service account. Without that policy, values above 3600 will fail when gcloud requests the token.
36+
:::
1737

1838
## Generic OpenId Connect Account
39+
1940
Google Cloud steps can use a Generic OpenId Connect Account for authentication.
2041

2142
1. Navigate to **Deploy ➜ Manage ➜ Accounts**, click the **ADD ACCOUNT** and select **Generic Oidc Account**.
@@ -26,21 +47,24 @@ Google Cloud steps can use a Generic OpenId Connect Account for authentication.
2647

2748
See the [Google cloud documentation](https://cloud.google.com/iam/docs/workload-identity-federation-with-other-providers) for instructions on creating and configuring a Workload Identity Federation.
2849

29-
Behind the scenes Octopus calls the gcloud cli with the following command to authenticate:
50+
:::div{.hint}
51+
The Generic OpenId Connect Account does not have a token lifetime setting. When it is used with Google Cloud the token lifetime defaults to 3600 seconds. To override it, add a project variable named `<account-variable>.OpenIdConnect.TokenLifetimeSeconds` (where `<account-variable>` is the name of the account variable the step references) set to a value between 600 and 43200. If you need a first-class token lifetime setting, use the Google Cloud OpenID Connect Account instead.
52+
:::
53+
54+
Behind the scenes Octopus calls the gcloud cli with the following command to authenticate. For both OpenID Connect account types the `--service-account-token-lifetime-seconds` value comes from the account's **Token Lifetime** (or the project variable above for a Generic account), and defaults to 3600:
3055

3156
```bash
3257
gcloud iam workload-identity-pools create-cred-config \
3358
<audience> \
3459
--service-account=<impersonationEmails> \
35-
--service-account-token-lifetime-seconds=3600 \
60+
--service-account-token-lifetime-seconds=<token-lifetime> \
3661
--output-file=<jsonAuthFilePath> \
3762
--credential-source-file=<jwtFilePath> \
3863
--credential-source-type=text \
3964
--subject-token-type=urn:ietf:params:oauth:token-type:jwt \
4065
--app-id-uri=<serverUri>
4166
```
4267

43-
4468
:::div{.hint}
4569
The default audience format is `https://iam.googleapis.com/projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/POOL_ID/providers/PROVIDER_ID` while `workload-identity-pools create-cred-config` command expects the audience without `https://iam.googleapis.com`. In this scenario Octopus expects the full audience value to be set on the account including `https://iam.googleapis.com` but will trim the `https://iam.googleapis.com` when running the create-cred-config command.
4670
:::
@@ -56,7 +80,7 @@ Google Cloud steps can use a Google Cloud Account for authentication.
5680

5781
See the [Google cloud documentation](https://cloud.google.com/iam/docs/creating-managing-service-account-keys) for instructions to create a service account and download the key file.
5882

59-
5. Click the **SAVE AND TEST** to save the account and verify the credentials are valid.
83+
1. Click the **SAVE AND TEST** to save the account and verify the credentials are valid.
6084

6185
:::div{.hint}
6286
Google Cloud steps can also defer to the service account assigned to the instance/virtual machine that hosts the Octopus Tentacles for authentication. In this scenario there is no need to create a Google Cloud account in Octopus Deploy.
@@ -68,4 +92,4 @@ You can access your Google cloud account from within projects through a variable
6892

6993
## Learn more
7094

71-
- How to use the [Run gcloud in a Script](/docs/deployments/google-cloud/run-gcloud-script) step
95+
- How to use the [Run gcloud in a Script](/docs/deployments/google-cloud/run-gcloud-script) step

src/pages/docs/projects/variables/google-cloud-account-variables.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
layout: src/layouts/Default.astro
33
pubDate: 2023-01-01
4-
modDate: 2024-08-29
4+
modDate: 2026-07-09
55
title: Google Cloud account variables
66
icon: fa-brands fa-google
77
description: Create a Google Cloud account variable to use it in Google Cloud deployment steps
@@ -27,8 +27,11 @@ Select the Google Cloud account you want to access from the project to assign it
2727
The Google Cloud account variable also exposes the following properties that you can reference in a PowerShell script:
2828

2929
| Name and description |
30-
| -------------------- |
31-
| **`JsonKey`** <br/> The JSON Key for the Google cloud account|
30+
| -------------------- |
31+
| **`JsonKey`** <br/> The JSON Key for the Google Cloud account. <br/> Only set if **Use a Key File** is selected |
32+
| **`OpenIdConnect.Jwt`** <br/> The JWT identity token for the current task. <br/> Only set if **Use OpenID Connect** is selected |
33+
| **`Audience`** <br/> The Workload Identity Federation audience. <br/> Only set if **Use OpenID Connect** is selected |
34+
| **`OpenIdConnect.TokenLifetimeSeconds`** <br/> The lifetime, in seconds, of the federated Google Cloud access token (600–43200, default 3600), passed to gcloud as `--service-account-token-lifetime-seconds`. Set from the account's **Token Lifetime** when **Use OpenID Connect** is selected. A Generic OpenId Connect account has no Token Lifetime setting, so define this variable yourself to override the 3600 default. |
3235

3336
### Accessing the properties in a script
3437

@@ -44,14 +47,19 @@ Write-Host 'GoogleCloudAccount.JsonKey=' $OctopusParameters["google cloud accoun
4447
# Directly as a variable
4548
Write-Host 'GoogleCloudAccount.Id=' #{google cloud account}
4649
Write-Host 'GoogleCloudAccount.JsonKey=' #{google cloud account.JsonKey}
50+
51+
# For an account using OpenID Connect
52+
Write-Host 'GoogleCloudAccount.OpenIdConnect.Jwt=' #{google cloud account.OpenIdConnect.Jwt}
53+
Write-Host 'GoogleCloudAccount.OpenIdConnect.TokenLifetimeSeconds=' #{google cloud account.OpenIdConnect.TokenLifetimeSeconds}
4754
```
4855

4956
## Add a Google Cloud account to Octopus
5057

5158
For instructions to set up a Google Cloud account in Octopus, see [Google Cloud Accounts](/docs/infrastructure/accounts/google-cloud).
5259

5360
## Older versions
54-
* Google Cloud accounts are available from Octopus Deploy **2021.3** onwards.
61+
62+
- Google Cloud accounts are available from Octopus Deploy **2021.3** onwards.
5563

5664
## Learn more
5765

0 commit comments

Comments
 (0)