AWS Learning Journey

Shift Left Without Slowing Down: DevSecOps on AWS

SAST, dependency scanning, container and IaC scanning, secret scanning, Amazon Inspector, security gates, SBOMs, artifact signing, policy as code, and a sane vulnerability exception process.

9 min read · 1661 words
DevSecOpsAWSCybersecurityCI/CDSupply Chain Security
Shift Left Without Slowing Down: DevSecOps on AWS cover image

AWS from Zero to Production — Phase 7, Part 4 of 5 · See the full series roadmap


Most security problems that reach production were visible long before.

The vulnerable library was flagged in a public advisory months ago. The public S3 bucket was right there in the Terraform diff. The leaked API key sat in a commit for weeks. Nobody was looking at the right moment.

DevSecOps means making the pipeline look — automatically, on every change — and stopping the dangerous ones before they ship. Done badly, it’s a wall of false positives that teams learn to ignore. Done well, it’s a fast, quiet safety net.

This article covers the tools, where they belong in the pipeline, and how to keep them from grinding delivery to a halt.

What you’ll walk away with


Where security checks fit

Developer laptop    pre-commit hooks: secrets, linting
     |
Pull request        SAST, SCA, IaC scanning, secret scanning
     |
Build               container image scan, SBOM, signing
     |
Deploy              policy checks, signature verification
     |
Runtime             Amazon Inspector, GuardDuty, Security Hub

Shift left means catching issues as early as possible, when they’re cheapest to fix. But keep scanning at runtime too: new vulnerabilities are published every day for code that was clean yesterday.


Static application security testing (SAST)

SAST analyzes your source code for vulnerable patterns: SQL injection, command injection, unsafe deserialization, hard-coded credentials, and weak cryptography.

pip install bandit
bandit -r src/ -ll

Tip: Start with a small, high-confidence rule set and block only on high severity. Expand once the team trusts the results.


Software composition analysis (SCA)

Most of your application is other people’s code. SCA checks your dependencies against vulnerability databases.

pip install pip-audit
pip-audit -r requirements.txt

Dependabot goes further: it opens pull requests to update vulnerable dependencies automatically. Turn on Dependabot alerts and security updates in every repository.

Lock your dependencies. Without lock files or pinned versions, you can’t know what you shipped — or reproduce it.


Container scanning

A container image includes an operating system layer full of packages — each a potential vulnerability.

Reduce findings at the source:


Infrastructure-as-Code scanning

IaC scanners catch misconfigurations before they exist:

Tools: Checkov, Trivy (which absorbed tfsec), KICS, cfn-lint and cfn-guard for CloudFormation, and cdk-nag for CDK.

pip install checkov
checkov -d infra/ --framework terraform

Engineer’s note: IaC scanners flag things like “RDS isn’t Multi-AZ” that may be acceptable in dev. Use inline suppressions with a reason — not blanket skips — so exceptions are visible in code review.


Secret scanning

A leaked credential can be exploited within minutes of being pushed to a public repository.

If a secret leaks: rotate it first, then clean up history. Assume it’s compromised the moment it’s pushed. And the best fix is structural: with OIDC, there are no AWS keys to leak.


Amazon Inspector

Amazon Inspector continuously scans workloads for vulnerabilities and unintended network exposure:

Inspector also offers CI/CD integration: generate an SBOM with the Inspector SBOM generator and scan it through the Inspector Scan API inside your pipeline, before the image is even pushed.


Security gates

A security gate is a pipeline step that fails the build when a check finds something above a threshold.

Good gates are:

aws ecr wait image-scan-complete --repository-name orders --image-id imageTag=$TAG

CRITICAL=$(aws ecr describe-image-scan-findings \
  --repository-name orders --image-id imageTag=$TAG \
  --query 'imageScanFindings.findingSeverityCounts.CRITICAL' --output text)

if [ "$CRITICAL" != "None" ] && [ "$CRITICAL" -gt 0 ]; then
  echo "Blocking deploy: $CRITICAL critical vulnerabilities"
  exit 1
fi

Watch out: A gate that blocks on everything gets bypassed. A gate that blocks on nothing is theater. Start strict on a few things, and tighten over time.


Software bill of materials (SBOM)

An SBOM is an inventory of every component in your software: packages, versions, and licenses.

Generate an SBOM for every build, and store it alongside the artifact.


Artifact signing and provenance

How do you know the image running in production is the one your pipeline built — not something pushed by an attacker with stolen registry credentials?

Sign it.

Then verify before deploying — for example, with an admission controller in Kubernetes, or a verification step in your pipeline.

The SLSA framework describes levels of supply chain integrity, and is a useful roadmap.


Policy as code

Policy as code expresses rules in code that tools enforce automatically:

package main

deny contains msg if {
  some r in input.resource_changes
  r.type == "aws_s3_bucket_public_access_block"
  r.change.after.block_public_acls == false
  msg := sprintf("%s must block public ACLs", [r.address])
}

Policies are reviewed, versioned, and tested — just like application code.


Vulnerability exception processes

Sometimes you can’t fix a finding right now: no patch exists, the vulnerable code path isn’t reachable, or the fix requires a major upgrade.

A healthy exception process has:

Red flag: An exception with no expiry date isn’t an exception. It’s a permanent hole with paperwork.


Putting it together

A practical pipeline for the orders API:

Pull request:
  pytest + bandit (high only) + pip-audit + checkov (infra/) + secret scanning (push protection)

Main branch:
  build image -> push to ECR -> wait for scan -> block on CRITICAL
  generate SBOM -> upload as artifact
  deploy -> smoke test -> roll back on failure

Runtime:
  Amazon Inspector continuous scanning -> Security Hub -> alert on new CRITICAL findings

That’s exactly what you’ll build in Part 5.


Common mistakes


Key takeaways


Quick self-check

Test yourself before moving on:

  1. Which type of scanning finds a vulnerable version of a library you depend on?
  2. A developer pushed an API key an hour ago. What’s the first thing to do?
  3. Why keep scanning images that passed the build-time scan?
  4. What four things should every vulnerability exception have?

Answers

  1. Software composition analysis (SCA).
  2. Rotate (revoke) the key. Then clean up history.
  3. New CVEs are published daily for software that was clean yesterday.
  4. An owner, a justification, an expiry date, and approval — tracked visibly.

What’s next

In Part 5, the Phase 7 lab: one GitHub Actions pipeline that tests, scans, authenticates with OIDC, pushes to ECR, gates on vulnerabilities, deploys to ECS, smoke-tests, and rolls back automatically.

Which security gate has saved your team — or annoyed it the most? Tell me in the comments.


Share this article

LinkedIn post draft