The AWS Mobile SDKs can be used to build thick-client architecture apps for iOS and Android devices. An overview of the SDKs will be presented as well as demos and code for storing data in Amazon S3 and sending emails via Amazon SES. You will also learn how to manage AWS credentials in a mobile environment.
MBL302 Using the AWS Mobile SDKs - AWS re: Invent 2012
1.
2. Agenda
• Overview of the AWS Mobile SDKs:
• http://aws.amazon.com/mobile
• AWS SDK for iOS : http://aws.amazon.com/sdkforios/
• AWS SDK for Android : http://aws.amazon.com/sdkforandroid/
• Common use cases
• Data storage
• Searchable data
• Application feedback
• Messaging
• Managing credentials
3. AWS Mobile SDKs
• What are the AWS mobile SDKs?
• Who should use them?
• Which services do they support?
• How are they integrated into my applications?
• How do I get help or support using the mobile SDKs?
• Where is the source code for the SDKs?
4. What Are the AWS Mobile SDKs?
• Simplifies mobile-to-cloud development
• Thick-client architecture
• AWS SDK for iOS
• Support iOS v4.3 and above
• AWS SDK for Android
• Supports Android v2.2 (API Level 8) and above
5. Who Should Use Them?
• Thick-client applications
• Don’t want to manage a back end
• Want users to make direct calls to the cloud
• Back-end processing isn’t necessary
6. Thin Versus Thick-Client Architecture
AWS
SDKs
custom thin architecture
APIs
AWS mobile
SDKs
Thick clients
Thin clients proxy thick architecture connect directly to
requests through the services they
intermediary services need
7. Which Services Do They Support?
• The AWS mobile SDKs support 11 services:
• Amazon Simple Storage Service (S3)
• Amazon DynamoDB
• Amazon Simple Queue Service (SQS)
• Amazon Simple Notification Service (SNS)
• Amazon Simple Email Service (SES)
• Amazon Elastic Compute Cloud (EC2)
• Elastic Load Balancing
• Auto Scaling
• Amazon CloudWatch
• Amazon SimpleDB
• AWS Security Token Service (STS)
8. Integration
• How are the SDKs integrated into my application?
• AWS SDK for iOS
• Single framework that can be added to your application
• AWS SDK for Android
• Single or service level jars available
9. Minimization
• How BIG will the SDKs make my application?
• AWS SDK for iOS
• Statically linked –only the parts you use will be added to your
application
• AWS SDK for Android
• Proguard integration to help obfuscate and minimize the size of your
application
10. Amazon S3
• SDK has many samples with Amazon S3
• Amazon S3 allows for the storage and retrieval of data
• Article and sample for Amazon S3:
• http://aws.amazon.com/articles/SDKs/3002109349624271
12. Amazon S3 SDK Code
iOS Android
// Create Amazon S3 Client // Create Amazon S3 Client
AmazonS3Client *s3 = [[AmazonS3Client alloc] AmazonS3Client s3 = new AmazonS3Client(
initWithAccessKey:ACCESS_KEY_ID withSecretKey:SECRET_KEY]; new BasicAWSCredentials( ACCESS_KEY_ID, SECRET_KEY ) );
// Create an S3 Bucket // Create an S3 Bucket
[s3 createBucketWithName:PICTURE_BUCKET]; s3.createBucket(PICTURE_BUCKET);
// Put an Object into a Bucket // Put an Object into a Bucket
S3PutObjectRequest *por = [[S3PutObjectRequest alloc] PutObjectRequest por =
initWithKey:PICTURE_NAME inBucket:PICTURE_BUCKET]; new PutObjectRequest(PICTURE_BUCKET,
por.contentType = @"image/jpeg"; PICTURE_NAME,
por.data = image; new java.io.File( image ) );
[s3 putObject:por]; s3.putObject( por );
// Get an Object from a Bucket // Get an Object from a Bucket
S3GetObjectRequest *gor = [[S3GetObjectRequest alloc] S3Object data = s3.getObject(PICTURE_BUCKET, PICTURE_NAME);
initWithKey:PICTURE_NAME withBucket:PICTURE_BUCKET];
S3GetObjectResponse *response = [s3 getObject:gor];
13. Queuing / Messaging (Amazon SQS, Amazon SNS)
• Queue up data for the application/user
• Send SMS/email to many users at once
• Article and sample for Amazon SNS & Amazon SQS:
• http://aws.amazon.com/articles/SDKs/9156883257507082
14. Application Feedback (Amazon SES Demo)
• Have the application send you customer feedback, stack
traces, etc.
• Don’t leave the app to go to the mail client
• Customers don’t worry about exposing their email address
• Article and sample included with SDKs for Amazon SES:
• http://aws.amazon.com/articles/SDKs/3290993028247679
16. Amazon SES Demo Code
iOS Android
// Create Amazon SES Client // Create Amazon SES Client
AmazonSESClient *ses = [[AmazonSESClient alloc] AmazonSESClient ses = new AmazonSESClient(
initWithAccessKey:ACCESS_KEY_ID withSecretKey:SECRET_KEY]; new BasicAWSCredentials( ACCESS_KEY_ID, SECRET_KEY ) );
// Create the Message // Create the Message
SESMessage *message = [Utility createMessage]; Message message = Utility.createMessage();
// Send the Message // Send the Message
SESDestination *destination = [[SESDestination alloc] init]; Destination to = new
[destination.toAddresses addObject:@”email@domain.com”]; Destination().withToAddresses( “email@domain.com” );
String from = “email@domain.com”;
SendEmailRequest ser= new SendEmailRequest( from, to, message );
SESSendEmailRequest *ser = [[SESSendEmailRequest alloc] init];
SendEmailResult result = ses.sendEmail( ser);
ser.source = @”email@domain.com”;
ser.destination = destination;
ser.message = message;
SESSendEmailResponse response = [ses sendEmail:ser];
17. Storing Searchable Data (Amazon DynamoDB)
• NoSQL database
• SDKs have low and high level interfaces:
• AWS Persistence Framework for Core Data
• DynamoDB Mapper for Android
• Articles and samples for all interfaces included in SDKs:
• http://aws.amazon.com/articles/SDKs/7439603059327617
• http://aws.amazon.com/articles/SDKs/4435846131581972
• http://aws.amazon.com/articles/SDKs/3756417425850538
18. Managing Credentials
• DO NOT embed your ROOT credentials
• If compromised, your entire AWS account is accessible
19. Managing Credentials
• Create an IAM account with limited permissions?
{ "Statement : [{
"Effect":"Allow",
"Action":["s3:PutObject","s3:GetObject"],
"Resource":"arn:aws:s3:::my_bucket/*"}]
}
• DO NOT embed IAM account credentials
• Can’t rotate the credentials
• NO individual user controls or revocation
20. Token Vending Machine
TVM STS
Simple
DB
temporary
get token credentials
requests via AWS mobile SDK
using temporary credentials
21. Token Vending Machine
• DO NOT EMBED YOUR CREDENTIALS!
• http://aws.amazon.com/articles/SDKs/4611615499399490
• Full Application TVM sample
• http://aws.amazon.com/code/4598681430241367
22. Token Vending Machine Demo
• Amazon S3 personal file store demo using the token
vending machine
25. How Do I Get Help/Support Using the Mobile SDKs?
• Community support available through the AWS forums
• https://forums.aws.amazon.com/forum.jspa?forumID=88
• SDKs contain a number of samples and articles
• AWS mobile blogs
• Release updates
• Tips & Tricks
26. Where’s the Source?
• All SDK source is available on GitHub:
• http://github.com/aws/aws-sdk-android
• http://github.com/aws/aws-sdk-ios
• Source includes project files to enable you to build the
source directly
• Want something changed/improved?
• Fork and submit a pull request!
27. We are sincerely eager to #reinvent
hear your feedback on this
presentation and on re:Invent.
Please fill out an evaluation
form when you have a
chance.