Organizations need to keep their software images updated to protect against new security threats. Cloud Build, Artifact Registry, and Cloud Scheduler work together to automate this process. Cloud Scheduler triggers build jobs on a schedule, Cloud Build pulls source files and creates new images, and Artifact Registry stores the finished images. This automation ensures that security patches and software updates are included in base images without requiring manual work.
Artifact Registry includes built-in container scanning that checks stored images for known vulnerabilities. Security teams can see which packages have security issues and what fixes are available. A practice called vendoring involves storing copies of third-party dependencies in private repositories, which protects against supply chain problems when external packages change or disappear. Teams should use dedicated service accounts with minimal permissions, such as roles/artifactregistry.writer, to control who can add or modify images.
For virtual machines, Packer combined with Cloud Build can create hardened "golden images" that include pre-configured operating systems, security hardening rules, and required software. Before capturing a disk image, administrators must stop the VM or flush disk writes to ensure the filesystem remains consistent. This automation makes VM deployments reproducible and ensures every instance meets security standards.
Image families help manage versions by grouping related images together, so automated deployments always get the latest available version. Administrators can set lifecycle rules to manage old images: DEPRECATED images still work but warn users to upgrade, OBSOLETE images cannot create new instances but existing disks remain usable, and DELETED images are completely removed.
VM Manager handles patch management for VM fleets through two main functions: checking whether VMs are up-to-date and actually applying patches. The service uses the OS Config API and requires an OS Config agent running on each VM to report inventory data and apply updates.
When a patch job runs, the API notifies agents on target VMs to begin patching. The agent uses standard tools like apt for Ubuntu or yum for RHEL to download and install updates from distribution repositories. The agent reports progress back to the API throughout the process so administrators can monitor status.
The OS Config agent sends inventory data to the backend approximately every 10 minutes, which is then cross-referenced with vulnerability databases from Red Hat, Debian, and Ubuntu. VMs are categorized by severity: Critical (RED), Important/Security (ORANGE), Other (YELLOW), and Up-to-date (GREEN). The dashboard shows the highest severity vulnerability for each VM, helping teams prioritize which machines need attention first.
Patch jobs can run on demand, one time, or on a recurring schedule. Maintenance windows define how long a patch job has to complete before timing out. You can also set enforcement deadlines—if VMs aren't patched by a certain date, the system automatically starts applying updates. Reboot behavior can be set to let the agent decide, always reboot, or never reboot (though some patches may not fully apply without a reboot).
For Windows VMs, you can select specific patch types like Security updates or target individual KB IDs. For Linux VMs, you can apply security updates, system updates, or specific packages. Instance filters let you target VMs by name, labels, zone, or group. You can patch up to 500 VMs at once, though smaller batches help minimize impact on availability.
Advanced features include pre-patch and post-patch scripts that run before and after the patching process—useful for stopping applications gracefully or checking health after updates. Scripts can run from local VM storage or from Cloud Storage buckets. Rollout options include patching zones sequentially or concurrently, and you can set a disruption budget to limit how many VMs are updated at once.
Managing patch jobs requires specific IAM roles: patchJobExecutor allows running and canceling jobs, while patchJobViewer provides read-only access. Patch jobs only work within a single project, and VMs in Managed Instance Groups may revert to unpatched states when the group repairs or scales instances.
Automated image hardening uses Infrastructure as Code tools to create secure, consistent base images for VMs and containers. This approach eliminates manual configuration differences and ensures every deployment starts from a known-good, hardened state. Security is built into the image from the beginning rather than applied afterward.
Packer builds VM images while Dockerfiles build container images. Both let you define image configuration as code that can be version-controlled and reused. You integrate security standards like CIS benchmarks directly into these build scripts, so resulting images are pre-hardened against common vulnerabilities before deployment.
The automated pipeline includes continuous security validation. Container Scanning automatically checks newly built images for known vulnerabilities as soon as they enter Artifact Registry. The pipeline validates that configurations meet internal policies and compliance standards. Using Cloud Scheduler to trigger Cloud Build pipelines regularly (such as nightly) ensures custom images rebuild automatically when base images receive updates.
Lifecycle management extends to ongoing maintenance through image families, which always point to the latest patched version. Policies can automatically deprecate or delete old images after a set time, preventing use of outdated vulnerable versions. Sharing hardened images across projects uses fine-grained IAM roles to ensure only authorized users and service accounts can access them.
Production environments require additional hardening: removing unnecessary software, using dedicated service accounts with minimal privileges, and ensuring no credentials are embedded in images. The pipeline should produce images that pass scanning before being promoted to artifact repositories. This automated, secure supply chain reduces attack surface and lets security teams focus on higher-level threats.
Professional Cloud Security Engineer
Gauge your current knowledge
Gauge your current knowledge