Image Uploads with AWS S3, Elixir + Phoenix (:ex_aws) — Step 1
- Step 1 AWS (IAM) — Create an IAM user with permissions to upload and read from S3 (Full Access)
- Step 2 AWS (S3) — Create an S3 bucket with the correct permissions and policies so that it can be accessed by our application
- Step 3 Application Code — Write code to facilitate the image upload within your Elixir/Phoenix application
Hello! And welcome to Step 1 of Image Uploads with S3, Elixir + Phoenix. By the end of this step you will have created a user in AWS IAM that has permissions to upload and read from an S3 bucket.
Before we write any application code we need to set up an AWS account. This can be done here.
Once you’ve created an account, navigate to the IAM (Identity and Access Management) service. It can be found by searching in the AWS Services search bar. Click on the link to navigate to the IAM dashboard:
The IAM service allows you to create users with specific permissions. Permissions can be limited so that access is restricted to certain AWS services. We want to create a new user that has full access to S3. We can do that by clicking on the Users tab on the left hand side:
Click on the blue “Add user” button at the top:
Next give your user a name, I’ve called mine s3-upload-tutorial, and then select the “Programmatic access” checkbox. By selecting this we are saying that we want to give access to our application for the AWS SDK. Then click the “Next: Permissions” button:
We then want to add permissions to the user we are creating. This can be done in a number of ways but for this tutorial I’ve attached the permissions directly to the user. We want to give full access to S3 so search for S3 in the search bar and then choose the AmazonS3FullAccess policy, then click “Next: Review”:
The review page shows you the details of the user that you are about to create. You should see a user with programmatic access and an attached policy for AmazonS3FullAccess. Click “Create user” if you’re happy with the details that you see:
You should then see a SUCCESS message and your newly created user below. Make a note of your Access key ID and Secret access key, we’ll need those in Step 3:
Nice! We have now created a user with permissions to upload to, and read from, AWS S3. Next we need to create a bucket to store all of our images in which we’ll cover in Step 2.
Image Uploads with AWS S3, Elixir + Phoenix (:ex_aws) — Step 2
A Complete Step-by-Step Guide