Skip to navigationSkip to main contentSkip to footerScaleway Docs HomepageAsk our AI
Ask our AI

CEL conditions guide

At Scaleway, IAM conditions are defined using Common Expression Language (CEL) expressions.

This page is here to help you with CEL expressions, providing examples, guidance, and additional resources.

As a reminder, you can refer to the How to create a policy and How to manage policies documentation pages to learn where and how to specify a condition.

General functions

FunctionDescriptionExample
sizeReturns the size of a string (characters), bytes, a list, or a map.size("hello") // 5
containsReturns whether a string contains a substring."hello".contains("ell") // true
startsWithReturns whether a string starts with a prefix."hello".startsWith("he") // true
endsWithReturns whether a string ends with a suffix."hello".endsWith("lo") // true
matchesReturns whether a string matches a RE2 regular expression."123".matches(r"^\d+$") // true

Time functions

FunctionDescriptionExample
getDayOfMonthReturns the day of the month (1-31).timestamp("2026-07-23T00:00:00Z").getDayOfMonth() // 23
getHoursReturns the hours (0-23).duration("1h30m").getHours() // 1
getMinutesReturns the minutes (0-59).duration("1h30m").getMinutes() // 30
Note

You can pass a timezone as a parameter, such as "America/New_York" or "Europe/Paris".

Example: resource.getHours("Europe/Paris").

By default, the time returned is in UTC (e.g., resource.getHours()).

Network functions

FunctionDescriptionExample
ipParses a string into an IP address, or extracts the IP from a CIDR.ip("192.168.0.1") or cidr("192.168.0.0/24").ip()
isIPChecks if a string is a valid IP address.isIP("192.168.0.1") // true
cidrParses a string into a CIDR block.cidr("192.168.0.0/24")
containsIPChecks if a CIDR block contains an IP address.cidr("192.168.0.0/24").containsIP(ip("192.168.0.1")) // true
familyReturns the IP family (4 for IPv4, 6 for IPv6).ip("192.168.0.1").family() // 4
isUnspecifiedChecks if the IP is an unspecified address (e.g., 0.0.0.0).ip("0.0.0.0").isUnspecified() // true

Examples of CEL expressions

RequestDescription
request.ip == "192.168.1.0" && request.time.getDayOfWeek() == 5 && resource.name.matches("prod")A certain IP requested on a Friday and has a resource name of prod.
resource.name.startsWith("staging") && resource.locality.startsWith("fr-par")Check a resource name that starts with staging and is in the fr-par locality.
(cidr('45.23.0.1/16').containsIP(request.ip) || request.user_agent.contains("Test"))Check if the IP is within 45.23.0.0/16 or if the user agent contains Test.

Additional CEL resources

You can test and experiment with CEL functions interactively using the CEL Playground (External link).

You can check the whole CEL official function reference list in section "Core functions" of the CEL Function reference guide (External link).

Still need help?

Create a support ticket
No Results