Skip to content

Commit 0df77ca

Browse files
committed
Add mode, inline cert iss & trust config to workload identity pool
1 parent 0c1f963 commit 0df77ca

File tree

10 files changed

+359
-11
lines changed

10 files changed

+359
-11
lines changed

mmv1/products/cloudrun/Service.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ iam_policy:
4545
parent_resource_attribute: 'service'
4646
base_url: 'v1/projects/{{project}}/locations/{{location}}/services/{{service}}'
4747
example_config_body: 'templates/terraform/iam/iam_attributes.go.tmpl'
48+
min_version: beta
4849
import_format:
4950
- 'projects/{{project}}/locations/{{location}}/services/{{service}}'
5051
- '{{service}}'

mmv1/products/iambeta/WorkloadIdentityPool.yaml

Lines changed: 177 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ description: |
1919
references:
2020
guides:
2121
'Managing workload identity pools': 'https://cloud.google.com/iam/docs/manage-workload-identity-pools-providers#pools'
22+
'Configure managed workload identity authentication for Compute Engine': 'https://cloud.google.com/iam/docs/create-managed-workload-identities'
23+
'Configure managed workload identity authentication for GKE': 'https://cloud.google.com/iam/docs/create-managed-workload-identities-gke'
2224
api: 'https://cloud.google.com/iam/docs/reference/rest/v1/projects.locations.workloadIdentityPools'
2325
docs:
2426
base_url: 'projects/{{project}}/locations/global/workloadIdentityPools'
@@ -40,19 +42,37 @@ async:
4042
base_url: '{{op_id}}'
4143
result:
4244
resource_inside_response: false
45+
iam_policy:
46+
parent_resource_attribute: 'workload_identity_pool_id'
47+
method_name_separator: ':'
48+
fetch_iam_policy_verb: 'POST'
49+
import_format:
50+
- 'projects/{{project}}/locations/global/workloadIdentityPools/{{workload_identity_pool_id}}'
51+
min_version: beta
4352
custom_code:
4453
constants: 'templates/terraform/constants/iam_workload_identity_pool.go.tmpl'
4554
decoder: 'templates/terraform/decoders/treat_deleted_state_as_gone.go.tmpl'
4655
test_check_destroy: 'templates/terraform/custom_check_destroy/iam_workload_identity_pool.go.tmpl'
4756
examples:
4857
- name: 'iam_workload_identity_pool_basic'
4958
primary_resource_id: 'example'
59+
primary_resource_name: 'fmt.Sprintf("tf-test-example-pool%s", context["random_suffix"])'
5060
vars:
5161
workload_identity_pool_id: 'example-pool'
52-
- name: 'iam_workload_identity_pool_full'
62+
- name: 'iam_workload_identity_pool_full_federation_only_mode'
5363
primary_resource_id: 'example'
64+
primary_resource_name: 'fmt.Sprintf("tf-test-example-pool%s", context["random_suffix"])'
5465
vars:
5566
workload_identity_pool_id: 'example-pool'
67+
min_version: beta
68+
external_providers:
69+
- "random"
70+
- name: 'iam_workload_identity_pool_full_trust_domain_mode'
71+
primary_resource_id: 'example'
72+
primary_resource_name: 'fmt.Sprintf("tf-test-example-pool%s", context["random_suffix"])'
73+
vars:
74+
workload_identity_pool_id: 'example-pool'
75+
min_version: beta
5676
parameters:
5777
properties:
5878
- name: 'workloadIdentityPoolId'
@@ -70,11 +90,11 @@ properties:
7090
type: Enum
7191
description: |
7292
The state of the pool.
73-
* STATE_UNSPECIFIED: State unspecified.
74-
* ACTIVE: The pool is active, and may be used in Google Cloud policies.
75-
* DELETED: The pool is soft-deleted. Soft-deleted pools are permanently deleted after
93+
* `STATE_UNSPECIFIED`: State unspecified.
94+
* `ACTIVE`: The pool is active, and may be used in Google Cloud policies.
95+
* `DELETED`: The pool is soft-deleted. Soft-deleted pools are permanently deleted after
7696
approximately 30 days. You can restore a soft-deleted pool using
77-
UndeleteWorkloadIdentityPool. You cannot reuse the ID of a soft-deleted pool until it is
97+
`UndeleteWorkloadIdentityPool`. You cannot reuse the ID of a soft-deleted pool until it is
7898
permanently deleted. While a pool is deleted, you cannot use it to exchange tokens, or
7999
use existing tokens to access resources. If the pool is undeleted, existing tokens grant
80100
access again.
@@ -101,3 +121,155 @@ properties:
101121
Whether the pool is disabled. You cannot use a disabled pool to exchange tokens, or use
102122
existing tokens to access resources. If the pool is re-enabled, existing tokens grant
103123
access again.
124+
- name: mode
125+
type: Enum
126+
description: |
127+
The mode for the pool is operating in.
128+
129+
130+
~> **Note** Altering this field requires a new `workload_identity_pool_id`. To automate
131+
`workload_identity_pool_id` changes, append a random string (numbers/lowercase letters) to the
132+
`workload_identity_pool_id` (see `FEDERATION_ONLY` mode example above).
133+
134+
* `MODE_UNSPECIFIED`: State unspecified. New pools should not use this mode. Pools with an
135+
unspecified mode will operate as if they are in `FEDERATION_ONLY` mode.
136+
* `FEDERATION_ONLY`: Pools can only be used for federating external workload identities into
137+
Google Cloud. Unless otherwise noted, no structure or format constraints are applied to
138+
workload identities in a `FEDERATION_ONLY` mode pool, and you may not create any resources
139+
within the pool besides providers.
140+
* `TRUST_DOMAIN`: Pools can be used to assign identities to either external workloads or those
141+
hosted on Google Cloud. All identities within a `TRUST_DOMAIN` mode pool must consist of a
142+
single namespace and individual workload identifier. The subject identifier for all identities
143+
must conform to the following import_format:
144+
145+
`ns/<namespace>/sa/<workload_identifier>`
146+
147+
`WorkloadIdentityPoolProvider`(`google.iam.v1.WorkloadIdentityPoolProvider`)s
148+
cannot be created within `TRUST_DOMAIN` mode pools.
149+
min_version: beta
150+
immutable: true
151+
enum_values:
152+
- 'MODE_UNSPECIFIED'
153+
- 'FEDERATION_ONLY'
154+
- 'TRUST_DOMAIN'
155+
- name: 'inlineCertificateIssuanceConfig'
156+
type: NestedObject
157+
description: |
158+
Represents configuration for generating mutual TLS (mTLS) certificates for the identities
159+
within this pool. Defines the Certificate Authority (CA) pool resources and configurations
160+
required for issuance and rotation of mTLS workload certificates.
161+
min_version: beta
162+
properties:
163+
- name: 'caPools'
164+
type: KeyValuePairs
165+
description: |
166+
A required mapping of a cloud region to the CA pool resource located in that region used
167+
for certificate issuance, adhering to these constraints:
168+
169+
* **Key format:** A supported cloud region name equivalent to the location identifier in
170+
the corresponding map entry's value.
171+
* **Value format:** A valid CA pool resource path format like:
172+
`projects/{project}/locations/{location}/caPools/{ca_pool}`
173+
* **Region Matching:** Workloads are ONLY issued certificates from CA pools within the
174+
same region. Also the CA pool region (in value) must match the workload's region (key).
175+
- name: 'lifetime'
176+
type: String
177+
description: |
178+
Lifetime of the workload certificates issued by the CA pool in seconds. Must be between
179+
`36000s` (10 hours) to `2592000s` (30 days), ends in the suffix "`s`" (indicating seconds)
180+
and is preceded by the number of seconds. If unspecified, this will be defaulted to
181+
`86400s` (24 hours).
182+
- name: 'rotationWindowPercentage'
183+
type: Integer
184+
description: |
185+
Rotation window percentage indicating when certificate rotation should be initiated based
186+
on remaining lifetime. Must be between 10 - 80. If unspecified, this will be defaulted to
187+
50.
188+
- name: 'keyAlgorithm'
189+
type: Enum
190+
description: |
191+
Key algorithm to use when generating the key pair. This key pair will be used to create
192+
the certificate. If unspecified, this will default to `ECDSA_P256`.
193+
194+
* `KEY_ALGORITHM_UNSPECIFIED`: Unspecified key algorithm. Defaults to `ECDSA_P256`.
195+
* `RSA_2048`: Specifies RSA with a 2048-bit modulus.
196+
* `RSA_3072`: Specifies RSA with a 3072-bit modulus.
197+
* `RSA_4096`: Specifies RSA with a 4096-bit modulus.
198+
* `ECDSA_P256`: Specifies ECDSA with curve P256.
199+
* `ECDSA_P384`: Specifies ECDSA with curve P384.
200+
enum_values:
201+
- 'KEY_ALGORITHM_UNSPECIFIED'
202+
- 'RSA_2048'
203+
- 'RSA_3072'
204+
- 'RSA_4096'
205+
- 'ECDSA_P256'
206+
- 'ECDSA_P384'
207+
- name: 'inlineTrustConfig'
208+
type: NestedObject
209+
description: |
210+
Represents config to add additional trusted trust domains. Defines configuration for extending
211+
trust to additional trust domains. By establishing trust with another domain, the current
212+
domain will recognize and accept certificates issued by entities within the trusted domains.
213+
Note that a trust domain automatically trusts itself, eliminating the need for explicit
214+
configuration.
215+
min_version: beta
216+
properties:
217+
- name: 'additionalTrustBundles'
218+
type: Map
219+
description: |
220+
Maps specific trust domains (e.g., "example.com") to their corresponding `TrustStore`
221+
objects, which contain the trusted root certificates for that domain. There can be a
222+
maximum of `10` trust domain entries in this map.
223+
224+
Note that a trust domain automatically trusts itself and don't need to be specified here.
225+
If however, this `WorkloadIdentityPool`'s trust domain contains any trust anchors in the
226+
`additional_trust_bundles` map, those trust anchors will be *appended to* the Trust Bundle
227+
automatically derived from your `InlineCertificateIssuanceConfig`'s `ca_pools`.
228+
key_name: trust_domain
229+
key_description: |
230+
The trusted trust domains (e.g., "example.com") to be extended trust to additional trust
231+
domains to.
232+
value_type:
233+
name: trustStore
234+
type: NestedObject
235+
description: |
236+
Trust store that contains trust anchors and optional intermediate CAs used in PKI to
237+
build trust chain and verify client's identity.
238+
properties:
239+
- name: 'trustAnchors'
240+
type: Array
241+
description: |
242+
List of Trust Anchors to be used while performing validation against a given
243+
`TrustStore`. The incoming end entity's certificate must be chained up to one of the
244+
trust anchors here.
245+
required: true
246+
item_type:
247+
type: NestedObject
248+
description: |
249+
Represents a root of trust.
250+
properties:
251+
- name: 'pemCertificate'
252+
type: String
253+
description: |
254+
PEM certificate of the PKI used for validation. Must only contain one ca
255+
certificate(either root or intermediate cert).
256+
required: true
257+
- name: 'intermediateCas'
258+
type: Array
259+
description: |
260+
Set of intermediate CA certificates used for building the trust chain to trust
261+
anchor.
262+
263+
264+
~> **Note** Intermediate CAs are only supported when configuring X.509 federation.
265+
item_type:
266+
type: NestedObject
267+
description: |
268+
Intermediate CA certificates used for building the trust chain to trust anchor.
269+
properties:
270+
- name: 'pemCertificate'
271+
type: String
272+
description: |
273+
PEM certificate of the PKI used for validation. Must only contain one ca
274+
certificate.
275+
required: true

mmv1/templates/terraform/examples/iam_workload_identity_pool_full.tf.tmpl

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
resource "random_string" "pool_id_suffix" {
2+
length = 2
3+
upper = false
4+
special = false
5+
}
6+
7+
resource "google_iam_workload_identity_pool" "{{$.PrimaryResourceId}}" {
8+
provider = google-beta
9+
10+
workload_identity_pool_id = "{{index $.Vars "workload_identity_pool_id"}}${random_string.pool_id_suffix.result}"
11+
display_name = "Name of the pool"
12+
description = "Identity pool operates in FEDERATION_ONLY mode"
13+
disabled = true
14+
mode = "FEDERATION_ONLY"
15+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
resource "google_iam_workload_identity_pool" "{{$.PrimaryResourceId}}" {
2+
provider = google-beta
3+
4+
workload_identity_pool_id = "{{index $.Vars "workload_identity_pool_id"}}"
5+
display_name = "Name of the pool"
6+
description = "Identity pool operates in TRUST_DOMAIN mode"
7+
disabled = true
8+
mode = "TRUST_DOMAIN"
9+
inline_certificate_issuance_config {
10+
ca_pools = {
11+
"us-central1" : "projects/project-bar/locations/us-central1/caPools/ca-pool-bar"
12+
"asia-east2" : "projects/project-foo/locations/asia-east2/caPools/ca-pool-foo"
13+
}
14+
lifetime = "86400s"
15+
rotation_window_percentage = 50
16+
key_algorithm = "ECDSA_P256"
17+
}
18+
inline_trust_config {
19+
additional_trust_bundles {
20+
trust_domain = "ca-pool-foo.global.project-foo.workload.id.goog"
21+
trust_anchors {
22+
pem_certificate = file("test-fixtures/trust_anchor_1.pem")
23+
}
24+
trust_anchors {
25+
pem_certificate = file("test-fixtures/trust_anchor_2.pem")
26+
}
27+
}
28+
additional_trust_bundles {
29+
trust_domain = "ca-pool-bar.global.project-bar.workload.id.goog"
30+
trust_anchors {
31+
pem_certificate = file("test-fixtures/trust_anchor_3.pem")
32+
}
33+
trust_anchors {
34+
pem_certificate = file("test-fixtures/trust_anchor_4.pem")
35+
}
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)