Linux command
aws-cloudfront 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Create a cache invalidation
aws cloudfront create-invalidation --distribution-id [EDFDVBD6EXAMPLE] --paths "/[path/to/file.jpg]" "/[images/*]"
Invalidate all files
aws cloudfront create-invalidation --distribution-id [EDFDVBD6EXAMPLE] --paths "/*"
List all distributions
aws cloudfront list-distributions
Get distribution details
aws cloudfront get-distribution --id [EDFDVBD6EXAMPLE]
Create a distribution
aws cloudfront create-distribution --distribution-config file://[distribution.json]
List invalidations
aws cloudfront list-invalidations --distribution-id [EDFDVBD6EXAMPLE]
Get invalidation status
aws cloudfront get-invalidation --distribution-id [EDFDVBD6EXAMPLE] --id [I2J0I21PCUYOIK]
Wait for a distribution to be deployed
aws cloudfront wait distribution-deployed --id [EDFDVBD6EXAMPLE]
说明
aws cloudfront manages Amazon CloudFront, a content delivery network (CDN) that caches content at edge locations worldwide for low-latency delivery. Invalidations remove cached objects from edge locations before their TTL expires. Paths support wildcards (/images/*) to invalidate multiple files. The first 1,000 invalidation paths per month are free. Distributions define origins (S3, ALB, custom HTTP), cache behaviors, SSL certificates, and other delivery settings. Changes propagate globally and may take 15-30 minutes. Origin Access Control (OAC) secures S3 origins by restricting direct bucket access, requiring requests to go through CloudFront. CloudFront Functions and Lambda@Edge allow running code at edge locations to customize request/response handling. Use quotes around paths with wildcards in shell commands to prevent glob expansion.
参数
- create-invalidation
- Invalidate cached objects in edge locations
- list-invalidations
- List invalidation requests for a distribution
- get-invalidation
- Get status of an invalidation request
- create-distribution
- Create a new CloudFront distribution
- get-distribution
- Get distribution configuration and status
- list-distributions
- List all distributions in the account
- update-distribution
- Modify distribution settings
- delete-distribution
- Remove a distribution (must be disabled first)
- create-origin-access-control
- Create OAC for secure S3 access.
- get-distribution-config
- Get only the distribution configuration (without status metadata).
- create-function
- Create a CloudFront Function for lightweight edge compute.
- sign
- Sign CloudFront URLs or cookies for private content.
- wait
- Wait for a distribution to reach a specific state (e.g., deployed).
- --distribution-id _id_
- Distribution identifier (e.g., EDFDVBD6EXAMPLE)
- --paths _paths_
- Space-separated paths to invalidate (supports wildcards with *)
- --invalidation-batch _json_
- JSON with paths and caller reference
- --distribution-config _json_
- Distribution configuration file
- --id _id_
- Resource identifier (invalidation, distribution)
- --if-match _etag_
- ETag for conditional updates/deletes
FAQ
What is the aws-cloudfront command used for?
aws cloudfront manages Amazon CloudFront, a content delivery network (CDN) that caches content at edge locations worldwide for low-latency delivery. Invalidations remove cached objects from edge locations before their TTL expires. Paths support wildcards (/images/*) to invalidate multiple files. The first 1,000 invalidation paths per month are free. Distributions define origins (S3, ALB, custom HTTP), cache behaviors, SSL certificates, and other delivery settings. Changes propagate globally and may take 15-30 minutes. Origin Access Control (OAC) secures S3 origins by restricting direct bucket access, requiring requests to go through CloudFront. CloudFront Functions and Lambda@Edge allow running code at edge locations to customize request/response handling. Use quotes around paths with wildcards in shell commands to prevent glob expansion.
How do I run a basic aws-cloudfront example?
Run `aws cloudfront create-invalidation --distribution-id [EDFDVBD6EXAMPLE] --paths "/[path/to/file.jpg]" "/[images/*]"` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does create-invalidation do in aws-cloudfront?
Invalidate cached objects in edge locations