Starting AWS S3 Services!

addam davis
3 min readMar 30, 2022

Objective: Create S3 Client and List Buckets!

We begin with opening our AWS Manager script we previously created.

Our next step is to in the process is creating the Amazon S3 Client.

To use Amazon S3 we first need to create an amazon S3 Client Instance which takes a preference to the Cognito AWS credentials we previously created. Copy the line provided above and paste it into the Awake method of our AWS Manager.

We need to pass in our credentials from the section on setting up our Identity Pool.

Insert your Identity Pool Inside the quotes.

We now have our ID and our Credentials, next we can list the buckets in an AWS account. To list the buckets in an AWS account call the Amazon S3 Client List Buckets Async method.

Let’s talk about this example code before we implement our own. They have a result text which is a label used for display information “fetching all Buckets.” Then they are typing the method Client.ListBucketsAsync. These are called anonymous methods where you can run some code and it treats variables as a function. We are basically passing in a parameter and we are telling it to run this code and it is using that parameter.

Then, if the response object that we pass in, if the exception equals null than “Got Response \nPrinting now \n” for each bucket printing out the bucket names.

Copy this code and paste it into Unity in awake after we establish our connection. We will refractor later so we have our helper functions later because right now we wouldn’t be able to access the S3 outside of Awake().

Remove these Result Text and the client is going to be our S3Client.

The response object is going to hold our list of buckets. This is accentually an in line for each loop for each bucket. It’s going to say the variable name we are then going to print our what that bucket is. It is passing in data, bucket name, and the bucket creation date. Instead, we are going to add a debug log.

Replace the else ResultText with another debug log.

If we were to test this we would receive and error “Amazon Client Exception: no Region End Point or service URL configured inside our S3Client.” We are going to fix these errors in our next tutorial!