mmv1/products/compute/ResourcePolicy.yaml (434 lines of code) (raw):
# Copyright 2024 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
name: 'ResourcePolicy'
kind: 'compute#resourcePolicy'
description: |
A policy that can be attached to a resource to specify or schedule actions on that resource.
references:
guides:
api: 'https://cloud.google.com/compute/docs/reference/rest/v1/resourcePolicies'
docs:
base_url: 'projects/{{project}}/regions/{{region}}/resourcePolicies'
has_self_link: true
update_url: 'projects/{{project}}/regions/{{region}}/resourcePolicies/{{name}}'
update_verb: 'PATCH'
timeouts:
insert_minutes: 20
update_minutes: 20
delete_minutes: 20
async:
actions: ['create', 'delete', 'update']
type: 'OpAsync'
operation:
base_url: '{{op_id}}'
result:
resource_inside_response: false
collection_url_key: 'items'
custom_code:
constants: 'templates/terraform/constants/compute_resource_policy.go.tmpl'
sweeper:
url_substitutions:
- region: "us-central1"
- region: "europe-west1"
- region: "us-east4"
- region: "europe-west9"
examples:
- name: 'resource_policy_basic'
primary_resource_id: 'foo'
vars:
name: 'gce-policy'
- name: 'resource_policy_hourly_format'
primary_resource_id: 'foo'
vars:
name: 'gce-policy'
exclude_docs: true
- name: 'resource_policy_full'
primary_resource_id: 'bar'
vars:
name: 'gce-policy'
- name: 'resource_policy_placement_policy'
primary_resource_id: 'baz'
vars:
name: 'gce-policy'
- name: 'resource_policy_placement_policy_max_distance'
primary_resource_id: 'baz'
min_version: 'beta'
vars:
name: 'gce-policy'
- name: 'resource_policy_instance_schedule_policy'
primary_resource_id: 'hourly'
vars:
name: 'gce-policy'
- name: 'resource_policy_snapshot_schedule_chain_name'
primary_resource_id: 'hourly'
vars:
name: 'gce-policy'
- name: 'resource_policy_consistency_group'
primary_resource_id: 'cgroup'
vars:
name: 'gce-policy'
- name: 'resource_policy_workload_policy'
primary_resource_id: 'bar'
min_version: 'beta'
vars:
name: 'gce-policy'
- name: 'resource_policy_workload_policy_accelerator_topology'
primary_resource_id: 'bar'
min_version: 'beta'
vars:
name: 'gce-policy'
- name: 'resource_policy_workload_policy_max_topology_distance'
primary_resource_id: 'bar'
min_version: 'beta'
vars:
name: 'gce-policy'
- name: 'resource_policy_placement_policy_gpu_topology'
primary_resource_id: 'baz'
min_version: 'beta'
vars:
name: 'gce-policy'
- name: 'resource_policy_placement_policy_tpu_topology'
primary_resource_id: 'baz'
min_version: 'beta'
vars:
name: 'gce-policy'
parameters:
- name: 'region'
type: ResourceRef
description: Region where resource policy resides.
required: false
immutable: true
ignore_read: true
default_from_api: true
custom_expand: 'templates/terraform/custom_expand/resourceref_with_validation.go.tmpl'
resource: 'Region'
imports: 'name'
properties:
- name: 'name'
type: String
description: |
The name of the resource, provided by the client when initially creating
the resource. The resource name must be 1-63 characters long, and comply
with RFC1035. Specifically, the name must be 1-63 characters long and
match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])`? which means the
first character must be a lowercase letter, and all following characters
must be a dash, lowercase letter, or digit, except the last character,
which cannot be a dash.
required: true
- name: 'description'
type: String
description: |
An optional description of this resource. Provide this property when you create the resource.
- name: 'snapshotSchedulePolicy'
type: NestedObject
description: |
Policy for creating snapshots of persistent disks.
conflicts:
- group_placement_policy
- instance_schedule_policy
- disk_consistency_group_policy
properties:
- name: 'schedule'
type: NestedObject
description: |
Contains one of an `hourlySchedule`, `dailySchedule`, or `weeklySchedule`.
required: true
properties:
- name: 'hourlySchedule'
type: NestedObject
description: |
The policy will execute every nth hour starting at the specified time.
exactly_one_of:
- 'snapshot_schedule_policy.0.schedule.0.hourly_schedule'
- 'snapshot_schedule_policy.0.schedule.0.daily_schedule'
- 'snapshot_schedule_policy.0.schedule.0.weekly_schedule'
properties:
- name: 'hoursInCycle'
type: Integer
description: |
The number of hours between snapshots.
required: true
- name: 'startTime'
type: String
description: |
Time within the window to start the operations.
It must be in an hourly format "HH:MM",
where HH : [00-23] and MM : [00] GMT. eg: 21:00
required: true
diff_suppress_func: 'HourlyFormatSuppressDiff'
validation:
function: 'verify.ValidateHourlyOnly'
- name: 'dailySchedule'
type: NestedObject
description: |
The policy will execute every nth day at the specified time.
exactly_one_of:
- 'snapshot_schedule_policy.0.schedule.0.hourly_schedule'
- 'snapshot_schedule_policy.0.schedule.0.daily_schedule'
- 'snapshot_schedule_policy.0.schedule.0.weekly_schedule'
properties:
- name: 'daysInCycle'
type: Integer
description: |
Defines a schedule with units measured in days. The value determines how many days pass between the start of each cycle. Days in cycle for snapshot schedule policy must be 1.
required: true
- name: 'startTime'
type: String
description: |
This must be in UTC format that resolves to one of
00:00, 04:00, 08:00, 12:00, 16:00, or 20:00. For example,
both 13:00-5 and 08:00 are valid.
required: true
diff_suppress_func: 'HourlyFormatSuppressDiff'
validation:
function: 'verify.ValidateHourlyOnly'
- name: 'weeklySchedule'
type: NestedObject
description: |
Allows specifying a snapshot time for each day of the week.
exactly_one_of:
- 'snapshot_schedule_policy.0.schedule.0.hourly_schedule'
- 'snapshot_schedule_policy.0.schedule.0.daily_schedule'
- 'snapshot_schedule_policy.0.schedule.0.weekly_schedule'
properties:
- name: 'dayOfWeeks'
type: Array
description: |
May contain up to seven (one for each day of the week) snapshot times.
is_set: true
required: true
item_type:
type: NestedObject
properties:
- name: 'startTime'
type: String
description: |
Time within the window to start the operations.
It must be in format "HH:MM", where HH : [00-23] and MM : [00-00] GMT.
required: true
- name: 'day'
type: Enum
description: |
The day of the week to create the snapshot. e.g. MONDAY
required: true
enum_values:
- 'MONDAY'
- 'TUESDAY'
- 'WEDNESDAY'
- 'THURSDAY'
- 'FRIDAY'
- 'SATURDAY'
- 'SUNDAY'
min_size: 1
max_size: 7
- name: 'retentionPolicy'
type: NestedObject
description: |
Retention policy applied to snapshots created by this resource policy.
properties:
- name: 'maxRetentionDays'
type: Integer
description: |
Maximum age of the snapshot that is allowed to be kept.
required: true
- name: 'onSourceDiskDelete'
type: Enum
description: |
Specifies the behavior to apply to scheduled snapshots when
the source disk is deleted.
default_value: "KEEP_AUTO_SNAPSHOTS"
enum_values:
- 'KEEP_AUTO_SNAPSHOTS'
- 'APPLY_RETENTION_POLICY'
- name: 'snapshotProperties'
type: NestedObject
description: |
Properties with which the snapshots are created, such as labels.
properties:
- name: 'labels'
type: KeyValuePairs
description: |
A set of key-value pairs.
at_least_one_of:
- 'snapshot_schedule_policy.0.snapshot_properties.0.labels'
- 'snapshot_schedule_policy.0.snapshot_properties.0.storage_locations'
- 'snapshot_schedule_policy.0.snapshot_properties.0.guest_flush'
- name: 'storageLocations'
type: Array
description: |
Cloud Storage bucket location to store the auto snapshot
(regional or multi-regional)
is_set: true
at_least_one_of:
- 'snapshot_schedule_policy.0.snapshot_properties.0.labels'
- 'snapshot_schedule_policy.0.snapshot_properties.0.storage_locations'
- 'snapshot_schedule_policy.0.snapshot_properties.0.guest_flush'
item_type:
type: String
max_size: 1
- name: 'guestFlush'
type: Boolean
description: |
Whether to perform a 'guest aware' snapshot.
send_empty_value: false
at_least_one_of:
- 'snapshot_schedule_policy.0.snapshot_properties.0.labels'
- 'snapshot_schedule_policy.0.snapshot_properties.0.storage_locations'
- 'snapshot_schedule_policy.0.snapshot_properties.0.guest_flush'
- name: 'chainName'
type: String
description: |
Creates the new snapshot in the snapshot chain labeled with the
specified name. The chain name must be 1-63 characters long and comply
with RFC1035.
- name: 'groupPlacementPolicy'
type: NestedObject
description: |
Resource policy for instances used for placement configuration.
conflicts:
- instance_schedule_policy
- snapshot_schedule_policy
- disk_consistency_group_policy
properties:
- name: 'vmCount'
type: Integer
description: |
Number of VMs in this placement group. Google does not recommend that you use this field
unless you use a compact policy and you want your policy to work only if it contains this
exact number of VMs.
- name: 'availabilityDomainCount'
type: Integer
description: |
The number of availability domains instances will be spread across. If two instances are in different
availability domain, they will not be put in the same low latency network
- name: 'collocation'
type: Enum
description: |
Collocation specifies whether to place VMs inside the same availability domain on the same low-latency network.
Specify `COLLOCATED` to enable collocation. Can only be specified with `vm_count`. If compute instances are created
with a COLLOCATED policy, then exactly `vm_count` instances must be created at the same time with the resource policy
attached.
enum_values:
- 'COLLOCATED'
- name: 'maxDistance'
type: Integer
description: |
Specifies the number of max logical switches.
conflicts:
- group_placement_policy.0.gpu_topology
min_version: 'beta'
- name: 'gpuTopology'
type: String
description: |
Specifies the shape of the GPU slice, in slice based GPU families eg. A4X.
conflicts:
- group_placement_policy.0.max_distance
immutable: true
min_version: 'beta'
- name: 'tpuTopology'
type: String
description: |
Specifies the shape of the TPU slice.
immutable: true
min_version: 'beta'
- name: 'instanceSchedulePolicy'
type: NestedObject
description: |
Resource policy for scheduling instance operations.
conflicts:
- snapshot_schedule_policy
- group_placement_policy
- disk_consistency_group_policy
properties:
- name: 'vmStartSchedule'
type: NestedObject
description: |
Specifies the schedule for starting instances.
at_least_one_of:
- 'instance_schedule_policy.0.vm_start_schedule'
- 'instance_schedule_policy.0.vm_stop_schedule'
properties:
- name: 'schedule'
type: String
description: |
Specifies the frequency for the operation, using the unix-cron format.
required: true
- name: 'vmStopSchedule'
type: NestedObject
description: |
Specifies the schedule for stopping instances.
at_least_one_of:
- 'instance_schedule_policy.0.vm_start_schedule'
- 'instance_schedule_policy.0.vm_stop_schedule'
properties:
- name: 'schedule'
type: String
description: |
Specifies the frequency for the operation, using the unix-cron format.
required: true
- name: 'timeZone'
type: String
description: |
Specifies the time zone to be used in interpreting the schedule. The value of this field must be a time zone name
from the tz database: http://en.wikipedia.org/wiki/Tz_database.
required: true
- name: 'startTime'
type: String
description: |
The start time of the schedule. The timestamp is an RFC3339 string.
- name: 'expirationTime'
type: String
description: |
The expiration time of the schedule. The timestamp is an RFC3339 string.
- name: 'diskConsistencyGroupPolicy'
type: NestedObject
description: |
Replication consistency group for asynchronous disk replication.
send_empty_value: true
conflicts:
- snapshot_schedule_policy
- group_placement_policy
- instance_schedule_policy
custom_flatten: 'templates/terraform/custom_flatten/disk_consistency_group_policy.tmpl'
custom_expand: 'templates/terraform/custom_expand/disk_consistency_group_policy.tmpl'
properties:
- name: 'enabled'
type: Boolean
description: |
Enable disk consistency on the resource policy.
required: true
immutable: true
- name: 'workloadPolicy'
type: NestedObject
description: |
Represents the workload policy.
min_version: 'beta'
properties:
- name: 'type'
type: Enum
description: |
The type of workload policy.
immutable: true
required: true
enum_values:
- 'HIGH_AVAILABILITY'
- 'HIGH_THROUGHPUT'
- name: 'maxTopologyDistance'
type: Enum
description: |
The maximum topology distance. This field can be set only when the workload policy type is HIGH_THROUGHPUT
and cannot be set if accelerator topology is set.
immutable: true
enum_values:
- 'BLOCK'
- 'CLUSTER'
- 'SUBBLOCK'
conflicts:
- 'workload_policy.0.accelerator_topology'
- name: 'acceleratorTopology'
type: String
description: |
The accelerator topology. This field can be set only when the workload policy type is HIGH_THROUGHPUT
and cannot be set if max topology distance is set.
immutable: true
conflicts:
- 'workload_policy.0.max_topology_distance'