aws-sdk-perl icon indicating copy to clipboard operation
aws-sdk-perl copied to clipboard

ECS Task Token Expired

Open josnidhin opened this issue 5 years ago • 6 comments

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.

josnidhin avatar Oct 11 '19 01:10 josnidhin

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?

pplu avatar Oct 11 '19 07:10 pplu

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 avatar Oct 11 '19 11:10 josnidhin

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

josnidhin avatar Nov 01 '19 06:11 josnidhin

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.

dheffx avatar Oct 07 '21 17:10 dheffx

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

pplu avatar Oct 11 '21 11:10 pplu

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

dheffx avatar Oct 12 '21 19:10 dheffx