Google Cloud Armor is Google’s managed web application firewall and DDoS defence service, and it is the layer that stands between the internet and your load balancer when you need to filter malicious traffic before it reaches your application. A backend that is open to the internet will eventually face automated scanning, credential-stuffing attempts, and volumetric floods, and absorbing those at the application layer wastes compute, fills logs, and risks an outage during a real attack. Cloud Armor moves that filtering to Google’s edge: it inspects requests against security policies you define, blocks or rate-limits the ones that match, and lets legitimate traffic through to your backends. This guide creates a security policy, attaches it to a load balancer backend, adds WAF rules and rate limiting, and explains how to test without blocking real users.
Cloud Armor has two layers that are easy to confuse. The always-on DDoS protection applies to all load balancer traffic at no extra configuration: Google’s infrastructure absorbs volumetric attacks and uses adaptive protection to learn your traffic baseline. The configurable layer is the security policy, where you write rules that allow, deny, throttle, or redirect requests based on IP addresses, geography, request headers, or preconfigured WAF rule sets for common attacks such as SQL injection and cross-site scripting. You pay for the policy layer, not for the always-on protection, and the policy is where your design decisions live. For related Google Cloud networking, see our guide to Google Cloud firewall rules for Compute Engine, which covers the VPC-level filtering that complements Cloud Armor.

Prerequisites
You need a Google Cloud project with billing enabled, a global external Application Load Balancer already serving an application, and permission to create security policies, which the Compute Security Admin role provides. The examples use the gcloud CLI, which you should have installed and authenticated with gcloud auth login and gcloud config set project. You should also have a test client, such as curl from a machine whose IP you can allowlist, because the safest way to test a deny rule is from an IP you control before it affects production traffic. Cloud Armor policies attach to backend services, not to individual VMs, so a load balancer is a hard prerequisite: a bare VM with a public IP cannot use Cloud Armor directly.
Google Cloud Armor: Create and Attach a Security Policy
Create a security policy with a default rule that allows traffic, then add deny rules above it. Rules are evaluated in priority order, lowest number first, and the first matching rule decides the action, so ordering is the policy. A common starting policy allows your office IP ranges, denies known bad actors by IP list, and leaves the default allow for everything else while you observe. Starting with allow as the default is deliberate: a new policy in deny-by-default mode can block legitimate traffic before you have tuned it, while an allow-default policy lets you add rules incrementally and watch their effect in logs.
gcloud compute security-policies create web-policy --description "Edge policy for public web app"
gcloud compute security-policies rules create 1000 --security-policy web-policy --expression "inIpRange(origin.ip, '203.0.113.0/24')" --action deny-403 --description "Block known abusive range"
gcloud compute security-policies rules update 2147483647 --security-policy web-policy --action allow --description "Default allow"
Attach the policy to the backend service of your load balancer. The attachment takes effect quickly, and from that moment every request to the backend is evaluated against the policy before it reaches your instances. Verify the attachment and test from both an allowed and a blocked address: a blocked request should return 403, while a normal request should reach the application unchanged. The official Google Cloud documentation on configuring Cloud Armor security policies documents every rule expression and action, including the preview mode described below.
gcloud compute backend-services update web-backend --global --security-policy web-policy
gcloud compute backend-services describe web-backend --global
Google Cloud Armor: WAF Rules, Rate Limiting, and Preview Mode
IP rules handle known bad addresses, but most web attacks come from addresses you have never seen, which is where preconfigured WAF rules help. These are managed rule sets maintained by Google for common attack classes: SQL injection, cross-site scripting, remote code execution, and protocol attacks, each with sensitivity levels you can tune. Enable a rule set in preview mode first, which logs matches without blocking, then review the logs for false positives against your application’s normal traffic, and only then switch the rule to deny. Skipping preview mode is the most common cause of a WAF outage, where a legitimate request pattern that resembles an attack gets blocked in production.
gcloud compute security-policies rules create 2000 --security-policy web-policy --expression "evaluatePreconfiguredWaf('sqli-v33-stable', {'sensitivity': 1})" --action deny-403 --preview --description "SQLi rules in preview"
Rate limiting is the second configurable defence, and it protects against abuse that is not a single malicious request but a flood of plausible ones: credential stuffing, scraping, and application-layer DDoS. A throttle rule limits requests per client IP over a time window, with options to enforce on IP, on a header such as a user ID, or on a combination. Start generous, such as 100 requests per minute per IP, and tighten based on your real traffic percentiles, because a limit set below your legitimate peak traffic is a self-inflicted outage. For an application behind a load balancer, also consider enabling Cloud Armor’s bot management features, which distinguish automated clients from browsers using signals beyond the request rate.
gcloud compute security-policies rules create 3000 --security-policy web-policy --expression "true" --action throttle --rate-limit-threshold-count 100 --rate-limit-threshold-interval-sec 60 --conform-action allow --exceed-action deny-429 --enforce-on-key ip --description "Throttle aggressive clients"
Adaptive Protection, available on Cloud Armor Enterprise tiers, goes further by learning your traffic baseline and proposing rules when it detects an attack pattern, which is valuable during a large Layer 7 attack when manual rule writing cannot keep up. Even without it, the combination of IP rules, WAF rules, and throttling covers the vast majority of attacks a public application faces, and every rule decision is logged for analysis in Cloud Logging.
Troubleshooting
When legitimate traffic is blocked, find the rule that blocked it before changing anything: Cloud Logging records the security policy, rule priority, and action for each evaluated request, so filter by the client IP and timestamp to identify the exact rule. If a WAF rule is the culprit, lower its sensitivity or add an exclusion for the specific field that triggers it, rather than disabling the whole rule set, which would reopen the attack class. If a throttle rule blocks real users, check whether many users share a single egress IP, such as a corporate NAT or a VPN gateway, because per-IP throttling treats that whole population as one client; in that case, enforce on a header that identifies individual users instead.
If a rule appears to have no effect, check the attachment first: a policy that is created but not attached to a backend service evaluates nothing, and a backend service can only have one policy, so attaching a new policy replaces the old one. Also check rule priority: a broad allow rule with a lower priority number than your deny rule will match first and the deny rule will never be evaluated. If Cloud Armor returns errors during policy creation, verify that the load balancer is a global external Application Load Balancer, because regional and internal load balancers do not support the same Cloud Armor features, and some advanced features require the Enterprise tier.
Conclusion
Google Cloud Armor turns edge filtering from a hope into a configured, logged, testable layer: a security policy attached to your backend, IP and geographic rules for known threats, previewed WAF rules for attack classes, and throttling for abusive rates. Build the policy incrementally, preview before you deny, monitor the logs after every change, and keep the VPC firewall rules behind it as a second layer. With that discipline, the next scan, flood, or injection attempt stops at Google’s edge, and your application only ever sees traffic that was supposed to reach it.