Professional Cloud Security Engineer
Prepare and test your skills
Prepare and test your skills
Worked example. The correct answer is already marked and every option is explained below, so there is nothing to select here. To answer questions yourself, start the free trial.
A security engineer needs to author a custom constraint rule using Common Expression Language (CEL) to enforce cryptographic key hygiene across an organization's resource hierarchy. The organization's compliance standard requires that:
cloudkms.googleapis.com/CryptoKey) must explicitly specify an automated rotation period.Which CEL condition should be configured in the custom rule definition to evaluate resource properties and satisfy these requirements?
This expression uses standard Common Expression Language (CEL) syntax supported across Google Cloud custom controls and constraints. It uses the has() field selection macro to verify presence and the built-in duration() function to evaluate time-based protobuf fields against a duration literal.
has(resource.data.rotationPeriod) macro inspects the underlying Google Cloud resource API definition to verify whether the rotationPeriod field has been explicitly defined on the CryptoKey object before attempting value comparisons.resource.data.rotationPeriod < duration('60h') converts the string literal '60h' into a native CEL duration type, enabling a valid relational comparison against the protobuf duration property defined on the resource.&& operator guarantees that the duration comparison is only evaluated if rotationPeriod exists, preventing null pointer or runtime field access errors.duration object.'h' for hours, 'm' for minutes, 's' for seconds) for clear, maintainable policy authoring.In Google Cloud policy definitions, CEL does not automatically coerce string representations of time into duration objects, nor does it allow direct access to unset protobuf message fields without checking presence. Combining has() with duration('60h') provides the exact syntax required for robust, error-free policy evaluation.
Keep the momentum going with these hand-picked practice scenarios
Want more questions like this?
Get a free certification question every week.