AWS PHP SDK Cloudfront Client 'key_pair_id', 'private_key'

0

Hi peeps, is it possible to create a signed GET url for cloudfront link without providing the 'key_pair_id', 'private_key' params?

As suggested in the AWS docs it is considered a bad practice to store the private key / id in .env or in a file locally when hosting a webapp on Amazon EC2. Currently I get an error "key_pair_id is required" when using the client as follows:

    public function getPresignedGetUrl(string $filePath): string {
        $client = new CloudFrontClient([
            'version' => 'latest',
            'region'  => env('AWS_DEFAULT_REGION')
        ]);
        $expiry = time()+(15*60); // 15 minutes x 60 seconds for UNIX timestamp format

        return $client->getSignedUrl([
            'url' => env('CLOUDFRONT_BASE_URL') . '/' . $filePath,
            'expires' => $expiry,
        ]);
    }

Thank you for your advice!

답변 없음

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠