2

I have the following adapter and service configured:

knp_gaufrette:
    adapters:
        sc_documents:
            aws_s3:
                service_id: sc.aws_s3.client
                bucket_name:  HIDDEN
                options:
                    directory: documents
                    create: true
    filesystems:
        sc_documents_fs:
            adapter:    sc_documents
            alias:  sc_document_storage

sc.aws_s3.client:
    class: Aws\S3\S3Client
    factory_class: Aws\S3\S3Client
    factory_method: factory
    arguments:
        -
            key: 'HIDDEN'
            secret: 'HIDDEN'
            region: 'eu-central-1'
            version: '2006-03-01'

I keep getting the following error for both read and write: Error retrieving credentials from the instance profile metadata server. (cURL error 7: Failed to connect to 169.254.169.254 port 80: Network unreachable (see http://curl.haxx.se/libcurl/c/libcurl-errors.html))

The bucket policy is:

"Id": "Policy1445959171046",
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "STMT",
            "Action": "s3:*",
            "Effect": "Allow",
            "Resource": "arn:aws:s3:::HIDDEN/*",
            "Principal": {
                "AWS": "*"
            }
        }
    ]

I tried with different accounts but none of them worked. I wonder what I am doing wrong. Do I need something else enabled?

Thanks!

Spas Bobchev
  • 104
  • 11

1 Answers1

1

It's a problem with the change of how credentials are managed in the latest version of php sdk. Now they use a Credentials object.

If you are using the aws/aws-sdk-php-symfony bundle there's no need to create the s3_client as a service.

Initialize the sdk in your config with

aws:
    version: latest
    region: us-east-1
    credentials:
        key: not-a-real-key
        secret: "@@not-a-real-secret" 
    S3:
        version: '2006-03-01'

And just pass the aws.s3 client to gaufrette instead of your declared client

knp_gaufrette:
    adapters:
        sc_documents:
            aws_s3:
                service_id: aws.s3
                bucket_name:  HIDDEN
                options:
                    directory: documents
                    create: true
Nodens
  • 354
  • 1
  • 3
  • 11