For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/terraform-gcp-shielded-vm-disabled.md.
A documentation index is available at /llms.txt.
Compute instances must be configured with Shielded VM enabled to provide enhanced security against rootkits and other persistent threats. This requires defining the shielded_instance_config block with all sub-attributes—enable_secure_boot, enable_vtpm, and enable_integrity_monitoring—set to true. Failure to enable these features, as shown below, can leave virtual machines vulnerable to unauthorized modifications, tampering, or attacks that compromise the integrity and confidentiality of the system.
data "google_compute_instance" "appserver" {
name = "primary-application-server"
zone = "us-central1-a"
shielded_instance_config {
enable_secure_boot = true
enable_vtpm = true
enable_integrity_monitoring = true
}
}
Compliant Code Examples
#this code is a correct code for which the query should not find any result
data"google_compute_instance""appserver"{name="primary-application-server"zone="us-central1-a"shielded_instance_config{enable_secure_boot=trueenable_vtpm=trueenable_integrity_monitoring=true}}
Non-Compliant Code Examples
#this is a problematic code where the query should report a result(s)
data"google_compute_instance""appserver1"{name="primary-application-server"zone="us-central1-a"}data"google_compute_instance""appserver2"{name="primary-application-server"zone="us-central1-a"shielded_instance_config{enable_secure_boot=trueenable_vtpm=true}}data"google_compute_instance""appserver3"{name="primary-application-server"zone="us-central1-a"shielded_instance_config{enable_secure_boot=trueenable_integrity_monitoring=true}}data"google_compute_instance""appserver4"{name="primary-application-server"zone="us-central1-a"shielded_instance_config{enable_vtpm=trueenable_integrity_monitoring=true}}data"google_compute_instance""appserver5"{name="primary-application-server"zone="us-central1-a"shielded_instance_config{enable_secure_boot=falseenable_vtpm=trueenable_integrity_monitoring=true}}data"google_compute_instance""appserver6"{name="primary-application-server"zone="us-central1-a"shielded_instance_config{enable_secure_boot=trueenable_vtpm=falseenable_integrity_monitoring=true}}data"google_compute_instance""appserver7"{name="primary-application-server"zone="us-central1-a"shielded_instance_config{enable_secure_boot=trueenable_vtpm=trueenable_integrity_monitoring=false}}