How to get started with AWS S3 cloud storage for Unity

Let’s go over how to get started with AWS cloud storage for Unity.

First, go to https://aws.amazon.com and create an account:

Download the AWS SDK package from https://docs.aws.amazon.com/mobile/sdkforunity/developerguide/setup-unity.html:

Open up Unity and import the S3 package:

Open up your web browser again and on the AWS website navigate to Amazon Cognito. Click on Manage Identity Pools:

Enter a name for the identity pool and tick “Enable access to unauthenticated identities”

Click on allow:

Go to S3 Buckets:

Click on create bucket:

Enter a unique name for the bucket:

Scroll down and click on Create bucket:

Go to IAM and create a policy:

Set service of the policy to S3 and allow all actions:

Name the policy and then click on create policy:

On the IAM main page click on roles and then click on the unauthenticated role:

Make note of the Role ARN and attach the new policy created:

Go back to S3 and select the bucket:

Click on the permissions tab:

Click on Edit bucket policy:

Click on Policy Generator:

AWS Policy Generator:
- Set Policy to S3 Bucket Policy.
- Set Effect to Allow.
- In the principal field add the Role ARN.
- Allow All Actions
- In the ARN field enter the following text “arn:aws:s3:::BUCKETNAME/*”
i.e arn:aws:s3:::aws-insurance-app-bucket/*

Click Add Statement and then Generate Policy:

Copy the JSON text:

Add the text to the bucket policy and save:

Go back to Unity and create a script called AWSManager. Create a new game object and attach the script:

Open up the AWSManager script and copy over the using directives from the S3Example script that came with the S3 package. Turn the AWSManager class into a singelton:

Create the two properties needed RegionEndpoint and AmazonS3Client. You get the details that belongs to your app from the sample code on Amazon Cognito:

Lastly, in the Awake function initialise by calling UnityInitialiser.AttachToGameObject. Set AWSConfigs.HttpClient to UnityWebRequest and then list all the buckets for this app:

If all is correct you will get this output in the console window when you press play:

Good luck!

--

--

--

Unity / C# Game developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Turning Instant Apps in to Intelligent Instant Apps

Easy Steps To Publish Your First CocoaPod

Get Going With Git — Part 2

Twitter Bot using Python — Enpacto

Create your Twitter Bot using Python

GoLang discussion series —  The beginning

Mavenir Systems Hiring Freshers For Test Engineer Position | Apply Now

Advantages of crodo.io

Using Session and Flash in Flask with Python

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Niklas Bergstrand

Niklas Bergstrand

Unity / C# Game developer

More from Medium

How to copy ssh key to remote host using Ansible.

Using Reaper Automixer for Livestreaming

Introduction to Library Resources

CS 371p Spring 2022: Blog #2