About the Author:

AWS Mobile Hub File Storage for Mobile Apps

August 12th, 2018

Using AWS for file storage is a great way to add data upload capabilities to your mobile apps. It can easily be added to your app and give you inexpensive storage space online.

If you have AWS Authentication added to your app it can allow users to upload files specifically for their account. Otherwise, you can allow users access to files across the board. This is great for file sharing, social content and more.

We’ll look at the AWS side of things and then the iOS project needs.


The first thing you need to do is create an AWS account here: aws.amazon.com. You’ll want to check out the pricing (https://aws.amazon.com/pricing/) but the Free Tier should be fine for getting started.

From there we’ll go to the Mobile Hub and create our project: console.aws.amazon.com/mobilehub/home

The first time you load the Mobile Hub you’ll be prompted to create a project:

Later, after you’ve created a project, this screen will list your projects.

Step 1: Select iOS

For demonstration purposes, we’ll select iOS as our platform.

Step 2: Cloud enable your existing app > Start

We won’t be using their tutorials so under Step 2 select the Start button in the box for “Cloud enable your existing app.” This will allow us to create our own app in Xcode.

Name and Next

All we have to do next is give our project a name: MyAWSApp (image below). And click Next.

The next screen (no image) has a prepared configuration file for you to download. However, we’ll hold off on this for now. We’re just going to have to download it again once we’ve configured the file storage anyway.

Click Next. On the following screen (image below), there’s a link to add the mobile SDK (which we’ll do later) so just click Done.

Now we see our project’s listing of apps (one, iOS) and the Backend features:

AWS automatically configured Messaging and Analytics for us. That’s in the configuration file already (the one we didn’t download yet). If you scroll down you can see other backend features you can add to your project. We’ll see User File Storage (not in the image above).

Scroll down and click User File Storage.

On the next screen you’ll see the very simple process of enabling the storage of files.

Simply click on Store Files and save your changes. Easy, right?

Notice the banner at the top informing you that the back end has been updated and you need to integrate:

Now well click on the blue banner:

And then click on the pulsating Integrate button

Now we’ll click on Download Cloud Config button (no image). This will download the awsconfiguration.json file. This is what we’ll use to configure our backend into our iOS app in Xcode.

Let’s look at the config file… (image below)

Notice the settings for S3TransferUtility. This specifies a bucket that was created for us in S3. You can see the bucket created for you by going to https://console.aws.amazon.com/s3/home

The bucket name will contain the name of the app, mobile hub and the same number at the end. For example: myawsapp-userfiles-mobilehub-23423523532.

iOS Xcode Project

Now we’ll switch over to Xcode for our iOS project. For Android details of the same process, see https://docs.aws.amazon.com/aws-mobile/latest/developerguide/getting-started.html#add-aws-mobile-sdk-connect-to-your-backend

First we need to create our project in Xcode:

Open Xcode

Select File>New Project>iOS Single View Template

Name your project and select where to store it (image).

Now we close Xcode to install the CocoaPods.

Open a Terminal and navigate to the directory where you stored your project.

If you haven’t installed CocoaPods before, run “sudo gem install cocoapods” – see https://cocoapods.org for details.

The run “pod init” to create your Podfile.

Edit that Podfile and add the lines for the pods we need:

pod ‘AWSMobileClient’, ‘~> 2.6.13’

pod ‘AWSS3’, ‘~> 2.6.13’

Your pod fille will look like this:

Then run “pod install” to install the pods and create your Xcode workspace.

Once installed the .xcworkspace is what you want to use going forward – not the .xcproject.

Run “open <projectname>.xcworkspace” to open it.

Now you have a workspace that includes your app and the CocoaPods needed.

Drag your awsconfiguration.json file into your project navigator:

Open the AppDelegate.swift file, import AWSMobileClient (line 10 below), the AWS mobile client framework, and add the client shared instance return to the first function (lines 20-22 below).

NOTE: You might see an error until you build the project which now includes the pods.

Your didFinishLaunchingWithOptions function will now also start the mobile client.

File Upload

Now we’ll upload the file…

Open the ViewController.swift file and import AWS3 – the S3 CocoaPod:

import AWSS3

Write a new function inside your ViewController class to upload data (below). We’ll simply create a data object from a String and upload that.

func uploadFile() {

let data = "HelloAWS".data(using: .utf8)


key: "public/hello.txt",

contentType: "text/plain",

expression: nil) { (task, error) in

print (error?.localizedDescription ?? "no error")



Be sure to call this function from your code (e.g., from viewDidLoad).

When you run your app (Command+R), you’ll see that “no error” is printed to the console. You can then check the S3 bucket (remember the name from the awsconfiguration.json file) and see the file.

If you click on the file you can open it or download it and confirm the contents.

Downloading is similar and can be done to data or file (represented in the URL sent to the callback). The calls are downloadData and download respectively.

func downloadFile() {


forKey: "public/hello.txt",

expression: nil) { (task, url, data, error) in

print (String.init(data: data!, encoding: .utf8)!)



Of course a lot more can be done including progress of uploads and downloads. I’d recommend you see more at aws.console.com and various courses online.

I encourage you to navigate around in the AWS Mobile Hub, Cognito and AWS IAM:




Also see my online courses with related topics here:

LiL: https://www.linkedin.com/learning/instructors/bear-cahill?trk=insiders_676521_learning

Lynda.com: https://www.lynda.com/Bear-Cahill/10916794-1.html

And feel free to visit me online at brainwashinc.com and @brainofbear

About the Author:

What does Elastic Beanstalk Do and Why use it?

April 13th, 2017

Applications deployed in the cloud need memory, computing power and an operating system to run. Creating and administering these items can take a lot of work and maintenance. AWS Elastic beanstalk can take a lot of the setup work out of development/deployment and can save developers and companies time and hassle. AWS Elastic Beanstalk is an orchestration service that abstracts away some of these hardware resources and details (e.g. setting up AWS components), while still allowing the developer a range of choices when it comes to OS and programming language. 

Get AWS Training for Teams

AWS Elastic Beanstalk supports multiple languages, which, includes, but is not limited to, Java, PHP, .NET and Docker. AWS Elastic Beanstalk provides tools to automate background tasks. Elastic Beanstalk employs Auto Scaling and Elastic Load Balancing to scale and balance workloads. It provides tools in the form of Amazon CloudWatch to monitor the health of deployed applications. It also provides capacity provisioning due to its reliance on AWS S3 and EC2. The AWS management console provides the option of using the Beanstalk API or Command Line Interface and has multiple Toolkits and SDKs for development. This creates a formidable and reliable infrastructure for deployment of cloud applications.

AWS Elastic Beanstalk actively separates the cloud from local systems in order to provide added security. HTTPS endpoints are used for access to services and enables encryption across accounts and the use of AWS consoles is restricted to people with the credentials. Additionally, a DMZ (Dematerialized Zone) can be set up with the help of Amazon Virtual Private Cloud by the developer so that a private subnet is created for AWS resources for more security. Access can be limited to read – only for some users with the help of Identity and Access Management. Deployed subnets show up on the dashboard as below:


Like most AWS services, AWS offers multiple regions where their servers are present.

Load Balancing is used to provide resources in cases where there are multiple instances that need to be run at the same time. This is necessary to provide the requisite resources to each instance and helps Amazon Auto Scaling to optimize the manner in which the application scales.

Beanstalk can be used alongside the Amazon S3. This provision is useful in cases the application is present in the cloud already in an S3 bucket, and can be called by its URL.

An alternative to the AWS Beanstalk is the AWS CloudFormation. This service provides a host of abstraction techniques whose focus is concentrated on the development of the application rather than how resources are handled.

CloudFormation is a simple resource handler that can manage multiple Beanstalk environments, as well as other AWS resources at the same time. Both have their own uses. While Beanstalk provides ease of use, CloudFormation provides greater control over resources one can deploy.


Many developers want to avoid the hassle of dealing with deep background details of the infrastructure. Elastic Beanstalk provides a simple environment in which they can develop and deploy their applications while letting Beanstalk handles a lot of the nitty gritty details.

Get AWS Training for Teams