For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/ansible/gcp/shielded_vm_disabled.md.
A documentation index is available at /llms.txt.
Compute instances must have Shielded VM features enabled to protect boot integrity and prevent or detect kernel and firmware tampering.
For Ansible resources using google.cloud.gcp_compute_instance or gcp_compute_instance, the shielded_instance_config property must be defined with enable_secure_boot, enable_vtpm, and enable_integrity_monitoring set to true. Resources missing shielded_instance_config or with any of these attributes undefined or set to false are flagged.
Secure configuration example:
- name:Create GCP compute instance with Shielded VM enabledgoogle.cloud.gcp_compute_instance:name:my-instancemachine_type:e2-mediumzone:us-central1-ashielded_instance_config:enable_secure_boot:trueenable_vtpm:trueenable_integrity_monitoring:true
Compliant Code Examples
#this code is a correct code for which the query should not find any result- name:create a instancegoogle.cloud.gcp_compute_instance:name:test_objectmachine_type:n1-standard-1disks:- auto_delete:'true'boot:'true'source:'{{ disk }}'- auto_delete:'true'interface:NVMEtype:SCRATCHinitialize_params:disk_type:local-ssdmetadata:startup-script-url:gs:://graphite-playground/bootstrap.shcost-center:'12345'labels:environment:productionnetwork_interfaces:- network:'{{ network }}'access_configs:- name:External NATnat_ip:'{{ address }}'type:ONE_TO_ONE_NATzone:us-central1-aproject:test_projectauth_kind:serviceaccountservice_account_file:/tmp/auth.pemstate:presentshielded_instance_config:enable_integrity_monitoring:yesenable_secure_boot:yesenable_vtpm:yes
Non-Compliant Code Examples
#this is a problematic code where the query should report a result(s)- name:create a instance1google.cloud.gcp_compute_instance:name:test_object1machine_type:n1-standard-1metadata:startup-script-url:gs:://graphite-playground/bootstrap.shcost-center:'12345'labels:environment:productionnetwork_interfaces:- network:"{{ network }}"access_configs:- name:External NATnat_ip:"{{ address }}"type:ONE_TO_ONE_NATzone:us-central1-aproject:test_projectauth_kind:serviceaccountservice_account_file:"/tmp/auth.pem"state:present- name:create a instance2google.cloud.gcp_compute_instance:name:test_object2machine_type:n1-standard-1metadata:startup-script-url:gs:://graphite-playground/bootstrap.shcost-center:'12345'labels:environment:productionnetwork_interfaces:- network:"{{ network }}"access_configs:- name:External NATnat_ip:"{{ address }}"type:ONE_TO_ONE_NATzone:us-central1-aproject:test_projectauth_kind:serviceaccountservice_account_file:"/tmp/auth.pem"state:presentshielded_instance_config:enable_secure_boot:yesenable_vtpm:yes- name:create a instance3google.cloud.gcp_compute_instance:name:test_object3machine_type:n1-standard-1metadata:startup-script-url:gs:://graphite-playground/bootstrap.shcost-center:'12345'labels:environment:productionnetwork_interfaces:- network:"{{ network }}"access_configs:- name:External NATnat_ip:"{{ address }}"type:ONE_TO_ONE_NATzone:us-central1-aproject:test_projectauth_kind:serviceaccountservice_account_file:"/tmp/auth.pem"state:presentshielded_instance_config:enable_integrity_monitoring:yesenable_vtpm:yes- name:create a instance4google.cloud.gcp_compute_instance:name:test_object4machine_type:n1-standard-1metadata:startup-script-url:gs:://graphite-playground/bootstrap.shcost-center:'12345'labels:environment:productionnetwork_interfaces:- network:"{{ network }}"access_configs:- name:External NATnat_ip:"{{ address }}"type:ONE_TO_ONE_NATzone:us-central1-aproject:test_projectauth_kind:serviceaccountservice_account_file:"/tmp/auth.pem"state:presentshielded_instance_config:enable_integrity_monitoring:yesenable_secure_boot:yes- name:create a instance5google.cloud.gcp_compute_instance:name:test_object5machine_type:n1-standard-1metadata:startup-script-url:gs:://graphite-playground/bootstrap.shcost-center:'12345'labels:environment:productionnetwork_interfaces:- network:"{{ network }}"access_configs:- name:External NATnat_ip:"{{ address }}"type:ONE_TO_ONE_NATzone:us-central1-aproject:test_projectauth_kind:serviceaccountservice_account_file:"/tmp/auth.pem"state:presentshielded_instance_config:enable_integrity_monitoring:noenable_secure_boot:yesenable_vtpm:yes- name:create a instance6google.cloud.gcp_compute_instance:name:test_object6machine_type:n1-standard-1metadata:startup-script-url:gs:://graphite-playground/bootstrap.shcost-center:'12345'labels:environment:productionnetwork_interfaces:- network:"{{ network }}"access_configs:- name:External NATnat_ip:"{{ address }}"type:ONE_TO_ONE_NATzone:us-central1-aproject:test_projectauth_kind:serviceaccountservice_account_file:"/tmp/auth.pem"state:presentshielded_instance_config:enable_integrity_monitoring:yesenable_secure_boot:noenable_vtpm:yes- name:create a instance7google.cloud.gcp_compute_instance:name:test_object7machine_type:n1-standard-1metadata:startup-script-url:gs:://graphite-playground/bootstrap.shcost-center:'12345'labels:environment:productionnetwork_interfaces:- network:"{{ network }}"access_configs:- name:External NATnat_ip:"{{ address }}"type:ONE_TO_ONE_NATzone:us-central1-aproject:test_projectauth_kind:serviceaccountservice_account_file:"/tmp/auth.pem"state:presentshielded_instance_config:enable_integrity_monitoring:yesenable_secure_boot:yesenable_vtpm:no
1
2
rulesets:- Ansible / GCP # Rules to enforce / GCP.
Request a personalized demo
Get Started with Datadog
Ask AI
AI-generated responses may be inaccurate. Verify important info.