gcloud compute security-policies rules update PRIORITY [--action=ACTION] [--ban-duration-sec=BAN_DURATION_SEC] [--ban-threshold-count=BAN_THRESHOLD_COUNT] [--ban-threshold-interval-sec=BAN_THRESHOLD_INTERVAL_SEC] [--conform-action=CONFORM_ACTION] [--description=DESCRIPTION] [--enforce-on-key=ENFORCE_ON_KEY] [--enforce-on-key-configs=[[all],[ip],[xff-ip],[http-cookie=HTTP_COOKIE],[http-header=HTTP_HEADER],[http-path],[sni],[region-code],[tls-ja3-fingerprint],[user-ip],[tls-ja4-fingerprint]],[…]] [--enforce-on-key-name=ENFORCE_ON_KEY_NAME] [--exceed-action=EXCEED_ACTION] [--exceed-redirect-target=EXCEED_REDIRECT_TARGET] [--exceed-redirect-type=EXCEED_REDIRECT_TYPE] [--[no-]preview] [--rate-limit-threshold-count=RATE_LIMIT_THRESHOLD_COUNT] [--rate-limit-threshold-interval-sec=RATE_LIMIT_THRESHOLD_INTERVAL_SEC] [--recaptcha-action-site-keys=[SITE_KEY,…]] [--recaptcha-session-site-keys=[SITE_KEY,…]] [--redirect-target=REDIRECT_TARGET] [--redirect-type=REDIRECT_TYPE] [--region=REGION] [--request-headers-to-add=[REQUEST_HEADERS_TO_ADD,…]] [--security-policy=SECURITY_POLICY] [--expression=EXPRESSION --network-dest-ip-ranges=[DEST_IP_RANGE,…] --network-dest-ports=[DEST_PORT,…] --network-ip-protocols=[IP_PROTOCOL,…] --network-src-asns=[SRC_ASN,…] --network-src-ip-ranges=[SRC_IP_RANGE,…] --network-src-ports=[SRC_PORT,…] --network-src-region-codes=[SRC_REGION_CODE,…] --network-user-defined-fields=[NAME;VALUE:VALUE:…,…] --src-ip-ranges=[SRC_IP_RANGE,…]] [GCLOUD_WIDE_FLAG …]
gcloud compute security-policies rules update is used to update
security policy rules.
gcloud compute security-policies rules update 1000 --security-policy=my-policy --description="block 1.2.3.4/32" --src-ip-ranges=1.2.3.4/32PRIORITY--action=ACTIONACTION must be one of:
allowdenydeny-403deny-404deny-502rate-based-banredirectredirect-to-recaptchathrottle--ban-duration-sec=BAN_DURATION_SECrate-based-ban. If specified, determines
the time (in seconds) the traffic will continue to be banned by the rate limit
after the rate falls below the threshold.
--ban-threshold-count=BAN_THRESHOLD_COUNTrate-based-ban. If specified, the key will
be banned for the configured
BAN_DURATION_SEC when the number of
requests that exceed the
RATE_LIMIT_THRESHOLD_COUNT also exceed this
BAN_THRESHOLD_COUNT.
--ban-threshold-interval-sec=BAN_THRESHOLD_INTERVAL_SECrate-based-ban. If specified, the key will
be banned for the configured
BAN_DURATION_SEC when the number of
requests that exceed the
RATE_LIMIT_THRESHOLD_COUNT also exceed this
BAN_THRESHOLD_COUNT.
--conform-action=CONFORM_ACTIONCONFORM_ACTION must be (only one value is supported):
allow.
--description=DESCRIPTION--enforce-on-key=ENFORCE_ON_KEYip: each client IP address has this limit
enforced separately
all: a single limit is applied to all
requests matching this rule
http-header: key type takes the value of
the HTTP header configured in enforce-on-key-name as the key value
xff-ip: takes the original IP address
specified in the X-Forwarded-For header as the key
http-cookie: key type takes the value of
the HTTP cookie configured in enforce-on-key-name as the key value
http-path: key type takes the value of the
URL path in the request
sni: key type takes the value of the server
name indication from the TLS session of the HTTPS request
region-code: key type takes the value of
the region code from which the request originates
tls-ja3-fingerprint: key type takes the
value of JA3 TLS/SSL fingerprint if the client connects using HTTPS, HTTP/2 or
HTTP/3
user-ip: key type takes the IP address of
the originating client, which is resolved based on user-ip-request-headers
configured with the security policy
tls-ja4-fingerprint: key type takes the
value of JA4 TLS/SSL fingerprint if the client connects using HTTPS, HTTP/2 or
HTTP/3
ENFORCE_ON_KEY must be one of: ip,
all, http-header, xff-ip,
http-cookie, http-path, sni,
region-code, tls-ja3-fingerprint,
user-ip, tls-ja4-fingerprint.
--enforce-on-key-configs=[[all],[ip],[xff-ip],[http-cookie=HTTP_COOKIE],[http-header=HTTP_HEADER],[http-path],[sni],[region-code],[tls-ja3-fingerprint],[user-ip],[tls-ja4-fingerprint]],[…]ip: each client IP address has this limit
enforced separately
all: a single limit is applied to all
requests matching this rule
http-header: key type takes the value of
the HTTP header configured in enforce-on-key-name as the key value
xff-ip: takes the original IP address
specified in the X-Forwarded-For header as the key
http-cookie: key type takes the value of
the HTTP cookie configured in enforce-on-key-name as the key value
http-path: key type takes the value of the
URL path in the request
sni: key type takes the value of the server
name indication from the TLS session of the HTTPS request
region-code: key type takes the value of
the region code from which the request originates
tls-ja3-fingerprint: key type takes the
value of JA3 TLS/SSL fingerprint if the client connects using HTTPS, HTTP/2 or
HTTP/3
user-ip: key type takes the IP address of
the originating client, which is resolved based on user-ip-request-headers
configured with the security policy
tls-ja4-fingerprint: key type takes the
value of JA4 TLS/SSL fingerprint if the client connects using HTTPS, HTTP/2 or
HTTP/3
--enforce-on-key-name=ENFORCE_ON_KEY_NAME--exceed-action=EXCEED_ACTIONEXCEED_ACTION must be
one of: deny-403, deny-404, deny-429,
deny-502, deny, redirect.
--exceed-redirect-target=EXCEED_REDIRECT_TARGETexternal-302.
--exceed-redirect-type=EXCEED_REDIRECT_TYPEEXCEED_REDIRECT_TYPE must be one of:
google-recaptcha, external-302.
--[no-]preview--preview to
enable and --no-preview to disable.
--rate-limit-threshold-count=RATE_LIMIT_THRESHOLD_COUNT--rate-limit-threshold-interval-sec=RATE_LIMIT_THRESHOLD_INTERVAL_SEC--recaptcha-action-site-keys=[SITE_KEY,…]--recaptcha-session-site-keys=[SITE_KEY,…]--redirect-target=REDIRECT_TARGETexternal-302. Cannot be specified if the
redirect type is google-recaptcha.
--redirect-type=REDIRECT_TYPEexternal-302 if unspecified while
--redirect-target is given. REDIRECT_TYPE must be one
of: google-recaptcha, external-302.
--region=REGIONA list of regions can be fetched by running:
gcloud compute regions listcompute/region property value for this
command invocation.
--request-headers-to-add=[REQUEST_HEADERS_TO_ADD,…]--security-policy=SECURITY_POLICY--expression=EXPRESSION--network-dest-ip-ranges=[DEST_IP_RANGE,…]--network-dest-ports=[DEST_PORT,…]--network-ip-protocols=[IP_PROTOCOL,…]--network-src-asns=[SRC_ASN,…]--network-src-ip-ranges=[SRC_IP_RANGE,…]--network-src-ports=[SRC_PORT,…]--network-src-region-codes=[SRC_REGION_CODE,…]--network-user-defined-fields=[NAME;VALUE:VALUE:…,…]--src-ip-ranges=[SRC_IP_RANGE,…]--access-token-file,
--account, --billing-project,
--configuration,
--flags-file,
--flatten, --format, --help, --impersonate-service-account,
--log-http,
--project, --quiet, --trace-token, --user-output-enabled,
--verbosity.
Run $ gcloud help for details.
gcloud alpha compute security-policies rules updategcloud beta compute security-policies rules updategcloud preview compute security-policies rules update
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-05-27 UTC.