dcg

AWS CloudFront

cdn.cloudfront

Protects against destructive AWS CloudFront operations like deleting distributions, cache policies, and functions.

  • 7blocking rules
  • 12safe patterns
  • 2Critical
  • 4High
  • 1Medium
~/.config/dcg/config.toml
[packs]
enabled = ["cdn.cloudfront"]

Evaluated when a command contains cloudfront.

Blocking rules

Each rule ID is cdn.cloudfront:<name>. Use it in allowlists and [policy.rules].

  1. cloudfront-delete-distribution

    Critical

    aws cloudfront delete-distribution removes a CloudFront distribution.

    Explanation
    Deleting a CloudFront distribution removes your CDN endpoint. All traffic to the distribution URL will fail. You must first disable the distribution and wait for propagation. Associated origins, behaviors, and cache settings are lost. Safer alternatives: - aws cloudfront get-distribution: Review configuration first - Disable the distribution before deleting - Export the distribution config for backup
  2. cloudfront-delete-key-group

    Critical

    aws cloudfront delete-key-group removes a key group used for signed URLs.

    Explanation
    Deleting a key group breaks signed URL and signed cookie validation. Users with existing signed URLs will lose access to protected content. Any distributions using this key group for restricted content will deny all requests. Safer alternatives: - Rotate keys by adding new keys before removing old ones - Verify no distributions reference this key group - Update applications to use new signing keys first
  3. cloudfront-delete-cache-policy

    High

    aws cloudfront delete-cache-policy removes a cache policy.

    Explanation
    Deleting a cache policy fails if any distribution behaviors reference it. If deletion succeeds, any caching optimizations you configured are lost. Custom TTLs, cache keys, and compression settings must be recreated. Safer alternatives: - aws cloudfront get-cache-policy: Review policy settings first - Check which distributions use this policy - Create a replacement policy before deleting
  4. cloudfront-delete-function

    High

    aws cloudfront delete-function removes a CloudFront function.

    Explanation
    Deleting a CloudFront Function removes edge compute logic. Any distributions using this function will lose URL rewriting, header manipulation, or other transformations. Function code is not recoverable after deletion. Safer alternatives: - aws cloudfront get-function: Download function code first - Remove function associations from distributions first - Test replacements before deleting the original
  5. cloudfront-delete-origin-request-policy

    High

    aws cloudfront delete-origin-request-policy removes an origin request policy.

    Explanation
    Deleting an origin request policy removes header, query string, and cookie forwarding configuration. Origins may receive different requests than expected, potentially breaking authentication or content negotiation. Safer alternatives: - aws cloudfront get-origin-request-policy: Review settings first - Verify no distributions reference this policy - Create replacement before deletion
  6. cloudfront-delete-response-headers-policy

    High

    aws cloudfront delete-response-headers-policy removes a response headers policy.

    Explanation
    Deleting a response headers policy removes security headers like CORS, Content-Security-Policy, and HSTS settings. Browsers may block cross-origin requests or report security warnings after deletion. Safer alternatives: - Review which distributions use this policy - Test your site without these headers in staging - Create a replacement policy before deleting
  7. cloudfront-create-invalidation

    Medium

    aws cloudfront create-invalidation creates a cache invalidation (has cost implications).

    Explanation
    Cache invalidations have cost implications after the first 1,000 paths per month. Wildcard invalidations (/*) count as one path but clear the entire cache, causing origin load spikes. Frequent invalidations defeat CDN benefits. Safer alternatives: - Use versioned URLs (file.v2.js) instead of invalidation - Invalidate specific paths rather than wildcards - Set appropriate Cache-Control headers at the origin

Safe patterns

Checked first. A command that matches one is never blocked by this pack.

  • cloudfront-list-distributions
  • cloudfront-list-cache-policies
  • cloudfront-list-origin-request-policies
  • cloudfront-list-functions
  • cloudfront-list-invalidations
  • cloudfront-get-distribution
  • cloudfront-get-distribution-config
  • cloudfront-get-cache-policy
  • cloudfront-get-origin-request-policy
  • cloudfront-get-function
  • cloudfront-get-invalidation
  • cloudfront-describe-function