Skip to content

Commit cecd167

Browse files
committed
Added global vme extension policy resource and tests.
1 parent 03e57f6 commit cecd167

5 files changed

Lines changed: 258 additions & 0 deletions

File tree

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
# Copyright 2026 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: 'GlobalVmExtensionPolicy'
16+
description: 'A Global VM Extension Policy.'
17+
base_url: 'projects/{{project}}/global/vmExtensionPolicies'
18+
self_link: 'projects/{{project}}/global/vmExtensionPolicies/{{name}}'
19+
update_verb: 'PATCH'
20+
update_mask: true
21+
custom_code:
22+
pre_update: 'templates/terraform/pre_update/vm_extension_policy_name.go.tmpl'
23+
test_check_destroy: 'templates/terraform/test_check_destroy/global_vm_extension_policy.go.tmpl'
24+
25+
samples:
26+
- name: 'compute_global_vm_extension_policy_basic'
27+
primary_resource_id: 'ops_agent_policy'
28+
steps:
29+
- name: 'compute_global_vm_extension_policy_basic'
30+
vars:
31+
policy_name: 'global-ops-agent-policy'
32+
ignore_read_extra:
33+
- 'rollout_operation'
34+
- name: 'compute_global_vm_extension_policy_update'
35+
vars:
36+
policy_name: 'global-ops-agent-policy'
37+
ignore_read_extra:
38+
- 'rollout_operation'
39+
40+
41+
autogen_async: true
42+
async:
43+
actions: ['create', 'delete', 'update']
44+
type: 'OpAsync'
45+
operation:
46+
base_url: 'projects/{{project}}/global/operations/{{op_id}}'
47+
48+
properties:
49+
- name: 'name'
50+
type: String
51+
required: true
52+
immutable: true
53+
description: |-
54+
Name of the resource. Provided by the client when the resource is created.
55+
- name: 'description'
56+
type: String
57+
description: 'An optional description of this resource.'
58+
- name: 'extensionPolicies'
59+
type: Map
60+
required: true
61+
description: |-
62+
Map from extension (eg: "cloudops") to its policy configuration.
63+
value_type:
64+
type: NestedObject
65+
properties:
66+
- name: 'pinnedVersion'
67+
type: String
68+
description: 'The version pinning for the extension.'
69+
- name: 'stringConfig'
70+
type: String
71+
description: 'String configuration payload.'
72+
key_name: 'extension_name'
73+
- name: 'instanceSelectors'
74+
type: Array
75+
description: 'Selector to target VMs for a policy.'
76+
item_type:
77+
type: NestedObject
78+
properties:
79+
- name: 'labelSelector'
80+
type: NestedObject
81+
description: 'LabelSelector matches VM labels.'
82+
properties:
83+
- name: 'inclusionLabels'
84+
type: KeyValuePairs
85+
description: 'Labels as key value pairs.'
86+
- name: 'priority'
87+
type: Integer
88+
default_from_api: true
89+
description: 'Used to resolve conflicts when multiple policies are active. Defaults to 0.'
90+
- name: 'rolloutOperation'
91+
type: NestedObject
92+
required: true
93+
description: 'Represents the rollout operation.'
94+
properties:
95+
- name: 'rolloutInput'
96+
type: NestedObject
97+
required: true
98+
description: 'Rollout input settings.'
99+
properties:
100+
- name: 'conflictBehavior'
101+
type: String
102+
description: 'Specifies the behavior of the rollout if a conflict is detected.'
103+
- name: 'name'
104+
type: String
105+
description: 'The name of the rollout plan.'
106+
- name: 'predefinedRolloutPlan'
107+
type: String
108+
description: 'Specifies the predefined rollout plan for the policy.'
109+
- name: 'retryUuid'
110+
type: String
111+
description: 'The UUID that identifies a policy rollout retry attempt.'
112+
- name: 'rolloutStatus'
113+
type: NestedObject
114+
description: 'Rollout status.'
115+
output: true
116+
properties:
117+
- name: 'currentRollouts'
118+
type: Array
119+
description: 'The current rollouts for the latest version of the resource.'
120+
output: true
121+
item_type:
122+
type: NestedObject
123+
output: true
124+
properties:
125+
- name: 'locationRolloutStatus'
126+
type: Map
127+
description: 'The rollout status for each location.'
128+
output: true
129+
value_type:
130+
type: NestedObject
131+
output: true
132+
properties:
133+
- name: 'state'
134+
type: String
135+
description: 'The state of the location rollout.'
136+
output: true
137+
key_name: 'location_name'
138+
- name: 'rollout'
139+
type: String
140+
description: 'The name of the rollout.'
141+
output: true
142+
- name: 'rolloutPlan'
143+
type: String
144+
description: 'The name of the rollout plan.'
145+
output: true
146+
- name: 'state'
147+
type: String
148+
description: 'The overall state of the rollout.'
149+
output: true
150+
- name: 'previousRollout'
151+
type: NestedObject
152+
description: 'Rollout status of the previous rollout.'
153+
output: true
154+
properties:
155+
- name: 'locationRolloutStatus'
156+
type: Map
157+
description: 'The rollout status for each location.'
158+
output: true
159+
value_type:
160+
type: NestedObject
161+
output: true
162+
properties:
163+
- name: 'state'
164+
type: String
165+
description: 'The state of the location rollout.'
166+
output: true
167+
key_name: 'location_name'
168+
- name: 'rollout'
169+
type: String
170+
description: 'The name of the rollout.'
171+
output: true
172+
- name: 'rolloutPlan'
173+
type: String
174+
description: 'The name of the rollout plan.'
175+
output: true
176+
- name: 'state'
177+
type: String
178+
description: 'The overall state of the rollout.'
179+
output: true
180+
- name: 'scopedResourceStatus'
181+
type: String
182+
description: 'The scoped resource status.'
183+
output: true
184+
- name: 'creationTimestamp'
185+
type: String
186+
description: 'Creation timestamp in RFC3339 text format.'
187+
output: true
188+
- name: 'id'
189+
type: String
190+
description: 'The unique identifier for the resource.'
191+
output: true
192+
- name: 'kind'
193+
type: String
194+
description: 'Type of the resource.'
195+
output: true
196+
- name: 'selfLink'
197+
type: String
198+
description: 'Server-defined fully-qualified URL for this resource.'
199+
output: true
200+
- name: 'updateTimestamp'
201+
type: String
202+
description: 'Update timestamp in RFC3339 text format.'
203+
output: true
204+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
obj["name"] = d.Get("name").(string)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
resource "google_compute_global_vm_extension_policy" "{{$.PrimaryResourceId}}" {
2+
name = "global-ops-agent-vme-policy-%{random_suffix}"
3+
description = "A basic global VM extension policy"
4+
priority = 10
5+
6+
extension_policies {
7+
extension_name = "ops-agent"
8+
pinned_version = "2.66.0"
9+
}
10+
11+
instance_selectors {
12+
label_selector {
13+
inclusion_labels = {
14+
env = "test"
15+
}
16+
}
17+
}
18+
19+
rollout_operation {
20+
rollout_input {
21+
predefined_rollout_plan = "FAST_ROLLOUT"
22+
}
23+
}
24+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
resource "google_compute_global_vm_extension_policy" "{{$.PrimaryResourceId}}" {
2+
name = "global-ops-agent-vme-policy-%{random_suffix}"
3+
description = "A basic global VM extension policy"
4+
priority = 20
5+
6+
extension_policies {
7+
extension_name = "ops-agent"
8+
pinned_version = "2.66.0"
9+
string_config = "logging:\n receivers:\n syslog:\n type: files\n include_paths:\n - /var/log/messages\n"
10+
}
11+
12+
instance_selectors {
13+
label_selector {
14+
inclusion_labels = {
15+
env = "test"
16+
}
17+
}
18+
}
19+
20+
rollout_operation {
21+
rollout_input {
22+
predefined_rollout_plan = "FAST_ROLLOUT"
23+
}
24+
}
25+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Skip destroy check to avoid eventual consistency issues of global rollouts.
2+
// The global VM extension policy deletion triggers a background purge rollout
3+
// that can take a few minutes to fully propagate across GCE zones.
4+
return nil

0 commit comments

Comments
 (0)