Prerequisites: Complete Lab 4: Release Controls before starting this lab.
Learning goals
- Understand Kosli Environments and how they track runtime state
- Create a Kosli Environment representing your deployment target
- Snapshot a Docker environment to report what’s running
- Create and configure compliance Policies
- Attach Policies to Environments for enforcement
- Integrate environment snapshotting into your CI/CD pipeline
Introduction
Kosli Environments allow you to track what’s actually running in your runtime environments (dev, staging, production). By taking regular snapshots, Kosli creates an immutable record of:- What artifacts are running, identified by their SHA256 digest
- When they started and stopped
- Whether they comply with your policies
- The complete change history over time
Environment types
Kosli supports several environment types:| Type | Tracks |
|---|---|
docker | Docker containers on a host |
k8s | Kubernetes pods in namespaces |
ecs | AWS ECS tasks |
lambda | AWS Lambda functions |
s3 | Files in S3 buckets |
server | Files on a server filesystem |
Exercise
Create an environment
Your application deploys as a Docker container, so create a Visit app.kosli.com → Environments and you should see
docker type environment:labs-prod listed (with no snapshots yet).See kosli create environment for full flag reference.Explore an existing environment
To see a real-world example, navigate to the Cyber-Dojo AWS Beta environment.Here you can see a history of snapshots taken from a production AWS environment. Each snapshot shows:
- Running artifacts: Container images currently running
- Compliance status: Whether they meet policy requirements
- Events: What started or stopped since the last snapshot
- Duration: How long the application has been running
Integrate snapshotting into CI
In This captures what’s running immediately after deployment.
.github/workflows/full-pipeline.yaml, add this step to the Deploy job after the “Deploy to production” step:Create a compliance policy
Create This policy requires:See
.kosli-policy.yml in the root of your repository:- All running artifacts must have been attested to Kosli (provenance)
- All artifacts must have JUnit test results
- All artifacts must have an SBOM
kosli create policy and Policies for more details.Attach the policy to your environment
kosli attach-policy for full flag reference.Push and verify
- Navigate to Environments → labs-prod → latest snapshot
- Check the compliance status — it should be Compliant, since you’ve been attesting unit tests and SBOM since Lab 3
- Click on the running artifact to see which attestations are present
If your artifact is non-compliant
If your artifact is non-compliant
- Verify the attestation names in your workflow match the names in
.kosli-policy.ymlexactly - Check that all attestation steps completed successfully in the previous workflow run
- Confirm the artifact fingerprint matches what was attested
Optional: policy enforcement gate
Optional: policy enforcement gate
You can also use policies as deployment gates, preventing non-compliant artifacts from deploying:If the artifact is non-compliant, this command exits with a non-zero status, failing the deployment step.See
kosli assert artifact for more details.Optional: policy expressions
Optional: policy expressions
Policies support conditional logic for sophisticated compliance rules:See Policy expressions for more.
Verification checklist
-
labs-prodenvironment of typedockercreated - Explored the Cyber-Dojo environment in Kosli
-
.kosli-policy.ymlcreated with compliance requirements - Policy created in Kosli and attached to the environment
- Workflow updated with policy update and snapshot steps
- Workflow runs successfully
- Environment snapshots visible in Kosli
- Running artifact shows as Compliant
Congratulations!
You’ve completed all five Kosli Learning Labs. You now know how to:- Set up Kosli and integrate it with a CI/CD pipeline
- Create Flows and Trails to track your software delivery process
- Attest artifacts and attach evidence (tests, SBOMs, scans)
- Define compliance requirements and gate releases
- Create environments, track what’s running, and enforce policies
Explore further
- Custom attestation types for your specific tools
- Kubernetes environment reporting if you use K8s
- Approvals for production deployment workflows