Platform Engineering · Lesson 163

Zero-Trust Cloud Architecture: Identity, Device, and Every Request Verified

Zero trust drops the idea that being inside the network makes you trustworthy. Every request, from a person or a workload, is authenticated, authorised for that specific resource, and evaluated in context (who, from which device, how risky, for what), every time, with the least access that does the job. NIST SP 800-207 describes it as policy decision and enforcement points in front of every resource. This lesson follows one engineer and one service reaching a production database, and shows the two failures zero trust exists to stop: a VPN that let a stolen laptop reach everything, and a flat network where one compromised service could talk to all the others.

Difficulty: Master · Know this first: Lesson 162, Lesson 152

What you will learn

By the end of this lesson you can work at four levels:

This page teaches it with a plain-language analogy, an animated diagram with normal and failure scenarios, a simulator, a quiz, basic, intermediate, advanced, and master checks, the expert detail ("Go deeper"), a production incident, a hands-on lab with commands and their output, and a production design exercise.

Run it as:

When it breaks, I check

One thing to remember

Where the time goes

This bar adds up minutes from an access request to access, including approval. It is a worked example, not a measurement. The policy decision and service-to-service hops are where implicit trust does its damage.

Try it: what can a stolen credential reach?

Pick how people get remote access, how services trust each other, and how admin rights are held. The readouts show what one stolen laptop or one compromised service can reach.

1 app, 1 ha stolen laptop reaches
its own callsa compromised service reaches

Check yourself

Three questions. No score is saved anywhere — this is just you against the material.

Basic to master

Zero trust grows in four levels: reading access decisions, removing implicit trust for people, then for workloads, and running it as a programme.

Basic — Read access decisions

At the basic level you can explain why a request was allowed or denied.

  • Identity, device posture, context, and the resource's policy.
  • Policy decision point and policy enforcement point (NIST SP 800-207).
  • Sign-in and access logs.

Where it breaks: "it is on the internal network, so it is fine".

Try it: Basic

An admin console allows any request from an internal IP. Is that zero trust?

Now do it: Find one internal service that trusts by IP.

Intermediate — People: proxies and phishing-resistant MFA

At the intermediate level people reach applications, not networks.

  • Phishing-resistant MFA for everyone; device compliance for sensitive apps.
  • An identity-aware proxy per application instead of a VPN for most access.
  • Just-in-time privileged access with approval and session recording.

Try it: Intermediate

Which MFA resists phishing?

Now do it: Register a passkey for your work account.

Advanced — Workloads: identity and authorisation

At the advanced level services trust identities and policies, not networks.

  • SPIFFE or mesh identities; strict mTLS; default-deny authorization policies.
  • Workload identity to cloud APIs and databases; no shared static secrets.
  • Default-deny network policies as a backstop.

Try it: Advanced

How do you roll out default-deny authorization in a busy mesh without an outage?

Now do it: Export one namespace's call graph.

Master — A zero-trust programme

At the master level zero trust is a measured programme across people, devices, workloads, networks, and data.

  • A maturity model (for example CISA's Zero Trust Maturity Model) to plan and report progress.
  • VPN retired for most use; standing privilege close to zero; every service under policy.
  • Continuous signals feeding policy: risk-based re-authentication, fast session revocation.

Trade-off: more checks add friction and dependencies (the IdP, the proxy, the mesh) that need their own reliability and break-glass paths.

Try it: Master

The identity provider is down. What keeps critical operations possible?

Now do it: Review your break-glass procedure.

Go deeper

Default-deny with one allowed call path in Istio: only the checkout service account may call payments' charge endpoint. Run new policies in a test namespace first (and check the Istio version's API).

apiVersion: security.istio.io/v1
kind: PeerAuthentication
metadata: {name: default, namespace: payments}
spec: {mtls: {mode: STRICT}}               # only mTLS traffic is accepted
---
apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata: {name: allow-nothing, namespace: payments}
spec: {}                                   # an empty policy in a namespace denies everything
---
apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata: {name: checkout-can-charge, namespace: payments}
spec:
  selector: {matchLabels: {app: payments-api}}
  action: ALLOW
  rules:
  - from: [{source: {principals: ["cluster.local/ns/checkout/sa/checkout"]}}]
    to:   [{operation: {methods: ["POST"], paths: ["/charge"]}}]

The building blocks on each cloud:

One time it broke

This is a composite of a failure pattern that keeps repeating; the details are illustrative. The laptop that was trusted for where it connected.

Timeline

  • Day 0, 19:00A laptop is stolen from a car. Its VPN client has saved credentials and push MFA that was approved earlier in the day.
  • Day 0, 23:30The thief connects to the VPN. Internal admin consoles allow access from the corporate range without another login.
  • Day 1–2From a console, the thief finds a shared database password in the internal wiki and copies customer records in small batches.
  • Day 3, 07:30An alert on unusual query volume fires. Sessions are revoked, the password rotated, the VPN account disabled; incident response and notification follow.

What changed after

Remote access moved to an identity-aware proxy with device checks and passkeys, admin consoles require their own authentication and just-in-time roles, database access uses identity-mapped roles, and the VPN remains only for a few legacy systems behind the proxy.

Try it yourself, from scratch

Everything here runs on any Linux machine: your own laptop, WSL on Windows (run wsl --install in PowerShell once), or a small cloud VM. The Python needs only Python 3 and its standard library; check that you have it with python3 --version.

Before you start: Linux with OpenSSL (installed on most distributions) and Python 3. Everything runs on your machine.

1. Linux commands

Type each one, read what it prints, and compare it with the note above it.

  1. Make a tiny certificate authority and certificates for two services, the way a mesh does for every workload.

    mkdir -p ~/labs/zt && cd ~/labs/zt
    openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes -keyout ca.key -out ca.crt -days 1 -subj "/CN=lab-ca" 2>/dev/null
    for svc in payments checkout; do
      openssl req -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes -keyout $svc.key -out $svc.csr -subj "/CN=$svc" 2>/dev/null
      openssl x509 -req -in $svc.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out $svc.crt -days 1 2>/dev/null
    done
    ls *.crt

    Options: -days 1: short-lived, like workload certificates; -nodes leaves the lab keys unencrypted.

    Expect: ca.crt checkout.crt payments.crt.

    Clean up: rm -rf ~/labs/zt.

  2. Start payments as a server that requires a client certificate from the lab CA.

    openssl s_server -accept 8443 -cert payments.crt -key payments.key -CAfile ca.crt -Verify 1 -www >server.log 2>&1 &
    sleep 1

    Options: -Verify 1 makes the client certificate mandatory; -www answers with a status page.

    Expect: Nothing printed; the server runs in the background. Stop it later with kill %1.

  3. Call it without a certificate (refused), then as checkout (accepted).

    echo | openssl s_client -connect localhost:8443 -CAfile ca.crt 2>&1 | grep -E "alert|Verify return code" | head -2
    echo "GET / HTTP/1.0
    " | openssl s_client -connect localhost:8443 -CAfile ca.crt -cert checkout.crt -key checkout.key -quiet 2>/dev/null | grep -m1 "Client certificate"
    kill %1

    Expect: The first call ends with a handshake alert (no certificate). The second gets the status page, which names the client certificate: authenticated. Deciding whether checkout may call this endpoint is the authorisation step the next part adds.

2. Python: pdp.py

This program is a small policy decision point. It decides people's requests on identity, MFA strength, device posture, and an approved just-in-time grant, never on network location, and decides service calls on the caller's workload identity against default-deny allow rules. The same requests are also judged the old way, by network location, for comparison. Save it as pdp.py, then run it.

# pdp.py
GRANTS = {("asha", "orders-db:read"): "until 15:00"}          # just-in-time, approved
SERVICE_ALLOW = {("spiffe://prod/ns/checkout/sa/checkout", "payments", "POST /charge")}

def decide_user(user, mfa, device_ok, resource, from_internal_ip):
    old = "ALLOW" if from_internal_ip else "DENY"
    if mfa != "passkey":
        new = "DENY: phishing-resistant MFA required"
    elif not device_ok:
        new = "DENY: device not compliant"
    elif (user, resource) not in GRANTS:
        new = "DENY: no just-in-time grant"
    else:
        new = f"ALLOW {GRANTS[(user, resource)]}"
    return old, new

def decide_service(caller, service, call, same_cluster):
    old = "ALLOW" if same_cluster else "DENY"
    new = "ALLOW" if (caller, service, call) in SERVICE_ALLOW else "DENY: no policy allows it"
    return old, new

people = [
    ("asha, on call, managed laptop", "asha", "passkey", True, "orders-db:read", False),
    ("stolen laptop on the VPN", "ravi", "push", True, "orders-db:read", True),
    ("asha, personal tablet", "asha", "passkey", False, "orders-db:read", False),
]
print(f"{'request':<38} {'by network location':<22} zero trust")
for label, *args in people:
    old, new = decide_user(*args)
    print(f"{label:<38} {old:<22} {new}")
services = [
    ("checkout -> payments POST /charge", "spiffe://prod/ns/checkout/sa/checkout", "payments", "POST /charge"),
    ("image-resize -> payments POST /charge", "spiffe://prod/ns/media/sa/image-resize", "payments", "POST /charge"),
    ("image-resize -> users GET /sessions", "spiffe://prod/ns/media/sa/image-resize", "users", "GET /sessions"),
]
for label, caller, service, call in services:
    old, new = decide_service(caller, service, call, True)
    print(f"{label:<38} {old:<22} {new}")

Run it, and you should see this output:

$ python3 pdp.py
request                                by network location    zero trust
asha, on call, managed laptop          DENY                   ALLOW until 15:00
stolen laptop on the VPN               ALLOW                  DENY: phishing-resistant MFA required
asha, personal tablet                  DENY                   DENY: device not compliant
checkout -> payments POST /charge      ALLOW                  ALLOW
image-resize -> payments POST /charge  ALLOW                  DENY: no policy allows it
image-resize -> users GET /sessions    ALLOW                  DENY: no policy allows it

3. What to notice

4. Advanced: every step as one Bash script

The same Linux steps, made into a real script you can keep and run again. It uses the Bash features a production script needs: functions (one per step), an array of step names, arguments to choose steps, a case for options, exit codes recorded for each step, and a trap that prints a summary even when you stop it with Ctrl+C. Make a folder for this lesson (mkdir -p ~/labs/zero-trust-cloud-architecture && cd ~/labs/zero-trust-cloud-architecture) and save this as lab.sh.

#!/usr/bin/env bash
# The Linux steps of "Zero-Trust Cloud Architecture: Identity, Device, and Every Request Verified", as one script (save it as lab.sh).
#
#   ./lab.sh          run every step, in order
#   ./lab.sh 2 4      run only steps 2 and 4
#   ./lab.sh --list   list the steps
#
# The steps share one shell, so a later step can use what an earlier one set up (a folder,
# a variable, a container): run them all in order the first time. Your own scripts should
# start with "set -euo pipefail"; this one runs teaching commands, and some of them fail on
# purpose, so it records each step's exit code instead of stopping at the first failure.

STEPS=(
  'Make a tiny certificate authority and certificates for two services, the way a mesh does for every workload.'
  'Start payments as a server that requires a client certificate from the lab CA.'
  'Call it without a certificate (refused), then as checkout (accepted).'
)

step_1() {
mkdir -p ~/labs/zt && cd ~/labs/zt
openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes -keyout ca.key -out ca.crt -days 1 -subj "/CN=lab-ca" 2>/dev/null
for svc in payments checkout; do
  openssl req -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes -keyout $svc.key -out $svc.csr -subj "/CN=$svc" 2>/dev/null
  openssl x509 -req -in $svc.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out $svc.crt -days 1 2>/dev/null
done
ls *.crt
}

step_2() {
openssl s_server -accept 8443 -cert payments.crt -key payments.key -CAfile ca.crt -Verify 1 -www >server.log 2>&1 &
sleep 1
}

step_3() {
echo | openssl s_client -connect localhost:8443 -CAfile ca.crt 2>&1 | grep -E "alert|Verify return code" | head -2
echo "GET / HTTP/1.0
" | openssl s_client -connect localhost:8443 -CAfile ca.crt -cert checkout.crt -key checkout.key -quiet 2>/dev/null | grep -m1 "Client certificate"
kill %1
}

# print a step that has to be run by hand, instead of running it
by_hand() {
  echo "  (run this one yourself: $1)"
  sed 's/^/    /'
}

RESULTS=()
run_step() {
  local n=$1 start=$SECONDS code
  printf '\n== step %d of %d: %s\n' "$n" "${#STEPS[@]}" "${STEPS[n-1]}"
  "step_$n"
  code=$?
  RESULTS+=("step $n: exit code $code, $((SECONDS - start)) s")
}

summary() {
  echo
  echo "== summary"
  local r
  for r in "${RESULTS[@]}"; do echo "  $r"; done
}

case "${1:-}" in
  -h|--help) sed -n '2,6p' "$0"; exit 0 ;;
  --list) for i in "${!STEPS[@]}"; do echo "$((i + 1)). ${STEPS[i]}"; done; exit 0 ;;
esac

[ $# -eq 0 ] && set -- $(seq 1 "${#STEPS[@]}")
for n in "$@"; do
  if ! [[ $n =~ ^[0-9]+$ ]] || (( n < 1 || n > ${#STEPS[@]} )); then
    echo "there is no step '$n'; try --list" >&2
    exit 2
  fi
done
trap summary EXIT
trap 'echo; echo "stopped with Ctrl+C"; exit 130' INT
for n in "$@"; do run_step "$n"; done

Then make it executable and run it:

chmod +x lab.sh
./lab.sh --list     # the steps
./lab.sh            # every step, then a summary of exit codes and times
./lab.sh 2 3        # only steps 2 and 3

5. Learn the basics behind it

New to a feature used above? These W3Schools pages explain each one from zero, with examples you can run in the browser.

If you remember nothing else

Design exercise

A company runs 120 services on Kubernetes in two clouds, with a VPN for all staff access and shared database passwords. Design its move to zero trust.

Clarifying questions to ask

How do people reach applications and infrastructure? How are devices checked? How do services authenticate and authorise each other? How do services and people reach data? What is monitored, and how fast can access be revoked? In what order, without breaking production?

Rough sizing

Say 1,500 staff, 120 services, 2 clouds, 30 databases, 40 people with admin rights today, and 6 months.

Shape of the answer

Passkeys for all staff and device compliance from the MDM; an identity-aware proxy (or the clouds' equivalents) for internal apps and Teleport-style access for infrastructure, with just-in-time admin approved and recorded; SPIFFE identities through the mesh in both clouds, strict mTLS, and default-deny authorization rolled out namespace by namespace from observed call graphs; workload identity to databases and cloud APIs, shared passwords removed; default-deny network policies as backstop; sign-in risk, new call paths, and data volume alerts; the VPN kept only for legacy systems; progress tracked against the CISA maturity model.

Trade-offs to name

More checks add friction and new critical dependencies (IdP, proxy, mesh) that need their own SLOs and break-glass; default-deny can break undocumented calls, so observe first; device checks exclude personal devices from sensitive apps by design.

Failure modes and how to troubleshoot them

Each row is one way this system went wrong in the diagram's scenarios. The hop number is where to look first.

ScenarioWhereEffectWhat goes wrong
VPN = trustedHop 3: Policy decisionBreaksAccess is a VPN: a valid VPN login puts the device on the internal network, and internal systems trust internal addresses. A laptop is stolen from a car with the VPN credentials saved.
Flat service networkHop 6: Service to serviceBreaksmTLS is on in permissive mode and no authorization policies exist, so any pod may call any service. An image-resize service with a vulnerable library is compromised through an uploaded file.

How to troubleshoot

  1. Write down the symptom and when it started: what users see, which number moved, and what changed just before (a deploy, a config change, traffic).
  2. Walk the path in order, from the first hop to the last: User identity → Device → Policy decision → Access proxy → Workload identity → Service to service → Micro-segmentation → Data layer → Monitoring. The first hop whose evidence is wrong is where to dig.
  3. At that hop, run the read-only check from the diagram or the lab first; change nothing until the evidence points at a cause.
  4. Fix the smallest thing that restores service, or roll back the last change, and confirm the symptom is gone with the same check.
  5. Write down what you found and the check that would have caught it sooner, so the next person starts there.

Architecture review checklist

Review the design in this lesson, or your own, against these ten areas. Tick an area when you can answer its question with evidence: a number, a test, a document, or an owner. Your ticks stay in this browser.

  1. Business outcomeWhich result for users or the business does this design serve, and which number shows it is working?
  2. SecurityWho and what can reach each part, how is identity proven, and how is data protected in transit and at rest?
  3. ReliabilityWhat is the target (SLO), which single failures does the design survive, and how was that tested?
  4. PerformanceWhat latency and throughput are required at peak, and where is the first bottleneck?
  5. OperationsHow is it deployed, observed, and changed safely, and who is paged when it breaks?
  6. CostWhat does it cost per month and per unit of work (request, tenant, model call), and what grows the bill?
  7. SustainabilityWhich resources sit idle, which region and hardware does it run on, and what can scale to zero?
  8. GovernanceWhich policies, guardrails, and compliance rules apply, and how are they enforced in code?
  9. OwnershipWhich team owns each component, its budget, and its on-call, and where is that written down?
  10. Failure and recovery planWhat is the RTO and RPO, what is the runbook for a region or dependency loss, and when was it last rehearsed?

References and review

The official documentation and standards behind this lesson. Versions and defaults change; when a command or field here differs from them, trust the official page.

Last updated . Next review due by November 2027. Found something out of date? Tell me.

Saved on this device, in this browser.
Next in this series · Lesson 164
Cloud Migrations: Discovery, the 7 Rs, Waves, and Cutover

Moving hundreds of applications to the cloud is a programme, not a lift. It starts with discovery (what runs, what it talks to, who owns it), chooses a strategy per application from the 7 Rs (retire, retain, rehost, relocate…

Go to Lesson 164 →

Or browse the full course from the Lessons index.