pplu / aws-sdk-perl

A community AWS SDK for Perl Programmers
Other
171 stars 94 forks source link

ECS Task Token Expired #347

Open josnidhin opened 5 years ago

josnidhin commented 5 years ago

I have an ECS Task with a ECS Task Role attached, which gives it permission to interact with SQS. Everything works fine most of the time but occasionally the task crashes with the following error.

The security token included in the request is expired

ECS starts another task to replace the crashed task and everything goes back to normal.

I have not looked into the codebase but I guess it has something to do with how the token expiry and refresh is handled. I would like to prevent this crash from occurring, is there some config that I missed which is causing this issue.

pplu commented 5 years ago

Hi,

This could be because we discard the credentials too late:

Compare https://github.com/pplu/aws-sdk-perl/blob/master/lib/Paws/Credential/ECSContainerProfile.pm#L80 to https://github.com/pplu/aws-sdk-perl/blob/master/lib/Paws/Credential/InstanceProfile.pm#L58 (which handles getting creds from an instance role, with almost the same logic).

Would you mind trying to adjust the expiry code for the ECSContainerProfile and report back if the errors have disappeared?

josnidhin commented 5 years ago

Thanks for the quick response I had concluded the same after the going through the code-base. I will try it out and will get back.

josnidhin commented 5 years ago

I had applied the change 2 weeks back which seems to have fixed the issue as I have not this error since the fix.

dheffx commented 3 years ago

We ran into this same issue. Any plans to get this merged into the module? Would prefer to see this patched into Paws as a permanent fix rather than needing to modify ECSContainerProfile ourselves.

pplu commented 3 years ago

@dheffx : Can you please send a pull request with your fix? It really helps go faster.

dheffx commented 3 years ago

Sure, here ya go: https://github.com/pplu/aws-sdk-perl/pull/421