Skip to content
Latchkey

AWS CloudFront "TooManyInvalidationsInProgress" in CI

CloudFront capped concurrent invalidations: "TooManyInvalidationsInProgress" means the distribution already has the maximum in-progress invalidations (15) and refuses another until some complete.

What this error means

aws cloudfront create-invalidation fails with "An error occurred (TooManyInvalidationsInProgress) when calling the CreateInvalidation operation". It happens when many deploys or per-file invalidations run close together.

aws-cli
An error occurred (TooManyInvalidationsInProgress) when calling the CreateInvalidation
operation: Your request contains more invalidations in progress than are allowed per distribution.

Common causes

Per-file invalidations flood the queue

Invalidating each changed file as its own request quickly reaches the 15 in-progress limit on a busy deploy.

Overlapping deploys each invalidate

Concurrent pipelines or a rerun stack multiple invalidations on the same distribution at once.

How to fix it

Invalidate with a single wildcard path

  1. Replace many per-file invalidations with one wildcard invalidation.
  2. Use "/*" for a full purge or a prefix like "/assets/*" for a subtree.
  3. Wait for it to complete before starting another.
Terminal
aws cloudfront create-invalidation \
  --distribution-id "$DISTRIBUTION_ID" \
  --paths "/*"

Serialize deploys to one distribution

Use a concurrency gate so only one deploy invalidates the distribution at a time.

.github/workflows/ci.yml
concurrency:
  group: deploy-${{ github.ref }}
  cancel-in-progress: false

How to prevent it

  • Prefer one wildcard invalidation over many per-file calls.
  • Gate deploys to a distribution with a concurrency group.
  • Poll GetInvalidation so overlapping runs do not stack.

Frequently asked questions

What causes "CloudFront "TooManyInvalidationsInProgress""?
Invalidating each changed file as its own request quickly reaches the 15 in-progress limit on a busy deploy.
How do I fix CloudFront "TooManyInvalidationsInProgress"?
Invalidate with a single wildcard path

Related guides

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card