amazon web services - PHP AWS S3 cURL error 6: Could not resolve host
I'm trying to move files across S3 buckets and am getting the following error when running CopyObject.
dev.ERROR: exception 'Aws\S3\Exception\S3Exception' with message 'Error executing "CopyObject" on "https://60_071fbf25-8654-4cef-a184-ecb241c1dfcf_20180115175327.wav"; AWS HTTP error: cURL error 6: Could not resolve host: 60_071fbf25-8654-4cef-a184-ecb241c1dfcf_20180115175327.wav
I can't figure out why the URL in the error message is https://60_071fbf25-8654-4cef-a184-ecb241c1dfcf_20180115175327.wav when it should be https://s3.us-west-2.amazonaws.com/my-bucket-name/60_071fbf25-8654-4cef-a184-ecb241c1dfcf_20180115175327.wav
Here's my code:
$s3 = \Aws\S3\S3Client::factory([
'credentials' => [
'key' => \Config::get('aws.s3_audio_upload.access_id'),
'secret' => \Config::get('aws.s3_audio_upload.access_secret')
],
'region' => 'us-west-2',
'version' => '2006-03-01'
]);
$s3->copyObject([
'Bucket' => 'metapop-hq-repo1',
'CopySource' => 'metapop-inbox/60_071fbf25-8654-4cef-a184-ecb241c1dfcf_20180115175327.wav',
'Key' => '60_071fbf25-8654-4cef-a184-ecb241c1dfcf_20180115175327.wav',
'ACL' => $cannedAcl
]);
Answer
Solution:
Discovered that the environment variables I was using to set the contents of Bucket and the bucket part of CopySource were not set in the daemon job runner I am using. Ensuring that these environment variables were set fixed the problem. :)