从第二个版本升级到第三个版本后,我在获取凭据时遇到问题。
我的服务从元数据服务器获取凭据并将其缓存在文件中。
这是第二个版本中的服务定义:
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).
对我的设置有什么问题有什么想法吗?
就我而言,问题出在 AWS 配置方面 无法从容器访问元数据服务器