亚马逊Cloudfront错误

亚马逊Cloudfront错误

本文介绍了亚马逊Cloudfront错误“ AccessDenied”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我收到拒绝访问消息的代码。有人告诉我如何解决这个问题。

This is my code i am getting Access Denied message. Anyone tell me how to fix this.

cloudfront:用户/ CloudFront原始访问身份[ID]与s3。

"cloudfront:user/CloudFront Origin Access Identity [ID]" with s3.

资源: arn:aws:s3 :::: bucket_name / *


"Resource": "arn:aws:s3:::bucket_name/*"

use Aws\CloudFront\CloudFrontClient;
require 'vendor/autoload.php';

$cloudFront = CloudFrontClient::factory([
    'version' => 'latest',
    'region'  => 'ap-south-1'
]);

// Setup parameter values for the resource
$streamHostUrl = 'http://example.cloudfront.net';
$resourceKey = 'Bucket/1.jpg';
$expires = new DateTime('+1 minute');

// Create a signed URL for the resource using the canned policy
$url = $cloudFront->getSignedUrl([
    'url'         => $streamHostUrl . '/' . $resourceKey,
    'expires'     => $expires->getTimestamp(),
    'private_key' => 'pk-private_key.pem',
    'key_pair_id' => '<key_pair_id>'
]);

echo $url;





<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>EE8B43497F516AD3</RequestId>
<HostId>
jghWRjO1Rnvv0/hRaeBS4pThCFJcGN26r3wDcMAiyqWeVHRVLbNaSUiIQmR7dDiQus/j8QjUWhM=
</HostId>
</Error>


推荐答案

我正在解决此问题

$ resourceKey ='Bucket / 1.jpg '

$resourceKey = 'Bucket/1.jpg'

$ resourceKey ='1.jpg';

$resourceKey = '1.jpg';

这篇关于亚马逊Cloudfront错误“ AccessDenied”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 20:45