Google OS Config Patch Deployment
This page shows how to write Terraform for OS Config Patch Deployment and write them securely.
google_os_config_patch_deployment (Terraform)
The Patch Deployment in OS Config can be configured in Terraform with the resource name google_os_config_patch_deployment. The following sections describe 2 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "google_os_config_patch_deployment" "blue-windows" {
patch_deployment_id = var.deployment_id_1
instance_filter {
group_labels {
resource "google_os_config_patch_deployment" "patch" {
patch_deployment_id = "patch-deploy-apt"
instance_filter {
group_labels {
labels = {
Parameters
-
create_timeoptional computed - string
Time the patch deployment was created. Timestamp is in RFC3339 text format. A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".
-
descriptionoptional - string
Description of the patch deployment. Length of the description is limited to 1024 characters.
-
durationoptional - string
Duration of the patch. After the duration ends, the patch times out. A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s"
-
idoptional computed - string -
last_execute_timeoptional computed - string
The last time a patch job was started by this deployment. Timestamp is in RFC3339 text format. A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".
-
nameoptional computed - string
Unique name for the patch deployment resource in a project. The patch deployment name is in the form: projects/[project_id]/patchDeployments/[patchDeploymentId].
-
patch_deployment_idrequired - string
A name for the patch deployment in the project. When creating a name the following rules apply: Must contain only lowercase letters, numbers, and hyphens. Must start with a letter. Must be between 1-63 characters. Must end with a number or a letter. * Must be unique within the project.
-
projectoptional computed - string -
update_timeoptional computed - string
Time the patch deployment was last updated. Timestamp is in RFC3339 text format. A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".
-
instance_filterlist block-
alloptional - bool
Target all VM instances in the project. If true, no other criteria is permitted.
-
instance_name_prefixesoptional - list of string
Targets VMs whose name starts with one of these prefixes. Similar to labels, this is another way to group VMs when targeting configs, for example prefix="prod-".
-
instancesoptional - list of string
Targets any of the VM instances specified. Instances are specified by their URI in the 'form zones/[[zone]]/instances/[[instance_name]]', 'projects/[[project_id]]/zones/[[zone]]/instances/[[instance_name]]', or 'https://www.googleapis.com/compute/v1/projects/[[project_id]]/zones/[[zone]]/instances/[[instance_name]]'
-
zonesoptional - list of string
Targets VM instances in ANY of these zones. Leave empty to target VM instances in any zone.
-
group_labelslist block-
labelsrequired - map from string to string
Compute Engine instance labels that must be present for a VM instance to be targeted by this filter
-
-
-
one_time_schedulelist block-
execute_timerequired - string
The desired patch job execution time. A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".
-
-
patch_configlist block-
reboot_configoptional - string
Post-patch reboot settings. Possible values: ["DEFAULT", "ALWAYS", "NEVER"]
-
aptlist block-
excludesoptional - list of string
List of packages to exclude from update. These packages will be excluded.
-
exclusive_packagesoptional - list of string
An exclusive list of packages to be updated. These are the only packages that will be updated. If these packages are not installed, they will be ignored. This field cannot be specified with any other patch configuration fields.
-
typeoptional - string
By changing the type to DIST, the patching is performed using apt-get dist-upgrade instead. Possible values: ["DIST", "UPGRADE"]
-
-
goolist block-
enabledrequired - bool
goo update settings. Use this setting to override the default goo patch rules.
-
-
post_steplist block-
linux_exec_step_configlist block-
allowed_success_codesoptional - list of number
Defaults to [0]. A list of possible return values that the execution can return to indicate a success.
-
interpreteroptional - string
The script interpreter to use to run the script. If no interpreter is specified the script will be executed directly, which will likely only succeed for scripts with shebang lines. Possible values: ["SHELL", "POWERSHELL"]
-
local_pathoptional - string
An absolute path to the executable on the VM.
-
gcs_objectlist block-
bucketrequired - string
Bucket of the Cloud Storage object.
-
generation_numberrequired - string
Generation number of the Cloud Storage object. This is used to ensure that the ExecStep specified by this PatchJob does not change.
-
objectrequired - string
Name of the Cloud Storage object.
-
-
-
windows_exec_step_configlist block-
allowed_success_codesoptional - list of number
Defaults to [0]. A list of possible return values that the execution can return to indicate a success.
-
interpreteroptional - string
The script interpreter to use to run the script. If no interpreter is specified the script will be executed directly, which will likely only succeed for scripts with shebang lines. Possible values: ["SHELL", "POWERSHELL"]
-
local_pathoptional - string
An absolute path to the executable on the VM.
-
gcs_objectlist block-
bucketrequired - string
Bucket of the Cloud Storage object.
-
generation_numberrequired - string
Generation number of the Cloud Storage object. This is used to ensure that the ExecStep specified by this PatchJob does not change.
-
objectrequired - string
Name of the Cloud Storage object.
-
-
-
-
pre_steplist block-
linux_exec_step_configlist block-
allowed_success_codesoptional - list of number
Defaults to [0]. A list of possible return values that the execution can return to indicate a success.
-
interpreteroptional - string
The script interpreter to use to run the script. If no interpreter is specified the script will be executed directly, which will likely only succeed for scripts with shebang lines. Possible values: ["SHELL", "POWERSHELL"]
-
local_pathoptional - string
An absolute path to the executable on the VM.
-
gcs_objectlist block-
bucketrequired - string
Bucket of the Cloud Storage object.
-
generation_numberrequired - string
Generation number of the Cloud Storage object. This is used to ensure that the ExecStep specified by this PatchJob does not change.
-
objectrequired - string
Name of the Cloud Storage object.
-
-
-
windows_exec_step_configlist block-
allowed_success_codesoptional - list of number
Defaults to [0]. A list of possible return values that the execution can return to indicate a success.
-
interpreteroptional - string
The script interpreter to use to run the script. If no interpreter is specified the script will be executed directly, which will likely only succeed for scripts with shebang lines. Possible values: ["SHELL", "POWERSHELL"]
-
local_pathoptional - string
An absolute path to the executable on the VM.
-
gcs_objectlist block-
bucketrequired - string
Bucket of the Cloud Storage object.
-
generation_numberrequired - string
Generation number of the Cloud Storage object. This is used to ensure that the ExecStep specified by this PatchJob does not change.
-
objectrequired - string
Name of the Cloud Storage object.
-
-
-
-
windows_updatelist block-
classificationsoptional - list of string
Only apply updates of these windows update classifications. If empty, all updates are applied. Possible values: ["CRITICAL", "SECURITY", "DEFINITION", "DRIVER", "FEATURE_PACK", "SERVICE_PACK", "TOOL", "UPDATE_ROLLUP", "UPDATE"]
-
excludesoptional - list of string
List of KBs to exclude from update.
-
exclusive_patchesoptional - list of string
An exclusive list of kbs to be updated. These are the only patches that will be updated. This field must not be used with other patch configurations.
-
-
yumlist block-
excludesoptional - list of string
List of packages to exclude from update. These packages will be excluded.
-
exclusive_packagesoptional - list of string
An exclusive list of packages to be updated. These are the only packages that will be updated. If these packages are not installed, they will be ignored. This field cannot be specified with any other patch configuration fields.
-
minimaloptional - bool
Will cause patch to run yum update-minimal instead.
-
securityoptional - bool
Adds the --security flag to yum update. Not supported on all platforms.
-
-
zypperlist block-
categoriesoptional - list of string
Install only patches with these categories. Common categories include security, recommended, and feature.
-
excludesoptional - list of string
List of packages to exclude from update.
-
exclusive_patchesoptional - list of string
An exclusive list of patches to be updated. These are the only patches that will be installed using 'zypper patch patch:' command. This field must not be used with any other patch configuration fields.
-
severitiesoptional - list of string
Install only patches with these severities. Common severities include critical, important, moderate, and low.
-
with_optionaloptional - bool
Adds the --with-optional flag to zypper patch.
-
with_updateoptional - bool
Adds the --with-update flag, to zypper patch.
-
-
-
recurring_schedulelist block-
end_timeoptional - string
The end time at which a recurring patch deployment schedule is no longer active. A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".
-
last_execute_timeoptional computed - string
The time the last patch job ran successfully. A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".
-
next_execute_timeoptional computed - string
The time the next patch job is scheduled to run. A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".
-
start_timeoptional - string
The time that the recurring schedule becomes effective. Defaults to createTime of the patch deployment. A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".
-
monthlylist block-
month_dayoptional - number
One day of the month. 1-31 indicates the 1st to the 31st day. -1 indicates the last day of the month. Months without the target day will be skipped. For example, a schedule to run "every month on the 31st" will not run in February, April, June, etc.
-
week_day_of_monthlist block-
day_of_weekrequired - string
A day of the week. Possible values: ["MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY"]
-
week_ordinalrequired - number
Week number in a month. 1-4 indicates the 1st to 4th week of the month. -1 indicates the last week of the month.
-
-
-
time_of_daylist block-
hoursoptional - number
Hours of day in 24 hour format. Should be from 0 to 23. An API may choose to allow the value "24:00:00" for scenarios like business closing time.
-
minutesoptional - number
Minutes of hour of day. Must be from 0 to 59.
-
nanosoptional - number
Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999.
-
secondsoptional - number
Seconds of minutes of the time. Must normally be from 0 to 59. An API may allow the value 60 if it allows leap-seconds.
-
-
time_zonelist block-
idrequired - string
IANA Time Zone Database time zone, e.g. "America/New_York".
-
versionoptional - string
IANA Time Zone Database version number, e.g. "2019a".
-
-
weeklylist block-
day_of_weekrequired - string
IANA Time Zone Database time zone, e.g. "America/New_York". Possible values: ["MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY"]
-
-
-
rolloutlist block-
moderequired - string
Mode of the patch rollout. Possible values: ["ZONE_BY_ZONE", "CONCURRENT_ZONES"]
-
disruption_budgetlist block-
fixedoptional - number
Specifies a fixed value.
-
percentageoptional - number
Specifies the relative value defined as a percentage, which will be multiplied by a reference value.
-
-
-
timeoutssingle block
Explanation in Terraform Registry
Patch deployments are configurations that individual patch jobs use to complete a patch. These configurations include instance filter, package repository settings, and a schedule. To get more information about PatchDeployment, see:
- API documentation
- How-to Guides
Frequently asked questions
What is Google OS Config Patch Deployment?
Google OS Config Patch Deployment is a resource for OS Config of Google Cloud Platform. Settings can be wrote in Terraform.
Where can I find the example code for the Google OS Config Patch Deployment?
For Terraform, the rackspace-infrastructure-automation/mgcp-terraform-modules and jeremychauvet/gcp-terramearth-showroom source code examples are useful. See the Terraform Example section for further details.