Skip to content

Commit 3bc1ac3

Browse files
authored
Adds SaaS Runtime Unit resource provider (#15339)
1 parent 09851e9 commit 3bc1ac3

File tree

3 files changed

+464
-0
lines changed

3 files changed

+464
-0
lines changed
Lines changed: 299 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,299 @@
1+
# Copyright 2025 Google Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
---
15+
name: Unit
16+
description: A Unit is the fundamental structural building block of a SaaS offering. Each Unit is an instance of a UnitKind. It is a versioned, manageable component of a service that has its own lifecycle, representing elements like infrastructure, workloads, or an entire application stack that a service producer intends to manage as a single entity.
17+
base_url: projects/{{project}}/locations/{{location}}/units
18+
update_mask: true
19+
self_link: projects/{{project}}/locations/{{location}}/units/{{unit_id}}
20+
create_url: projects/{{project}}/locations/{{location}}/units?unitId={{unit_id}}
21+
update_verb: PATCH
22+
id_format: projects/{{project}}/locations/{{location}}/units/{{unit_id}}
23+
import_format:
24+
- projects/{{project}}/locations/{{location}}/units/{{unit_id}}
25+
examples:
26+
- name: saas_runtime_unit_basic
27+
primary_resource_id: "example"
28+
min_version: "beta"
29+
vars:
30+
saas_name: example-saas
31+
unitkind_name: example-unitkind
32+
unit_name: example-unit
33+
test_env_vars:
34+
project: "PROJECT_NAME"
35+
bootstrap_iam:
36+
- member: "serviceAccount:service-{project_number}@gcp-sa-saasservicemgmt.iam.gserviceaccount.com"
37+
role: "roles/saasservicemgmt.serviceAgent"
38+
autogen_async: false
39+
autogen_status: VW5pdA==
40+
parameters:
41+
- name: location
42+
type: String
43+
description: Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122.
44+
immutable: true
45+
url_param_only: true
46+
required: true
47+
- name: unitId
48+
type: String
49+
description: The ID value for the new unit.
50+
immutable: true
51+
url_param_only: true
52+
required: true
53+
properties:
54+
- name: annotations
55+
type: KeyValueAnnotations
56+
description: |-
57+
Annotations is an unstructured key-value map stored with a resource that
58+
may be set by external tools to store and retrieve arbitrary metadata.
59+
They are not queryable and should be preserved when modifying objects.
60+
61+
More info: https://kubernetes.io/docs/user-guide/annotations
62+
- name: conditions
63+
type: Array
64+
description: |-
65+
A set of conditions which indicate the various conditions this resource can
66+
have.
67+
output: true
68+
item_type:
69+
type: NestedObject
70+
properties:
71+
- name: lastTransitionTime
72+
type: String
73+
description: Last time the condition transited from one status to another.
74+
required: true
75+
- name: message
76+
type: String
77+
description: Human readable message indicating details about the last transition.
78+
required: true
79+
- name: reason
80+
type: String
81+
description: Brief reason for the condition's last transition.
82+
required: true
83+
- name: status
84+
type: String
85+
description: |-
86+
Status of the condition.
87+
Possible values:
88+
STATUS_UNKNOWN
89+
STATUS_TRUE
90+
STATUS_FALSE
91+
required: true
92+
- name: type
93+
type: String
94+
description: |-
95+
Type of the condition.
96+
Possible values:
97+
TYPE_READY
98+
TYPE_UPDATING
99+
TYPE_PROVISIONED
100+
TYPE_OPERATION_ERROR
101+
required: true
102+
- name: createTime
103+
type: String
104+
description: The timestamp when the resource was created.
105+
output: true
106+
- name: dependencies
107+
type: Array
108+
description: Set of dependencies for this unit. Maximum 10.
109+
output: true
110+
item_type:
111+
type: NestedObject
112+
properties:
113+
- name: alias
114+
type: String
115+
description: Alias for the name of the dependency.
116+
output: true
117+
- name: unit
118+
type: String
119+
description: A reference to the Unit object.
120+
output: true
121+
- name: dependents
122+
type: Array
123+
description: |-
124+
List of Units that depend on this unit. Unit can only be deprovisioned if
125+
this list is empty. Maximum 1000.
126+
output: true
127+
item_type:
128+
type: NestedObject
129+
properties:
130+
- name: alias
131+
type: String
132+
description: Alias for the name of the dependency.
133+
output: true
134+
- name: unit
135+
type: String
136+
description: A reference to the Unit object.
137+
output: true
138+
- name: inputVariables
139+
type: Array
140+
description: Indicates the current input variables deployed by the unit
141+
output: true
142+
item_type:
143+
type: NestedObject
144+
properties:
145+
- name: type
146+
type: String
147+
description: |-
148+
Name of a supported variable type. Supported types are string, int, bool.
149+
Possible values:
150+
STRING
151+
INT
152+
BOOL
153+
immutable: true
154+
- name: value
155+
type: String
156+
description: String encoded value for the variable.
157+
- name: variable
158+
type: String
159+
description: Name of the variable from actuation configs.
160+
immutable: true
161+
required: true
162+
- name: labels
163+
type: KeyValueLabels
164+
description: |-
165+
The labels on the resource, which can be used for categorization.
166+
similar to Kubernetes resource labels.
167+
- name: maintenance
168+
type: NestedObject
169+
description: |-
170+
Captures requested directives for performing future maintenance on the
171+
unit. This includes a request for the unit to skip maintenance for a period
172+
of time and remain pinned to its current release as well as controls for
173+
postponing maintenance scheduled in future.
174+
properties:
175+
- name: pinnedUntilTime
176+
type: String
177+
description: |-
178+
If present, it fixes the release on the unit until the given time; i.e.
179+
changes to the release field will be rejected. Rollouts should and will
180+
also respect this by not requesting an upgrade in the first place.
181+
- name: managementMode
182+
type: String
183+
description: |-
184+
Indicates whether the Unit life cycle is controlled
185+
by the user or by the system.
186+
Immutable once created.
187+
Possible values:
188+
MANAGEMENT_MODE_USER
189+
MANAGEMENT_MODE_SYSTEM
190+
immutable: true
191+
- name: name
192+
type: String
193+
description: |-
194+
Identifier. The resource name (full URI of the resource) following the standard naming
195+
scheme:
196+
197+
"projects/{project}/locations/{location}/units/{unit}"
198+
output: true
199+
- name: ongoingOperations
200+
type: Array
201+
description: List of concurrent UnitOperations that are operating on this Unit.
202+
output: true
203+
item_type:
204+
type: String
205+
- name: outputVariables
206+
type: Array
207+
description: |-
208+
Set of key/value pairs corresponding to output variables from execution of
209+
actuation templates. The variables are declared in actuation configs (e.g
210+
in helm chart or terraform) and the values are fetched and returned by the
211+
actuation engine upon completion of execution.
212+
output: true
213+
item_type:
214+
type: NestedObject
215+
properties:
216+
- name: type
217+
type: String
218+
description: |-
219+
Name of a supported variable type. Supported types are string, int, bool.
220+
Possible values:
221+
STRING
222+
INT
223+
BOOL
224+
immutable: true
225+
- name: value
226+
type: String
227+
description: String encoded value for the variable.
228+
- name: variable
229+
type: String
230+
description: Name of the variable from actuation configs.
231+
immutable: true
232+
required: true
233+
- name: pendingOperations
234+
type: Array
235+
description: List of pending (wait to be executed) UnitOperations for this unit.
236+
output: true
237+
item_type:
238+
type: String
239+
- name: release
240+
type: String
241+
description: The current Release object for this Unit.
242+
output: true
243+
- name: scheduledOperations
244+
type: Array
245+
description: List of scheduled UnitOperations for this unit.
246+
output: true
247+
item_type:
248+
type: String
249+
- name: state
250+
type: String
251+
description: |-
252+
Current lifecycle state of the resource (e.g. if it's being
253+
created or ready to use).
254+
Possible values:
255+
UNIT_STATE_NOT_PROVISIONED
256+
UNIT_STATE_PROVISIONING
257+
UNIT_STATE_UPDATING
258+
UNIT_STATE_DEPROVISIONING
259+
UNIT_STATE_READY
260+
UNIT_STATE_ERROR
261+
output: true
262+
- name: systemCleanupAt
263+
type: String
264+
description: If set, indicates the time when the system will start removing the unit.
265+
output: true
266+
- name: systemManagedState
267+
type: String
268+
description: |-
269+
Indicates the system managed state of the unit.
270+
Possible values:
271+
SYSTEM_MANAGED_STATE_ACTIVE
272+
SYSTEM_MANAGED_STATE_INACTIVE
273+
SYSTEM_MANAGED_STATE_DECOMMISSIONED
274+
output: true
275+
- name: tenant
276+
type: String
277+
description: |-
278+
Reference to the Saas Tenant resource this unit belongs to. This for
279+
example informs the maintenance policies to use for scheduling future
280+
updates on a unit. (optional and immutable once created)
281+
- name: uid
282+
type: String
283+
description: |-
284+
The unique identifier of the resource. UID is unique in the time
285+
and space for this resource within the scope of the service. It is
286+
typically generated by the server on successful creation of a resource
287+
and must not be changed. UID is used to uniquely identify resources
288+
with resource name reuses. This should be a UUID4.
289+
output: true
290+
- name: unitKind
291+
type: String
292+
description: Reference to the UnitKind this Unit belongs to. Immutable once set.
293+
- name: updateTime
294+
type: String
295+
description: |-
296+
The timestamp when the resource was last updated. Any
297+
change to the resource made by users must refresh this value.
298+
Changes to a resource made by the service should refresh this value.
299+
output: true
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
resource "google_saas_runtime_saas" "example_saas_regional" {
2+
provider = google-beta
3+
saas_id = "{{index $.Vars "saas_name"}}"
4+
location = "us-central1"
5+
6+
locations {
7+
name = "us-central1"
8+
}
9+
}
10+
11+
resource "google_saas_runtime_unit_kind" "example_unit_kind" {
12+
provider = google-beta
13+
location = "us-central1"
14+
unit_kind_id = "{{index $.Vars "unitkind_name"}}"
15+
saas = google_saas_runtime_saas.example_saas_regional.id
16+
}
17+
18+
resource "google_saas_runtime_unit" "{{$.PrimaryResourceId}}" {
19+
provider = google-beta
20+
location = "us-central1"
21+
unit_id = "{{index $.Vars "unit_name"}}"
22+
unit_kind = google_saas_runtime_unit_kind.example_unit_kind.id
23+
management_mode = "MANAGEMENT_MODE_USER"
24+
}

0 commit comments

Comments
 (0)