← All articles
Security11 min read

Container Supply Chain Security on Amazon EKS

Base images, SBOMs, signing, and admission controls—closing the gap between build and what runs in the cluster.

If anyone can run any image in your cluster, your cluster inherits every vulnerability and every compromised dependency on the internet. Supply chain security closes the gap between the code you reviewed and the container that actually runs. This guide builds an end-to-end pipeline for Amazon EKS: hardened images, CI without static keys, scanning, SBOMs, signing with AWS KMS, private ECR, and admission control that rejects anything unsigned.

Supply chain pipeline: commit, build, Trivy scan, Syft SBOM, push to ECR, sign and attest with cosign and KMS, deploy through Argo CD, verify with a Kyverno admission policy, and run on Amazon EKS.
Every gate is automated: a failed scan, missing signature, or untrusted registry stops the release.

What you are defending against

  • Known vulnerabilities in base images and language dependencies.
  • Typosquatted or compromised packages pulled during the build.
  • Leaked CI credentials used to push a malicious image to your registry.
  • Images pulled from public registries that change underneath a mutable tag.
  • Over-privileged containers that turn a small bug into a node or account compromise.

1. Start with a minimal, non-root image

Fewer packages mean fewer vulnerabilities and fewer tools for an attacker. Multi-stage builds keep compilers and package managers out of the final image, and distroless or minimal base images ship only what the application needs. Pin the base image by digest so the build is reproducible.

Dockerfiledockerfile
# Build stage
FROM golang:1.23@sha256:<pinned-digest> AS build
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/orders-api ./cmd/api

# Runtime stage: no shell, no package manager, non-root
FROM gcr.io/distroless/static-debian12:nonroot@sha256:<pinned-digest>
COPY --from=build /out/orders-api /orders-api
USER nonroot:nonroot
ENTRYPOINT ["/orders-api"]

2. CI without static AWS keys

Long-lived access keys stored as CI secrets are a favourite target. GitHub Actions can assume an IAM role through OpenID Connect instead, receiving short-lived credentials scoped to one repository and branch. The role only needs permission to push to its own ECR repository and use the signing key.

.github/workflows/build.ymlyaml
name: build
on:
  push:
    branches: [main]

permissions:
  id-token: write # required for OIDC
  contents: read

jobs:
  image:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: arn:aws:iam::111122223333:role/gha-orders-api-push
          aws-region: ap-south-1

      - id: ecr
        uses: aws-actions/amazon-ecr-login@v2

      - name: Build
        run: docker build -t ${{ steps.ecr.outputs.registry }}/orders-api:${{ github.sha }} .

      - name: Scan (fail on fixable HIGH/CRITICAL)
        uses: aquasecurity/trivy-action@0.28.0
        with:
          image-ref: ${{ steps.ecr.outputs.registry }}/orders-api:${{ github.sha }}
          severity: HIGH,CRITICAL
          ignore-unfixed: true
          exit-code: "1"

      - name: Push
        run: docker push ${{ steps.ecr.outputs.registry }}/orders-api:${{ github.sha }}

Restrict the IAM role's trust policy to the exact repository and branch using the token.actions.githubusercontent.com:sub condition, so a pull request from a fork cannot assume it. Pin third-party actions to a release tag or, better, a full commit SHA.

How does your cloud measure up?

Score your setup across foundation, delivery, reliability, security, and cost in 3 minutes—instant results, no email needed.

Take the free scorecard

3. Scan with intent, not just volume

A scanner that fails every build gets disabled within a week. Fail only on high and critical findings that have a fix available, and track the rest. When you must accept a finding, record it in a .trivyignore file with a comment explaining why and an expiry date for review—never as a silent, permanent exception.

4. Generate an SBOM for every image

A software bill of materials lists every package inside an image. When the next widely exploited vulnerability is announced, an SBOM lets you answer which running images are affected in minutes instead of days.

SBOM with Syftbash
syft "$IMAGE@$DIGEST" -o spdx-json > sbom.spdx.json

5. Harden Amazon ECR

Make tags immutable so a pushed version can never be silently replaced, encrypt with KMS, and enable enhanced scanning through Amazon Inspector so images are re-scanned continuously as new vulnerabilities are published—not just once at push time.

ecr.tfhcl
resource "aws_ecr_repository" "orders_api" {
  name                 = "orders-api"
  image_tag_mutability = "IMMUTABLE"

  encryption_configuration {
    encryption_type = "KMS"
  }
}

resource "aws_ecr_registry_scanning_configuration" "this" {
  scan_type = "ENHANCED" # continuous scanning via Amazon Inspector

  rule {
    scan_frequency = "CONTINUOUS_SCAN"
    repository_filter {
      filter      = "*"
      filter_type = "WILDCARD"
    }
  }
}

resource "aws_ecr_lifecycle_policy" "orders_api" {
  repository = aws_ecr_repository.orders_api.name
  policy = jsonencode({
    rules = [{
      rulePriority = 1
      description  = "Expire untagged images after 14 days"
      selection = {
        tagStatus   = "untagged"
        countType   = "sinceImagePushed"
        countUnit   = "days"
        countNumber = 14
      }
      action = { type = "expire" }
    }]
  })
}

6. Sign and attest with cosign and AWS KMS

Signing proves an image came from your pipeline. Keeping the private key in AWS KMS means it never exists on a CI runner or a laptop; the pipeline role is simply granted permission to use it. Always sign the image digest, not a tag. Attaching the SBOM as a signed attestation ties the bill of materials to that exact image.

Sign and attestbash
DIGEST=$(aws ecr describe-images --repository-name orders-api \
  --image-ids imageTag="$GITHUB_SHA" \
  --query 'imageDetails[0].imageDigest' --output text)
IMAGE="$REGISTRY/orders-api@$DIGEST"

cosign sign --key awskms:///alias/cosign-images "$IMAGE"

cosign attest --key awskms:///alias/cosign-images \
  --type spdxjson --predicate sbom.spdx.json "$IMAGE"

# Anyone with the public key can verify
cosign verify --key awskms:///alias/cosign-images "$IMAGE"

7. Enforce at admission on EKS

Signing is only useful if something checks the signature. A Kyverno verifyImages policy runs at admission time: pods whose images come from an unexpected registry, or lack a valid signature from your key, are rejected before they are scheduled.

verify-images.yaml (Kyverno)yaml
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  name: verify-signed-images
spec:
  validationFailureAction: Enforce
  webhookTimeoutSeconds: 30
  rules:
    - name: only-signed-ecr-images
      match:
        any:
          - resources:
              kinds: ["Pod"]
      exclude:
        any:
          - resources:
              namespaces: ["kube-system"]
      verifyImages:
        - imageReferences:
            - "111122223333.dkr.ecr.ap-south-1.amazonaws.com/*"
          mutateDigest: true # rewrite tags to digests
          attestors:
            - entries:
                - keys:
                    kms: "awskms:///arn:aws:kms:ap-south-1:111122223333:alias/cosign-images"

Kyverno needs read access to ECR and permission to call kms:GetPublicKey and kms:Verify, granted through a Pod Identity role on its service account. Add a second rule that denies any image outside your approved registries, so public images cannot bypass verification simply by not matching the first rule.

8. Deploy by digest through GitOps

Tags are pointers that can move; digests cannot. Have the pipeline write the signed digest into your GitOps repository, so Argo CD or Flux deploys exactly what was scanned and signed, and every production change is a reviewed commit.

kustomization.yamlyaml
images:
  - name: orders-api
    newName: 111122223333.dkr.ecr.ap-south-1.amazonaws.com/orders-api
    digest: sha256:<digest-from-pipeline>

9. Limit the blast radius at runtime

Even a verified image can contain an exploitable bug. A restrictive security context limits what an attacker can do from inside the container.

securityContextyaml
securityContext:
  runAsNonRoot: true
  allowPrivilegeEscalation: false
  readOnlyRootFilesystem: true
  capabilities:
    drop: ["ALL"]
  seccompProfile:
    type: RuntimeDefault
  • Give each workload its own Pod Identity role with only the permissions it uses.
  • Apply the restricted Pod Security Standard to application namespaces.
  • Use default-deny NetworkPolicies so a compromised pod cannot reach everything else.
  • Enable GuardDuty EKS runtime monitoring to detect suspicious process and network activity.

A rollout plan that does not break production

  1. Move CI to OIDC and remove stored AWS keys.
  2. Add Trivy scanning in report-only mode, fix base images, then make it blocking.
  3. Make ECR tags immutable and enable enhanced scanning.
  4. Start signing and attaching SBOMs for every new image.
  5. Deploy the Kyverno policy in Audit mode and review what would have been blocked.
  6. Re-sign or rebuild the remaining images, then switch the policy to Enforce—namespace by namespace.

Supply chain controls are boring when they work and career-defining when they do not. If you want this pipeline built and enforced on your EKS clusters, it is part of our Secure Delivery Pipeline and Cloud Posture Hardening modules.

Key takeaways

  • Approved bases, scanning, SBOMs, and admission verification belong together.
  • Sign images and verify signatures before they run.
  • Keep build identity separate from cluster admin identity.

FAQ

Do image scans alone make us safe?

No. Scans without rebuild cadence, admission controls, and runtime policies leave known-bad images runnable.

What should fail a deploy?

Critical vulnerabilities with known fixes on your owned layers, unsigned images, and bases outside the approved list—tuned so teams can remediate quickly.

Need help putting this into practice?

Our engineers do this every week. Get a fixed-scope plan for security hardening module—free scoping call, written price before you commit.

Get a free scoping call