Мой сервис получает учетные данные с сервера метаданных и кэширует их в файле.
Вот как выглядит определение сервиса во второй версии:
Код: Выделить всё
my_app.infrastructure.s3.client.credentials_cache.adapter:
class: Doctrine\Common\Cache\FilesystemCache
public: false
arguments:
- '%kernel.cache_dir%/aws_credentials'
my_app.infrastructure.s3.client.credentials_cache:
class: Guzzle\Cache\DoctrineCacheAdapter
public: false
arguments:
- '@my_app.infrastructure.s3.client.credentials_cache.adapter'
my_app.infrastructure.s3.client:
class: Aws\S3\S3Client
factory: [ 'Aws\S3\S3Client', 'factory' ]
arguments:
- region: "%my_app_organization_dictionary_aws_s3_region%"
credentials.cache: '@my_app.infrastructure.s3.client.credentials_cache'
Код: Выделить всё
my_app.infrastructure.s3.client.credentials_cache.adapter:
class: Doctrine\Common\Cache\FilesystemCache
public: false
arguments:
- '%kernel.cache_dir%/aws_credentials'
my_app.infrastructure.s3.client.credentials_cache:
class: Aws\DoctrineCacheAdapter
public: false
arguments:
- '@my_app.infrastructure.s3.client.credentials_cache.adapter'
my_app.infrastructure.s3.client.credentials_provider:
class: Aws\Credentials\CredentialProvider
factory: [ 'Aws\Credentials\CredentialProvider', 'defaultProvider' ]
public: false
my_app.infrastructure.s3.client.cached_credentials_provider:
class: Aws\Credentials\CredentialProvider
factory: [ 'Aws\Credentials\CredentialProvider', 'cache' ]
arguments:
- '@my_app.infrastructure.s3.client.credentials_provider'
- '@my_app.infrastructure.s3.client.credentials_cache'
public: false
my_app.infrastructure.s3.client:
class: Aws\S3\S3Client
factory: [ 'Aws\S3\S3Client', 'factory' ]
arguments:
- region: "%my_app_organization_dictionary_aws_s3_region%"
version: 'latest'
credentials: '@my_app.infrastructure.s3.client.cached_credentials_provider'
Код: Выделить всё
FAIL AWS S3: Fail check the AWS S3 with bucket "my_app_bucket".
Reason: [Aws\Exception\CredentialsException]
Error retrieving credentials from the instance profile metadata server.
(cURL error 28: Operation timed out after 1001 milliseconds with 0 bytes received (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://169.254.169.254/latest/api/token).
Подробнее здесь: https://stackoverflow.com/questions/790 ... ding-to-v3