awslabs / aws-crt-php

Apache License 2.0
322 stars 13 forks source link

How to install the required awscrt in my docker environment? #63

Closed f-skold closed 1 year ago

f-skold commented 2 years ago

Confirm by changing [ ] to [x] below:

Platform/OS/Hardware/Device

Linux (AWS Elastic Beanstalk), custom docker environment based on debian, running on Amazon AWS Linux 2

Describe the question

I did add code that wants to download from one S3 bucket in a (different) region, and upload to my S3 bucket (in a local region). I got the exception saying "AWS Common Runtime for PHP is required to use Signature V4A.". I tried to add the composer package "aws/aws-crt-php", version 1.0.2. But I still get the same exception.

I don't think that the instructions are very clear. Should I add a debian package to get the correct code? Should I build a PECL package? Is the composer package to old (v.1.0.2)?

Logs/output

I got this stack trace:

PHP Fatal error:  Uncaught Aws\\Exception\\CommonRuntimeException: AWS Common Runtime for PHP is required to use Signature V4A.  Please install it using the instructions found at https://github.com/aws/aws-sdk-php/blob/master/CRT_INSTRUCTIONS.md in /www/prod/external/lib/composer/vendor/aws/aws-sdk-php/src/Signature/SignatureV4.php:451
Stack trace:
#0 /www/prod/external/lib/composer/vendor/aws/aws-sdk-php/src/Signature/S3SignatureV4.php(41): Aws\\Signature\\SignatureV4->signWithV4a(Object(Aws\\Credentials\\Credentials), Object(GuzzleHttp\\Psr7\\Request), 's3')
#1 /www/prod/external/lib/composer/vendor/aws/aws-sdk-php/src/Middleware.php(126): Aws\\Signature\\S3SignatureV4->signRequest(Object(GuzzleHttp\\Psr7\\Request), Object(Aws\\Credentials\\Credentials))
#2 /www/prod/external/lib/composer/vendor/guzzlehttp/promises/src/Promise.php(204): Aws\\Middleware::Aws\\{closure}(Object(Aws\\Credentials\\Credentials))
#3 /www/prod/external/lib/composer/vendor/guzzlehttp/promises/src/Promise.php(153): GuzzleHttp\\Promise\\Promise::callHandler(1, Object(Aws\\Credentials\\Credentials), NULL)
#4 /www/prod/external/lib/composer/vendor/guzzlehttp/promises/src/TaskQueue.php(48): GuzzleHttp\\Promise\\Promise::GuzzleHttp\\Promise\\{closure}()
#5 /www/prod/external/lib/composer/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(158): GuzzleHttp\\Promise\\TaskQueue->run()
#6 /www/prod/external/lib/composer/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(183): GuzzleHttp\\Handler\\CurlMultiHandler->tick()
#7 /www/prod/external/lib/composer/vendor/guzzlehttp/promises/src/Promise.php(248): GuzzleHttp\\Handler\\CurlMultiHandler->execute(true)
#8 /www/prod/external/lib/composer/vendor/guzzlehttp/promises/src/Promise.php(224): GuzzleHttp\\Promise\\Promise->invokeWaitFn()
#9 /www/prod/external/lib/composer/vendor/guzzlehttp/promises/src/Promise.php(269): GuzzleHttp\\Promise\\Promise->waitIfPending()
#10 /www/prod/external/lib/composer/vendor/guzzlehttp/promises/src/Promise.php(226): GuzzleHttp\\Promise\\Promise->invokeWaitList()
#11 /www/prod/external/lib/composer/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\\Promise\\Promise->waitIfPending()
#12 /www/prod/external/lib/composer/vendor/guzzlehttp/promises/src/Coroutine.php(67): GuzzleHttp\\Promise\\Promise->wait()
#13 /www/prod/external/lib/composer/vendor/guzzlehttp/promises/src/Promise.php(248): GuzzleHttp\\Promise\\Coroutine->GuzzleHttp\\Promise\\{closure}(true)
#14 /www/prod/external/lib/composer/vendor/guzzlehttp/promises/src/Promise.php(224): GuzzleHttp\\Promise\\Promise->invokeWaitFn()
#15 /www/prod/external/lib/composer/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\\Promise\\Promise->waitIfPending()
#16 /www/prod/external/lib/composer/vendor/guzzlehttp/promises/src/Coroutine.php(103): GuzzleHttp\\Promise\\Promise->wait(false)
#17 /www/prod/external/lib/composer/vendor/guzzlehttp/promises/src/Promise.php(274): GuzzleHttp\\Promise\\Coroutine->wait(false)
#18 /www/prod/external/lib/composer/vendor/guzzlehttp/promises/src/Promise.php(226): GuzzleHttp\\Promise\\Promise->invokeWaitList()
#19 /www/prod/external/lib/composer/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\\Promise\\Promise->waitIfPending()
#20 /www/prod/external/lib/composer/vendor/aws/aws-sdk-php/src/AwsClientTrait.php(58): GuzzleHttp\\Promise\\Promise->wait()
#21 /www/prod/external/lib/composer/vendor/aws/aws-sdk-php/src/AwsClientTrait.php(86): Aws\\AwsClient->execute(Object(Aws\\Command))
#22 /myrepo-path/lib/satellite/IngestScene.php(129): Aws\\AwsClient->__call('getObject', Array)
#23 /myrepo-path/lib/satellite/IngestScene.php(71): IngestScene->downloadFiles('sentinel-s2-l2a...')
#24 /myrepo-path/lib/satellite/request_image.php(78): IngestScene->doWork()
#25 /myrepo-path/htdocs/application/satellite/request_image.html(3): require_once('/www/filer/sand...')
#26 {main}
  thrown in /www/prod/external/lib/composer/vendor/aws/aws-sdk-php/src/Signature/SignatureV4.php on line 451
italo1983 commented 1 year ago

Try this:

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

RUN git clone --recursive https://github.com/awslabs/aws-crt-php.git && \
 cd aws-crt-php && \
 phpize && \
 ./configure && \
 make && make test

RUN touch /etc/php/7.4/fpm/conf.d/30-awscrt.ini && echo "extension=/aws-crt-php/modules/awscrt.so" > /etc/php/7.4/fpm/conf.d/30-awscrt.ini
TingDaoK commented 1 year ago

We are still working on the PECL package fix. So, for now, as @italo1983 suggested, build from source is the only way to install awscrt native extension.

We will let you know if we fixed the PECL package issue we currently have. And, once it's fixed, you should be able to install it via pecl install awscrt

TingDaoK commented 1 year ago

You should be able to use pecl install awscrt now.