Creates an Amazon CloudFront distribution. You can have up to 100 distributions in the Amazon CloudFront system.
For an Adobe Real-Time Messaging Protocol (RTMP) streaming distribution, set the Streaming option
to true.
Access
public
Parameters
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
|
Required |
The source to use for the Amazon CloudFront distribution. Use an Amazon S3 bucket name, or a fully-qualified non-S3 domain name prefixed with |
|
|
|
Required |
A unique identifier for the request. A timestamp-appended string is recommended. |
|
|
|
Optional |
An associative array of parameters that can have the following keys:
|
Returns
Type |
Description |
|---|---|
|
A |
Examples
Create a new CloudFront distribution with logging and CNAMEs enabled.
// Create a new CloudFront distribution from an S3 bucket.
$cdn = new AmazonCloudFront();
$response = $cdn->create_distribution(''my-bucket'', 'AWSPHPSDKCFDemo01', array(
'Enabled' => true,
'Comment' => 'This is my sample comment',
'CNAME' => array(
'cname-php-10.example.com',
'cname-php-20.example.com'
),
'Logging' => array(
'Bucket' => 'my-bucket-logs',
'Prefix' => 'log_'
)
));
// Success?
var_dump($response->isOK());
Result:
bool(true)
Create a new streaming CloudFront distribution with logging and CNAMEs enabled.
// Create a new CloudFront distribution from an S3 bucket.
$cdn = new AmazonCloudFront();
$response = $cdn->create_distribution('my-bucket', 'php1' . time(), array(
'Enabled' => true,
'Comment' => 'This is my sample comment',
'CNAME' => 'cname-php-3.example.com',
'Logging' => array(
'Bucket' => 'my-bucket-logs',
'Prefix' => 'log_',
),
'RequiredProtocols' => 'https',
'Streaming' => true,
'OriginAccessIdentity' => 'E3HV63EQPFPPOA',
'TrustedSigners' => array(
'Self',
'178280267275',
),
'CachingBehavior' => array(
'MinTTL' => '30 minutes',
),
));
// Success?
var_dump($response->isOK());
Result:
bool(true)
Create a new CloudFront distribution from a non-S3 origin.
// Create a new CloudFront distribution from an S3 bucket.
$cdn = new AmazonCloudFront();
$response = $cdn->create_distribution('http://'www.example.com'', 'php2' . time(), array(
'Enabled' => true,
'Comment' => 'This is my sample comment',
'OriginProtocolPolicy' => 'match-viewer',
'CNAME' => array(
'cname-php-4.example.com',
'cname-php-5.example.com'
),
'Logging' => array(
'Bucket' => 'my-bucket-logs',
'Prefix' => 'nonS3_'
)
));
// Success?
var_dump($response->isOK());
Result:
bool(true)
Related Methods
See Also
Source
Method defined in services/cloudfront.class.php | Toggle source view (11 lines) | View on GitHub

