Testing file uploads to AWS S3 with IAM user credentials in Postman

Christina Hastenrath
4 min readFeb 11, 2020

This tutorial describes how you can use Postman to test file uploads to your AWS S3 bucket with IAM User credentials and write as short status test script. I am going to show you how to upload a file to a S3 bucket and how to test that the IAM user credentials for that bucket are working correctly. This tutorial assumes you have already setup an S3 Bucket and an IAM user with Access Key, Secrete Key and access rights to your S3 bucket.

First of all, I find the AWS docs quite confusing and not easy to read. Diving into the docs we found the link to PutObject Example 1: Upload an object shows you what the call expects. Furthermore, Postman has this great feature that allows you to sign your AWS request under the hood, so that you do not have to calculate any signatures yourself.

PUT /my-image.jpg HTTP/1.1
Host: myBucket.s3.<Region>.amazonaws.com
Date: Wed, 12 Oct 2009 17:50:00 GMT
Authorization: authorization string
Content-Type: text/plain
Content-Length: 11434
x-amz-meta-author: Janet
Expect: 100-continue
[11434 bytes of object data]

So let’s get started in the Postman App:

In order to set up our request and auth in Postman, I first open up a new request tab for my PUT request and define the request URL as per the example in the AWS docs.

You have two options to store your bucket name and region. You can either store your S3 Bucket name and region as global variables and call those variables in your request. This is what I did here. However, you can also just replace {{myS3BucketName}} with your bucket name directly.

<name-of-my-S3-Bucket>.s3.<the-region-my-bucket-is-set-to>.amazonaws.com/<path-inside-S3/name-of-file-to-upload>

I then go to the Authorization tab and select ‘Type’ and then ‘AWS Signature’. Here are the Postman docs on AWS Signature setting.

--

--

Christina Hastenrath

Molecular Biologist turned Software Engineer. I write about my code. Connect with me on Twitter @etTinchen