Creates a new invalidation request.
Access
public
Parameters
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
|
Required |
The distribution ID returned from |
|
|
|
Required |
A unique identifier for the request. A timestamp-appended string is recommended. |
|
|
|
Required |
One or more paths to set for invalidation. Pass a string for a single value, or an indexed array for multiple values. values. |
|
|
|
Optional |
An associative array of parameters that can have the following keys:
|
Returns
Type |
Description |
|---|---|
|
A |
Examples
Create a new CloudFront invalidation request.
In this example, we don’t know the file path to invalidate, so we’ll invalidate everything in the distribution.
$s3 = new AmazonS3();
$cdn = new AmazonCloudFront();
// Get the information about the distribution.
$distribution_info = $cdn->get_distribution_info('E2L6A3OZHQT5W4');
// Fetch the fully-qualified domain name for the origin bucket.
$origin_bucket_fqdn = (string) $distribution_info->body->DistributionConfig->S3Origin->DNSName;
// Strip the hostname, and only leave the bucket name.
$origin_bucket = substr($origin_bucket_fqdn, 0, -17); // Remove `.s3.amazonaws.com`
// Get the list of files from the S3 bucket.
$file_paths = $s3->get_object_list($origin_bucket);
// Create a new invalidation.
$response = $cdn->create_invalidation('E2L6A3OZHQT5W4', 'aws-php-sdk-test' . time(), $file_paths);
// Success?
var_dump($response->isOK());
Result:
bool(true)
Related Methods
See Also
Source
Method defined in services/cloudfront.class.php | Toggle source view (12 lines) | View on GitHub

