Home› Blog› Week 22 - Container Image Security: A Signature Sa…
AWS Weekly Lab AWS Terraform

A signature says who, not whether

ECR signs every image on push and Inspector scans it for known flaws. Neither stops anything. This week builds the gate that reads the evidence and refuses the image — and finds the case it misses is the normal one.

Verified against current vendor documentation on 9 October 2026. Pricing, limits and API behaviour were checked against the official docs on that date. Cloud services change fast — if you are reading this much later, treat the specifics as a starting point and re-check the linked sources.
AWS Platform Engineering Lab · Week 22 of 52

Lab Overview

Someone on your team ships a new version of an app. It runs. A month later a question comes up in a review: who built that exact image, and did anyone check what was inside it? Most teams cannot answer either.

The problem. AWS has a managed answer to both questions — ECR can sign every image as it arrives, and Amazon Inspector can scan it for known flaws. Both are close to one click. Neither of them stops anything. Signing writes a signature; scanning writes a finding. If nothing reads them and acts, a flawed image is signed, scanned, documented — and still deployable.

The objective. Build the part nobody writes about: the gate that reads the evidence and refuses the image.

The outcome. The managed features worked on the first apply. The gate took five attempts, and the most important failure was one most pipelines would hit on day one.

DifficultyIntermediate
Lab runtimeRan across 6–9 October; duration not recorded
Measured cost$0.2409, 99.7% of it signing
DeploymentTerraform via HCP Terraform with OIDC
Full lab guideGitHub — prerequisites, Terraform, commands, validation, cleanup

Cloud Services and Concepts

ServicePurpose hereWhat it is
Amazon ECRStores the container images, and is where managed signing is switched on by repository filter.A private registry for container images, with per-repository rules such as refusing to overwrite a tag that already exists.
AWS SignerProduces the signature — the provenance record of who built an image.Signs artefacts, such as container images, so a consumer can verify where they came from and that they have not changed.
Amazon InspectorScans images for known vulnerabilities. A separate service with its own bill.Scans workloads and container images for known software vulnerabilities, continuously rather than on request.
EventBridgeCarries the two triggers the gate listens on: scan finished, and image pushed.An event bus. Services and your own code publish events to it, and rules decide which events reach which targets.
AWS LambdaThe gate. The only component here that can stop a deployment.Runs a piece of code on demand with no server to manage. You are billed per request and per millisecond it runs, and each in-flight request occupies one execution environment.
Amazon SNSSends the quarantine notice, and alarms when the gate itself fails.A publish-and-subscribe topic. One message is fanned out to every subscriber — email, a queue, or a function.
AWS CodeBuildBuilds and pushes the images, and therefore triggers signing.Runs build and test commands on AWS-managed machines, billed per build minute.

Basic versus enhanced scanning is not a quality setting. ECR presents them as two settings of one feature. Basic is ECR's own scanner, free, and reads OS packages only. Enhanced hands the work to Inspector at $0.09 per first scan and also reads your language dependencies — the pinned versions in requirements.txt or package-lock.json. You switch it on in the ECR console and the charges appear under a service you never opened.

A signature answers "who", not "whether". Holding that distinction is the whole week.

Architecture and Workflow

aws AWS Cloud Build and registry CodeBuild builds and pushes 1 Amazon ECR immutable tags AWS Signer provenance Amazon Inspector known flaws 2 3 EventBridge scan done, or push the gate allow or refuse 4 A rebuilt image with the same digest raises no scan event, so the gate never runs and the old findings still stand. 5
Signing and scanning both hang off the push. The gate only runs when an event arrives — which is the hole measured in this lab.
  1. CodeBuild builds and pushes an image to an ECR repository.
  2. ECR matches the repository against the signing filter and asks AWS Signer to sign it. The signature records provenance, nothing about content.
  3. Inspector scans the image under enhanced scanning, reading OS packages and language dependencies.
  4. EventBridge carries the result on two separate triggers: Inspector's scan-complete event, and ECR's own image-push event.
  5. A Lambda gate reads the findings and decides. This is the only component that can refuse anything.
  6. A failing image is re-tagged quarantined-*, its deployable tags removed, and an SNS notice sent.

Design decisions

Two triggers, not one. Keying only on "newly scanned" protects only images nobody has pushed before — see Troubleshooting. The ECR push event is the second trigger and it decides from findings Inspector already holds.

Quarantine by re-tagging, never delete. Deleting the image destroys the evidence needed to answer "what shipped, and when did we know".

Scoped by repository filter, not registry-wide. With signing billed per image, a registry-wide rule would sign everything you ever push.

Prerequisites

RequirementDetail
AWS accountPermission for ECR, Signer, Inspector, Lambda, EventBridge, SNS and CodeBuild
Terraform>= 1.10, AWS provider 6.68.0
HCP TerraformWorkspace with OIDC to AWS. No static keys
InspectorEnabled per account, not per stack — this matters at cleanup
Regionus-east-1

One gap you will hit immediately. ECR managed signing shipped in November 2025 and still has no resource in the Terraform AWS provider — the pull request adding it was still open when 6.68.0 shipped on 7 October 2026. Confirm it yourself rather than trusting this page:

terraform validate
# Error: Invalid resource type ... aws_ecr_signing_configuration

Cost warning before you start: Inspector enhanced scanning has a 15-day free trial per account. If yours is already used, this lab costs more than the figure below.

Implementation

Twenty-four resources — and the proportion is the point. Only four of them exist because of signing and scanning: the signing profile, the signing configuration, the Inspector enabler and the scanning configuration. The other twenty are the enforcement nobody writes about.

week-22-container-image-security/
|
+-- terraform/
|   +-- environments/dev/   HCP backend, OIDC, wires the modules
|   +-- modules/registry/   ECR repositories, signing and scanning configuration
|   +-- modules/gate/       the Lambda, its triggers, SNS and the alarm
|   +-- modules/build/      CodeBuild project and its role
|
+-- src/gate/               the only code that enforces anything
|
+-- scripts/                the push-and-check tests
Only the directories that matter. The full repository is on GitHub.

The gate is 164 lines. Everything else is declaration. Two ECR repositories are created: one inside the signing filter, one deliberately outside it as a control, so the tests can show the filter actually filtering.

The build role needs signer:SignPayload as well as the ECR push actions. Without it the push succeeds and the image is simply never signed, with no error anywhere.

The applied HCP Terraform run for week-22-dev showing plus 17 resources and the module resource list
Applied. The builder was added in a later run.

Validation and Evidence

The managed features deploying is not the same as the gate working. Each of these was run against the live pipeline.

TestExpectedActualStatus
Image push is signedValid Signer signatureValid signature attachedPass
Repository outside the filterNot signedNot signedPass
Enhanced scan reads language depsPython findings reported12 Python findings incl. CVE-2023-30861 on Flask, vs 4 OS findingsPass
Signed but vulnerable imageQuarantinedQuarantined on 16 findings despite a valid signaturePass
Re-tagged existing imageEvaluatedNo scan, no event, left deployable with 7 critical findingsFail — fixed, see below
Gate failure behaviourFails closed, alarmsRaised rather than returning allowPass
The Amazon Inspector findings list showing 95 active findings ranked by severity, with every impacted resource already carrying a quarantined tag
Ninety-five findings — and every impacted resource is already a quarantined-* image.
The quarantine notification email showing the repository, image digest, tags removed, the new quarantined tag and the finding severity counts
The notice for exactly that case — an image caught only by the push event.
A card listing the six tests with pass and fail markers, the Python versus OS finding split, and the five defects the tests found
Signing and scanning were correct on the first apply. The enforcement took five attempts.

Security and Cost

Security

Immutable tags. With mutable tags an image approved as v1.2.3 can be quietly repointed after review, and the signature and scan result then describe something that is no longer there.

The gate quarantines, never deletes. Only the deployable tags go. Deleting the image would destroy the evidence needed to answer "what shipped, and when did we know".

It fails closed, and alarms on its own errors. Observed for real: when the gate broke it raised rather than returning an allow.

Least privilege, with a silent failure mode. The build role needs signer:SignPayload alongside the ECR push actions. Without it the push succeeds and the image is never signed — no error anywhere.

The signing key is not yours. A Signer profile takes a platform, a validity period and tags, and no key of any kind. For container signing AWS generates and holds the key material; you control who may ask it to sign. That is a trust decision, not an absence of one.

Cost

Billed $0.2409, read by usage type — grouping by service only ever says "ECR".

LineCostShare
ECR managed signing — 12 signatures at $0.02$0.240099.7%
ECR storage$0.00090.3%
Amazon Inspector$0.0015-day free trial
CodeBuild, Lambda, EventBridge, SNS$0.00free tier
Cost Explorer output grouped by usage type, showing USE1-AsyncActions-ImageSigning at 0.2400 dollars for 12 signatures against 0.0009 dollars of storage, totalling 0.2409, with Amazon Inspector and CodeBuild both at zero
Signing was 99.7% of it. Read by usage type, because grouping by service only ever says "ECR".

I wrote, before the bill arrived, that signing was free. AWS Signer is free with ECR — its pricing page says so. The charge is on ECR's side, as AsyncActions-ImageSigning at $0.02 per signature, and ECR's pricing page carries a "Managed Signing" heading with no figure under it. The bill was the only place that number appeared.

Twelve signatures, not three, because every rebuild re-signs. Four builds during one night of debugging cost four times a single build. On a busy pipeline that is the line to watch — not storage, which came to nine hundredths of a cent.

Two controls matter more than the rates. Scope scanning and signing by repository filter rather than registry-wide, and expire untagged images with a lifecycle policy — under continuous scanning every retained image is rescanned whenever the vulnerability database updates.

Troubleshooting and Lessons

The gate missed the case that matters most

Problem. An image rebuilt byte-identically sat deployable with seven critical findings.
Root cause. Inspector emits its scan-complete event only the first time it sees a digest. The rebuild attached a new tag to content Inspector already knew, so there was no new scan, no event, and no evaluation. Deleting the image from ECR first did not help; Inspector still remembered.
Resolution. A second trigger on ECR's own push event, deciding from findings Inspector already holds.
Lesson. This is not an edge case. Promoting an image by re-tagging it — v1.2.3 becomes prod — is how images normally reach production, and it pushes no new bytes. A gate keyed on first scans protects only images nobody has pushed before.

A valid signature on an image we refused to deploy

Problem. The headline test quarantined an image carrying a complete, valid AWS Signer signature.
Root cause. Working as intended — 16 findings, of which 12 were Python package findings including CVE-2023-30861 on Flask, against 4 OS findings. Basic scanning would have reported the four and stopped.
Resolution. None needed; this is the demonstration.
Lesson. A signature tells you who built an image and nothing about whether it is safe to run. Those are different questions, and only one is answered by the feature with "signing" in the name.

Terraform has no resource for ECR managed signing

Problem. terraform validate rejects the signing configuration outright.
Root cause. The feature shipped in November 2025; the provider pull request was still open when 6.68.0 shipped on 7 October 2026.
Resolution. Create it outside Terraform and document the gap, rather than pretending the stack is complete.
Lesson. "Managed" does not imply "declarable". Check provider coverage before designing around a new feature.

Cleanup and Key Takeaways

Inspector is enabled per account, not per stack, so it is worth being explicit about who removes it. Here the enabler and the registry scanning configuration are Terraform resources and terraform destroy did remove both — the teardown script found scanning already back to BASIC and all five Inspector scan types already DISABLED.

The script still checks, and still disables them if it finds them on. That is not superstition: in an earlier week a CloudWatch anomaly detector survived a destroy and kept billing for days, because nothing in the state file owned it. Account-level settings are the category where "the destroy probably handled it" is worth converting into a command that looks.

Terminal output showing the destroy run applying 24 resources, then the cleanup script reporting scanning back to BASIC, all five Inspector scan types disabled, and no repositories, signing profiles, signing configuration or log groups remaining
Twenty-four resources destroyed, then checked. Every line is something that could have been left running.

The script also cancels the signing profile. Signer profiles cannot be deleted, only cancelled — the documented end state rather than a leftover.

Key takeaways

  • A signature says who, not whether. A valid signature on a vulnerable image is the most comfortable false assurance in this area.
  • Signing and scanning stop nothing. They produce evidence. Something has to read it and act, and that something is yours to build and yours to get wrong.
  • Enforcement keyed on "newly scanned" misses the normal case. Promoting an existing image pushes no new bytes and triggers no scan.
  • Signing is billed per signature and the rate is not on the pricing page. $0.02 each, 99.7% of this week's bill, and every rebuild re-signs.
  • Test the enforcement, not the features. The managed parts worked on the first apply; the part that actually stops a bad image took five attempts, and every fault was found by a test rather than by reading the code.

References

Comments

How was your experience?
Your feedback helps improve this site.
PoorExcellent