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-gke-master-authorized-networks-disabled.md.
A documentation index is available at /llms.txt.
GKE clusters must enable master authorized networks to restrict access to the Kubernetes control plane to trusted network ranges. Without this restriction, unauthorized or network-based access could lead to cluster compromise.
For Ansible resources using google.cloud.gcp_container_cluster or gcp_container_cluster, the master_authorized_networks_config property must be defined and its enabled field set to true. Resources missing master_authorized_networks_config or with master_authorized_networks_config.enabled set to false are flagged as insecure. Optionally, include CIDR entries to specify allowed client networks via master_authorized_networks_config.cidr_blocks.
Secure Ansible example:
- name:Create secure GKE cluster with master authorized networksgoogle.cloud.gcp_container_cluster:name:my-clusterlocation:us-central1master_authorized_networks_config:enabled:truecidr_blocks:- cidr_block:203.0.113.0/24display_name:office-network
Compliant Code Examples
- name:create a clustergoogle.cloud.gcp_container_cluster:name:my-clusterinitial_node_count:2location:us-central1-aauth_kind:serviceaccountmaster_authorized_networks_config:cidr_blocks:- cidr_block:192.0.2.0/24enabled:yesstate:present
Non-Compliant Code Examples
---- name:create a clustergoogle.cloud.gcp_container_cluster:name:my-clusterlocation:us-central1-aauth_kind:serviceaccountmaster_authorized_networks_config:cidr_blocks:- cidr_block:192.0.2.0/24enabled:nostate:present- name:create a second clustergoogle.cloud.gcp_container_cluster:name:my-second-clusterlocation:us-central1-aauth_kind:serviceaccountmaster_authorized_networks_config:cidr_blocks:- cidr_block:192.0.2.0/24state:present- name:create a third clustergoogle.cloud.gcp_container_cluster:name:my-third-clusterlocation:us-central1-aauth_kind:serviceaccountstate: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.