Skip to content
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

Config.php requires "use Aws\\Credentials\\CredentialProvider" #31

Closed
andrea-malatesta-ws opened this issue Aug 4, 2021 · 3 comments
Closed

Comments

@andrea-malatesta-ws
Copy link

andrea-malatesta-ws commented Aug 4, 2021

Hi,
I have an infrastructure with moodle installed as described in aws-refarcg-moodle.

Since August 4th I have a 500 HTTP server error and I found the following error.

ERROR

#######################################################################
Fatal errorPHP Fatal error: Uncaught Aws\Exception\CredentialsException: Error retrieving credentials from the instance profile metadata service. (cURL error 6: Could not resolve host: https (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)) in phar:///var/www/moodle/html/lib/aws.phar/Aws/Credentials/InstanceProfileProvider.php:272
Stack trace:
#0 phar:///var/www/moodle/html/lib/aws.phar/Aws/Credentials/InstanceProfileProvider.php(159): Aws\Credentials\InstanceProfileProvider->handleRetryableException(Object(GuzzleHttp\Exception\ConnectException), Array, 'Error retrievin...')
#1 [internal function]: Aws\Credentials\InstanceProfileProvider->Aws\Credentials\{closure}()
#2 phar:///var/www/moodle/html/lib/aws.phar/GuzzleHttp/Promise/Coroutine.php(160): Generator->throw(Object(GuzzleHttp\Exception\ConnectException))
#3 phar:///var/www/moodle/html/lib/aws.phar/GuzzleHttp/Promise/Promise.php(204): GuzzleHttp\Promise\Coroutine->_handleFailure(Object(GuzzleHttp\Exception\ConnectException))
#4 phar:///var/www/moodle/html/lib/aws.phar/Guzzl in phar:///var/www/moodle/html/lib/aws.phar/Aws/Credentials/InstanceProfileProvider.php on line 272

#######################################################################

To resolve it I have to change the initial part of config.php file from:

              require 'lib/aws.phar';
              use Aws\\SecretsManager\\SecretsManagerClient;
              use Aws\\Exception\\AwsException;
              use Aws\\Iam\\IamClient;

              $client = new SecretsManagerClient([
                  'version' => '2017-10-17',
                  'region' => ''
              ]);

to:

              require 'lib/aws.phar';
              use Aws\\SecretsManager\\SecretsManagerClient;
              use Aws\\Exception\\AwsException;
              use Aws\\Iam\\IamClient;
              use Aws\\Credentials\\CredentialProvider;

              $provider = CredentialProvider::defaultProvider();

              $client = new SecretsManagerClient([
                  'version' => '2017-10-17',
                  'region' => '',
                  'credentials' => $provider
              ]);

Basically seems that a breaking change has been introduced in aws.phar.

Please can you help me to understand how to prevent that from happening?
Is it available an url point for a specific v3 revision ?
What I did is correct ?
You too have the same anomaly as me?

Thanks

@brianjbeach
Copy link

Can you confirm that you have an IAM profile assigned to the instance and the metadata service is enabled? It should look something like this.

% aws ec2 describe-instances
{
    "Reservations": [
        {
            "Groups": [],
            "Instances": [
                {
                    ...
                    "IamInstanceProfile": {
                        "Arn": "arn:aws:iam::XXXXXXXXXXXX:instance-profile/XXXXXX",
                        "Id": "XXXXXXXXXXXXX"
                    },
                    ...
                    "MetadataOptions": {
                        "State": "applied",
                        "HttpTokens": "optional",
                        "HttpPutResponseHopLimit": 1,
                        "HttpEndpoint": "enabled"
                    },
                    ...
                }
            ],
            ...
        }
    ]
}

@andrea-malatesta-ws
Copy link
Author

Yes. I can confirm it.
IAM profile is assigned to instance and the metadata service is enabled.

@vrioux
Copy link
Contributor

vrioux commented Jan 31, 2023

Is this issue still valid? If so, please reopen. Thanks!

@vrioux vrioux closed this as completed Jan 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants