-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Class EcsCredentialProvider Doesn't Support Customized Guzzle Handler #2162
Comments
Hey @dminy, thanks for opening this issue, trying to understand the issue a bit more here so you are trying to make sure whether the credential provider uses your guzzle handler or not? Looking at the code it seems your custom handler must be used elsewhere. |
Right. I didn't include the code to make the actual API call. The bug happens when calling AWS APIs using ECS credentials (without credentials hardcoded in the PHP code). Ideally, the customized handler should be used by package The bug had been verified in our backend microservices, and we had made a patch to make it work for us. I'm reporting a bug, and hoping that you guys could make a proper fix for it (although the patch I included did work in our case). Thanks |
Hi everyone, i was about to report the exact same issue, but in my case it affects the class $this->client = isset($config['client'])
? $config['client']
: \Aws\default_http_handler(); As a workaround it is possible to set the |
Hi @deminy, @pflueg, this behavior is actually expected since http_handler is a client parameter, which means that it will just apply to the client. If you want to pass a custom handler to the ECS or InstanceProfile provider, you can either or create an instance of the provider separated or pass a parameter called "client" in the arguments you provide when instancing the client. Creating a separated instance of the provider:<?php
require '../vendor/autoload.php';
use Aws\Credentials\CredentialProvider;
use Aws\S3\S3Client;
$provider = CredentialProvider::ecsCredentials([
'client' => new CustomizedGuzlleHandler()
]);
$memoizedProvider = CredentialProvider::memoize($provider);
$client = new S3Client([
'region' => getenv('TEST_REGION'),
'credentials' => $memoizedProvider
]);
$client->listBuckets(); Providing the custom handler in the parameter called "client":<?php
require '../vendor/autoload.php';
use Aws\S3\S3Client;
$client = new S3Client([
'region' => getenv('TEST_REGION'),
'client' => new CustomizedGuzzleHandler()
]);
$client->listBuckets(); Please let me know if that helps! Thanks! |
This issue has not recieved a response in 1 week. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled. |
|
Describe the bug
Class \Aws\Credentials\EcsCredentialProvider doesn't support customized Guzzle handler.
Version of AWS SDK for PHP?
v3.166.2
Version of PHP (
php -v
)?PHP 7.4.12
To Reproduce (observed behavior)
We used to call some AWS APIs with credentials hardcoded. e.g.,
Please note that here we use a customized Guzzle handler.
Recently we switched to use IAM Roles for Tasks,
and started calling the AWS APIs like following:
The problem is that, the API call starts using the default handler, but not the customized one we specified.
Expected behavior
Here is the constructor in class \Aws\Credentials\EcsCredentialProvider:
I patched it like following to make it work for us:
I'm not sure if the patch is the proper way to address the issue, and I don't have unit tests added, thus I'm submitting a bug report instead of a PR.
Screenshots
N/A
Additional context
Same issue could also happen on class \Aws\Credentials\InstanceProfileProvider.
The text was updated successfully, but these errors were encountered: