Amazon S3 Integration Setup

To integrate Amazon S3 features of the AWS SDK for iOS into an app, take the following steps.

Create and configure the following AWS services and policies.

  1. Install the SDK

    Add the AWS SDK for iOS to your project and import the APIs you need, by following the steps in Set Up the SDK for iOS.

  2. Configure credentials

    To use Amazon Cognito to create AWS identities and credentials that give your users access to your app's AWS resources, follow the steps in Amazon Cognito for iOS.

  3. Create and configure an Amazon S3 bucket

    Amazon S3 stores your resources in buckets, which are AWS containers for objects. Buckets are created in specific regions. Each bucket must have a globally unique name.

    Create a bucket

    1. Sign in to the Amazon S3 console.
    2. Choose Create Bucket.
    3. Type a bucket name, choose a region, and then choose Create Bucket.

    Grant Permissions

    Like most AWS service objects, Amazon S3 buckets have access policies attached to them that you can use to grant permissions for IAM entities, such as roles or individual identities. Take the following steps to grant the unauthenticated IAM role of your app's identity pool permissions to the bucket you created.

    1. Navigate to the Identity and Access Management console.

    2. Choose Roles in the left navigation pane.

    3. Type your identity pool name into the search box. Two roles are listed: one for unauthenticated users and one for authenticated users.

    4. Choose the role for unauthenticated users (it has unauth appended to your identity pool name).

    5. At the bottom of the Permissions tab, find the policy AWS attached when you created the role and choose Create Role Policy.

    6. Choose Custom Policy, and then choose Select.

    7. Enter a name in Policy Name, and then copy and paste the following policy statement into the Policy Document area.

      {
          "Version": "2012-10-17",
          "Statement": [
              {
                  "Effect": "Allow",
                  "Action": ["s3:*"],
                  "Resource": ["arn:aws:s3:::examplebucket/"]
              }
          ]
      }
      
    8. Choose Apply Policy.

    This policy grants the user permissions for all actions in all objects in the specified bucket. For more information on granting access to Amazon S3, see Granting Access to an Amazon S3 Bucket.

    Upload files from the console

    The following steps describe how to manually upload the file used in this walk through to the bucket you have created.

    1. In the Amazon S3 console, navigate to your bucket.
    2. In the Actions`drop down menu, choose :guilabel:`Upload.
    3. Choose + Add Files and select a test file to upload. For this walk through, we'll assume you're uploading an image called myImage.jpg.
    4. With your test image selected, choose Start Upload.