How to use Android S3 TransferUtility without Cognito

0

My Android app is currently uploading to Amazon S3 bucket through Presigned URL. However, we kind of need to have a pause and continue interrupted upload because our userbase are in low connectivity area.

It seems that there is no way to do this using S3 Presigned URL (correct me if I am wrong). After searching a while, I found out that there is TransferUtility in AWS S3 SDK for Android. This utility seems can do pause and continue interrupted upload.

https://github.com/awslabs/aws-sdk-android-samples/blob/main/S3TransferUtilitySample/S3TransferUtilityTutorial.md

But in the example, it seems that we need to create an Amazon Cognito pool. For now, I don't want to be committed to migrating our users to Cognito just to do this.

Is there any way to utilize TransferUtility without Cognito but still pretty secure? I am thinking of creating a temporary credentials using STS only for a one object in the bucket and then pass it to the Android through similar API that we use to pass the presigned URL. But AFAIK, STS can only assume one role, we cannot limit it to one single object.

1 Answer
2
Accepted Answer

What you're trying to do actually uses an Amazon Cognito identity pool, not a user pool. Therefore, there's no need to migrate any users to a Cognito user pool for this scenario as you're able to use an identity pool on it's own.

An identity pool allows you to get temporary AWS credentials and does not manage the underlying identities of your users. Look into the README for the utility example for steps on setting up the Cognito identity pool (e.g. steps 1 & 2).

However, and most importantly, this sample you're looking into uses an "unauthenticated" role from the identity pool. And this has the AmazonS3FullAccess policy attached to this unauthenticated role. I would highly, highly recommend to instead using an authenticated role with IAM policies that follow a more restrictive and least privileged access model, based on your use case and requirements. You have an ability to federate from your existing identity provider that your Android app uses to the Cognito identity pool. This way you can securely allow only authenticated users access to the S3 bucket and you can enforce more fine-grained permissions. For example, you could use an attribute-based access control (ABAC) or a role-based access control (RBAC) model to determine permissions.

Here's some additional links to help out (in addition to the repo you referenced):

profile pictureAWS
answered a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions