maxbanton / cwh

Amazon Web Services CloudWatch Logs Handler for Monolog library
MIT License
417 stars 84 forks source link

[BUG] - "UnrecognizedClientException","message":"The security token included in the request is invalid." #119

Closed CassadyCampos closed 1 year ago

CassadyCampos commented 1 year ago

Describe the bug When trying to send a info log to AWS Cloud Watch I encounter this exception

"GuzzleHttp\Exception\ClientException: Client error: POST https://logs.ca-central-1.amazonaws.com resulted in a 400 Bad Request response: {"__type":"UnrecognizedClientException","message":"The security token included in the request is invalid."}"

I created my CloudWatchLogsClient like so

        $client = new CloudWatchLogsClient([
            'region' => $region,
            'version' => 'latest',
            'credentials' => [
                'key' => $key,
                'secret' => $secret,
            ],
        ]);

Notice how I am not giving a token within credentials because it's supposed to be optional.

Expected behaviour I'd expect to be able to send logs to cloud watch without providing a session token.

Please tell about your environment:

CassadyCampos commented 1 year ago

I resolved my issue.

I was receiving $key, $secret from my environment variables, and they were not defined properly so they were both 'false'.

Once I fixed that my logs started writing to AWS. There was no issue with this library, it was my fault although the error message was a bit misleading.