How to fix expired token in AWS s3 copy command?

Viewed 589

I need to run the command aws s3 cp <filename> <bucketname> from an EC2 RHEL instance to copy a file from the instance to an S3 bucket.

When I run this command, I receive this error: An error occurred (ExpiredToken) when calling the PutObject operation: The provided token has expired

I also found that this same error occurs when trying to run many other CLI commands from the instance.

I do not want to change my IAM role because the command was previously working perfectly fine and IAM policy changes must go through an approval process. I have double checked the IAM role the instance is assuming and it still contains the correct configuration for allowing PutObject on the correct resources.

What can I do to allow AWS CLI commands to work again in my instance?

1 Answers

AWS API tokens are time-sensitive, and VMs in the cloud tend to suffer from clock drift.

Check that time is accurate on the RHEL instance, and use ntp servers to make sure any drift is regularly corrected.

Related