A passing policy test shows that a rule produced the expected decisions for its supplied examples. Cloud security engineering and controls work also needs evidence of what was deployed and what happened after changes. Build an evidence chain connecting the assertion, tested policy, input, deployed resource, and later evaluation instead of presenting a green test result as proof of continuing protection.
Key takeaways
- Assertion: State a claim that a failing example could disprove.
- Tests: Include allowed, prohibited, and incomplete inputs.
- Provenance: Retain the exact policy, input, tool version, and evaluation result.
- Runtime: Pair preventive checks with observed resource state and remediation history.
What evidence connects cloud security engineering and controls?
Connect a specific control assertion to tests, the evaluated artifact, deployed state, and later changes. Each link answers a different question. Keep the conclusion narrow enough that a reviewer can tell which part is demonstrated and which part still requires evidence.
Use a fictional application with synthetic data. Suppose its design requires audit logging to be enabled. A useful initial assertion is: “The evaluated resource configuration explicitly declares audit logging enabled.” A missing or disabled value can falsify that statement.
That assertion is deliberately narrower than “all activity is monitored.” The broader claim would require evidence about event selection, delivery, storage, review, and response. A configuration flag cannot establish those behaviors by itself.
For candidates considering cleared cloud security responsibilities, the distinction provides a practical interview topic. Explain what evidence would change your conclusion rather than simply naming the product that generated a passing result.
How do you write passing and failing policy examples?
Start with an allowed input, a prohibited input, and an input missing the relevant field. Define the expected policy decision before running the tests. The tests should demonstrate that the rule rejects the prohibited condition as well as accepting the intended condition.
The current online Open Policy Agent policy-testing documentation describes Rego test rules whose names begin with test_. The following original learning example uses a synthetic normalized input, not the native schema of an AWS resource.
Save this policy as logging.rego in a dedicated example directory:
package lab.logging
default allow := false
allow if {
input.audit_logging_enabled == true
}
Save the corresponding tests as logging_test.rego in that directory:
package lab.logging
test_enabled if {
allow with input as {"audit_logging_enabled": true}
}
test_disabled_denied if {
not allow with input as {"audit_logging_enabled": false}
}
test_missing_denied if {
not allow with input as {}
}
From the example directory, run opa test . --fail-on-empty -v. The expected outcome is that every test passes, including the tests that expect a denied policy decision. A rejected configuration and a failed test are different outcomes: the negative test succeeds when the rule rejects the bad input as intended.
The --fail-on-empty option makes an accidentally empty test run fail. OPA’s current Rego language documentation explains default values; the example’s false default covers inputs where the enabling condition is not established.
Add cases for the actual input contract, such as a string instead of a Boolean, a null value, or an unexpectedly nested field. Then deliberately break the policy and confirm that the tests detect the change. Keep the fixture set small enough to explain but varied enough to challenge the intended rule.
What exactly should you capture from the test run?
Retain the policy and test inputs actually evaluated, the command, tool version, output, and execution context. Use version references or content digests so the result cannot become detached from its inputs. A filename alone is insufficient when its contents can change.
Create a simple manifest linking the assertion to the policy revision, fixture revisions, installed OPA version, and test output. Record whether the evaluated input came from source, a rendered deployment artifact, or an exported resource configuration. These are suggested evidence fields, not a mandated assessment template.
If you normalize a provider-specific export into the synthetic schema, preserve the original export and document the transformation. A mapper that substitutes a permissive value for a missing property can invalidate the conclusion even when the policy itself works correctly.
Preserve standard error and the process outcome alongside the readable report. A policy rejection, a parser error, and a command that never ran require different follow-up. In a delivery workflow, demonstrate what happens when the tool cannot load its policy or input; otherwise, an unavailable check could be mistaken for an acceptable configuration.
Keep evaluation and enforcement separate. Running the example produces policy decisions; it does not stop a deployment. If you integrate it into a release workflow, demonstrate how a denied decision changes that workflow’s outcome and how errors or missing input are handled.
This is a useful extension for a cleared DevSecOps work sample. Show the tested decision and the release behavior it actually controls, then identify paths the integration does not cover.
How do you compare planned settings with deployed state?
Collect the relevant deployed resource configuration and connect it to the deployment record and evaluated artifact. Compare the same security property across them. Verify the resource identity, collection time, environment, and observation scope before treating the records as comparable.
The current online AWS Config Developer Guide describes resource configuration history and evaluating settings against rules. That supplies a way to retain observed configuration evidence for supported resources within the recording setup. It does not make every cloud resource or property visible automatically.
For the fictional logging assertion, find the actual provider-specific property and determine whether it represents enabled logging, a destination setting, or something else. Document the mapping to your policy’s input. If the property is not available in the collected record, mark the assertion unevaluated rather than filling the gap by assumption.
AWS’s resource evaluation documentation distinguishes proactive evaluation before deployment from detective evaluation after deployment. It also states that proactive rules do not themselves remediate a noncompliant resource or prevent its deployment. Build the necessary action into the surrounding workflow.
Make time part of the claim. An export describes the state observed at collection, while a later change may invalidate that observation. If your presentation combines a release report with a runtime export, explain their order and any intervening changes instead of implying that both records describe the same moment.
Keep your OPA policy and any AWS Config rule conceptually aligned without implying that they are automatically the same implementation. Compare their input schemas, scope, and expected decisions. Matching labels do not establish equivalent tests.
| Evidence | Question it answers | Remaining limit |
|---|---|---|
| Policy unit tests | Did the rule make the expected fixture decisions? | Fixtures do not establish deployed state |
| Release evaluation | Did the evaluated artifact satisfy the rule? | Other deployment paths may exist |
| Observed configuration | What setting was recorded for the resource? | Configuration does not prove event delivery |
| Test event at destination | Did that approved action produce the expected record? | A sample does not establish complete ongoing coverage |
| Remediation and reevaluation | What changed, and what result followed? | Later changes still need observation |
What should you retain when an evaluation fails?
Preserve the failed input, result, affected resource, owner, correction, and subsequent evaluation. Link the source fix to the deployed correction. Keep an unresolved issue visible until the relevant evidence supports closure.
Suppose the fictional application passes its release check but a later configuration export shows logging disabled. Start by confirming that the records refer to the same resource and relevant property. Investigate whether a later change occurred, the wrong artifact was evaluated, or the normalization logic misrepresented the setting.
Record the explanation that the available evidence supports. An observation gap is different from a disabled setting, and a disabled setting is different from proven loss of a particular event. Preserve uncertainty where the records cannot distinguish them.
After an authorized correction, collect the configuration again and repeat the evaluation. Where your intended claim includes operational logging, generate an approved synthetic event and inspect its destination record. Keep that behavioral check separate from the enabled-setting assertion.
Retain failed and corrected results together. If a missing field exposed a policy or mapping defect, add that case to the tests. A regression check should address the failure’s cause rather than merely reproduce the happy path.
How should you present preventive and detective evidence together?
Present a connected case: assertion, tested policy, evaluated artifact, observed state, finding, correction, and verified result. Explain the limitations alongside the claim they qualify. A reviewer should be able to follow the evidence without accepting your interpretation on trust.
A short portfolio narrative can start with the allowed and denied fixtures, then show how a resource export maps to the same assertion. Use synthetic or recreated records that you are permitted to share. Identify simulated runtime evidence explicitly if you did not deploy a resource.
For showcasing technical skills on a cybersecurity resume, describe what you implemented and verified. “Tested a logging policy against enabled, disabled, and missing-field inputs, then documented the runtime evidence needed to validate it” is more defensible than claiming complete cloud compliance.
Be ready to explain the unresolved boundaries: monitoring scope, collection timing, transformation accuracy, alternate change paths, and operational follow-up. A work sample can demonstrate disciplined engineering judgment without establishing a system authorization or an employer’s compliance status.
Frequently Asked Questions
Does a passing negative test mean the bad configuration passed?
No. A negative test passes when the policy rejects the prohibited input as expected. Read the asserted decision and the test outcome separately when interpreting the report.
Can the same policy evaluate planned and observed settings?
It can when the inputs have a documented compatible representation. Preserve the source data and test the mapping. Native deployment and runtime schemas may differ, so reuse does not follow from a shared control label.
Is an enabled logging flag enough evidence?
It supports the narrow configuration assertion. Claims about generated events, delivery, retention, review, or response need evidence of those behaviors and processes.
What should I add to my project next?
Add a missing-field fixture, run the tests with empty-suite failure enabled, and connect the result to a dated synthetic resource export. Record exactly which runtime claim that export supports and which operational evidence is still missing.
