# A .sops.yaml has a rule with path_regex: .*\.yaml$ followed by a rule with path_regex: ^prod/.*\.yaml$. Which rule applies when you encrypt prod/db.yaml?

Flux CD, Hard (Expert), Troubleshooting. https://k8wiz.com/uquiz/a-sopsyaml-has-a-rule-with-path_regex-yaml-followed-by-a-rule-with-path_regex-prodyaml-which-rule-applies-when-you-encrypt-prodd

- A. The first rule, because sops uses the first match
- B. The second rule, because it is more specific
- C. Both rules, so the file is encrypted for both keys
- D. Neither, because sops rejects overlapping rules

**Answer:** The first rule, because sops uses the first match

**Explanation:** sops checks creation_rules in order against the file path relative to the directory of .sops.yaml and stops at the first rule that matches. A broad rule at the top shadows everything below it, so specific rules have to come first.
