Created
January 23, 2017 16:02
-
-
Save akira345/d94efcd6eab20fb13603b19066872650 to your computer and use it in GitHub Desktop.
AWS SDK for PHPでCloudFrontのキャッシュパージ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once "aws.phar"; | |
//設定 | |
$access_key = "<ACCESS_KEY>"; | |
$secret_key = "<SECRET_KEY>"; | |
$distribution_id = "<DISTRIBUTION_ID>"; | |
$paths = array("/img/a.png",); | |
$client = new \Aws\CloudFront\CloudFrontClient(array( | |
'region' => 'ap-northeast-1', | |
'credentials' => array( | |
'key' => $access_key, | |
'secret' => $secret_key, | |
), | |
)); | |
$result = $client->createInvalidation(array( | |
// DistributionId is required | |
'DistributionId' => $distribution_id, | |
// Paths is required | |
'Paths' => array( | |
// Quantity is required | |
'Quantity' => count($paths), | |
'Items' => $paths, | |
), | |
// CallerReference is required | |
'CallerReference' => time(), | |
)); | |
$invalidation_id = $result.Id; | |
$result = $client->waitUntilInvalidationComplated(array( | |
// DistributionId is required | |
'DistributionId' => $distribution_id, | |
// Id is required | |
'Id' => $invalidation_id, | |
)); | |
print_r ($result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment