deliciousbrains / wp-amazon-s3-and-cloudfront

Automatically copies media uploads to Amazon S3 for delivery. Optionally configure Amazon CloudFront for even faster delivery.
https://wordpress.org/plugins/amazon-s3-and-cloudfront/
304 stars 148 forks source link

AWS ECS Fargate serverless, plugin cannot get iam role #619

Closed HemzaWindSogeti closed 1 year ago

HemzaWindSogeti commented 1 year ago

Describe the bug When I upload a file using the iam access key and ID to s3 the plugin works fine, but as soon as I use the IAM role functionality I get an error message when I try to upload a file. for context, I am running containers on fargate ECS serverless mode.

2022/12/30 13:12:54 [error] 197#197: *14800 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught 
DeliciousBrains\WP_Offload_Media\Aws3\Aws\Exception\CredentialsException: Error retrieving credentials from the instance profile 
metadata service. (cURL error 7: (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)) in 
/bitnami/wordpress/wp-content/plugins/amazon-s3-and-cloudfront/vendor/Aws3/Aws/Credentials/InstanceProfileProvider.php:177

one thing I noticed is that it uses the instanceprofileprovider.php instead of the ecscredentialprovider.php. although I do not know if this is related at all or not.

below is my config

define('AS3CF_SETTINGS', serialize([
    'provider'=> 'aws',
    'use-server-roles' => true,
    'bucket' => '<hidden for privacy>', 
    'region' => '<hidden for privacy>',
    'copy-to-s3' => true,'serve-from-s3' => false,
    'enable-object-prefix' => true,
    'object-prefix' => '<hidden for privacy>',
    'use-yearmonth-folders' => true,
    'remove-local-file' => true,
    'delivery-provider' => 'aws',
    'deliver-provider-name' => 'Cloudfront',
    'delivery-domain' => '<hidden for privacy>',
    'enable-deliver-domain' => true,
    'object-versioning' => false
 ]));   

Diagnostic Info (from plugin's "Support" tab):

site_url(): <hidden for privacy>
home_url(): <hidden for privacy>
Database Name:<hidden for privacy>
Table Prefix: <hidden for privacy>
WordPress: 6.1.1
Web Server: nginx/1.23.3
PHP: 8.1.13
MySQL: 8.0.23
ext/mysqli: yes
PHP Memory Limit: 512M
WP Memory Limit: 40M
ianmjones commented 1 year ago

Please only create issues for bug reports or feature requests on this repo.

For support, please raise a request at https://wordpress.org/support/plugin/amazon-s3-and-cloudfront or if you have a WP Offload Media license please use the "Support" tab in the plugin.