Issue with AWS S3 Presigned URL with session token

Viewed 417

I am having an issue generating a presigned url for AWS S3 if my credentials are using a session token. I am getting the following error:

<Code>InvalidToken</Code>
<Message>The provided token is malformed or otherwise invalid.</Message>

I am getting the error in my code using AWS Amplify, but I can reproduce the issue using the CLI directly. When I use a profile that doesn't have a session-token, the url returned from the cli command works. But when I use a profile that does have a session-token, the url from the cli command doesn't work and has the above error

# this returned url will work
aws --profile=some-profile-without-session-token --region=us-east-2 s3 presign s3://a-valid-bucket/a-valid-key

# this returned url will not work
aws --profile=some-profile-with-session-token --region=us-east-2 s3 presign s3://a-valid-bucket/a-valid-key

Any help would be appreciated.

0 Answers
Related