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-cloud-storage-anonymous-or-publicly-accessible.md.
A documentation index is available at /llms.txt.
Cloud Storage buckets must not be anonymously or publicly accessible. Setting an ACL entity to allUsers or allAuthenticatedUsers grants broad read or write access to anyone on the internet or to any authenticated Google account, risking data exposure or unauthorized modification.
For Ansible gcp_storage_bucket resources (modules google.cloud.gcp_storage_bucket and gcp_storage_bucket), ensure neither the acl.entity nor the default_object_acl.entity property is set to allUsers or allAuthenticatedUsers. If a bucket does not define acl, default_object_acl must be explicitly defined and must not contain those public entities. Tasks missing default_object_acl or with either entity set to allUsers/allAuthenticatedUsers are flagged.
Compliant Code Examples
#this code is a correct code for which the query should not find any result- name:create a bucketgoogle.cloud.gcp_storage_bucket:name:ansible-storage-moduleproject:test_projectauth_kind:serviceaccountservice_account_file:/tmp/auth.pemstate:presentacl:bucket:bucketNameentity:group-example@googlegroups.com
Non-Compliant Code Examples
#this is a problematic code where the query should report a result(s)- name:create a bucket1google.cloud.gcp_storage_bucket:name:ansible-storage-module1project:test_projectauth_kind:serviceaccountservice_account_file:"/tmp/auth.pem"state:presentdefault_object_acl:bucket:bucketName1entity:allUsersrole:READER- name:create a bucket2google.cloud.gcp_storage_bucket:name:ansible-storage-module2project:test_projectauth_kind:serviceaccountservice_account_file:"/tmp/auth.pem"state:presentacl:bucket:bucketName2entity:allAuthenticatedUsersdefault_object_acl:bucket:bucketName2entity:allUsersrole:READER- name:create a bucket3google.cloud.gcp_storage_bucket:name:ansible-storage-module3project:test_projectauth_kind:serviceaccountservice_account_file:"/tmp/auth.pem"state:present
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.