Amazon Cloud Drive and Play

Wednesday, March 30th, 2011

Amazon is awesome!

Everyone of us have a lot of music files. You can try “du -hs Music/“, I’m getting 100+GB answer, and this is just the part of my music, mostly because “df -h” is saying “Avail 4.5Gb” .
This is after I purge more than 50GB of music.

I’m also user of Grooveshark and Pandora services, because I cannot have all my music.

But the world is changing now, Amazon announced two services:

To start using both services you have to accept terms and you are ready.

Cloud Drive is build on top S3 and you get 5Gb for free. Of course you can buy more till 1000Gb. There is also Metadata Service that allows us to search our files stored into Cloud Drive.

Some photos:
Cloud Drive:

Cloud Player:

Amazon Uploader:

There is also web player as well Android app. Every purchase you made in Amazon MP3 Store or by Android App can be stored in Cloud Drive, than played from whatever place.

Hope Cloud Player for iPhone is in review queue, so it should be announced soon.

My summary: This is Awesome.


AWS CloudFormation Introduction

Sunday, February 27th, 2011

AWS CloudFormation solves the complexity of creating collections of AWS Services and Resources (RDS, EC2, etc). We can use existing Templates or create our own. From chosen Template we can easily deploy our Stack, without worries about dependency resolution of ours Services. Read more on Amazon Blog: Create Your AWS Stack From a Recipe.

CloudFormation comes for free and is fully integrated into AWS Management Console. Unfortunately you have to sing up even if you already have active AWS Account. In my case it takes few seconds and I’ve have response in my inbox.

Amazon provides article how to setup step by step WordPress blog: AWS CloudFormation in the AWS Management Console. Today this resources are supported:

  • Auto Scaling Groups
  • AWS Elastic Beanstalk
  • CloudWatch Alarms
  • EBS Volumes
  • EC2 Instances
  • EC2 Security Groups
  • Elastic IP Addresses
  • Elastic Load Balancers
  • RDS Database Instances
  • RDS Security Groups
  • SimpleDB Domains
  • SNS Topics
  • SNS Subscriptions
  • SQS Queues

We can easily start with CloudFormation by choosing template from this list and than customize it. Template is text resource in JSON format which describes our resources and from template we can create our stack. Today list of templates:

  • WordPress (blog)
  • TextPattern (content management)
  • MoinMoin (wiki)
  • Tracks (project tracking)
  • Gollum (wiki used by GitHub)
  • Drupal (content management)
  • ReviewBoard (code review tool)
  • Movable Type Open Source (blog)
  • MantisBT (bug tracker)
  • Hibari (collaboration, wiki)
  • Joomla (content management)
  • Insoshi (social apps)
  • Redmine (project mgmt)

We may also create our template. Every template may have this sections:

  • AWSTemplateFormatVersion (required): 2010-09-09
  • Description (optional): We can provide comments about our template.
  • Parameters (optional): We can define parameter of String or CommaSeparatedList type with default value. This values may be changed during stack creation.
  • Mappings (optional): We can specify conditional parameter values. This is very similar to dictionary. To get value we use Fn::FindInMap function.
  • Resources (required): Here we define resources we need with resource parameters.
  • Outputs (optional): We can define information passed back to template user.

Additionally we have pseudo parameters and functions:

  • AWS::Region parameter returns AWS Region in which the resource is created.
  • AWS::StackName parameter returns name of the stack
  • Fn::Base64 function returns Base64 encoding of input string.
  • Fn::FindInMap function returns the value of a key from a mapping declared in the Mappings.
  • Fn::GetAtt function returns the value of an attribute from a resource.
  • Fn::GetAZs function returns comma-separated list of Availability Zones for the specified region.
  • Fn::Join function appends a set of values into a single value, separated by the specified delimiter.
  • Ref function allow us to use the logical name of any resource or parameter.

See WordPress template example for easy start.

 

Conclusions

 

Amazon is lider in public cloud computing. By introducing AWS CloudFormation Amazon makes entry into cloud computing easier. The cost is also important and AWS CloudFormation comes for free, we are only paying for Resources we are using. There is limit to 20 stacks we may create, but it seams reasonable and of course we may contact with Amazon to rise this limit. Amazon also provide detailed documentation: API Reference, Getting Started Guide, User Guide and a bonus Command Line Quick Reference Card.

All that make start with cloud computing is piece of cake!


Amazon Services for iOS and Android

Tuesday, February 15th, 2011

Every time we write an application which uses Amazon Web Services, we have to write our Web Services client with http connection processing and errors handling. Amazon gives us two SDKs to simplify this tasks:

Both SDKs comes with code samples, so we may start really quickly. Currently these services are supported:

I’m iPhone fan so I will show you an usage example by building simple application and deploying it on an iPad device.

Our first step is to download AWS SDK for iOS aws-ios-sdk-0.1.0.2.zip. Next we have to unpack zip file. Inside zip file we will find:

  • src directory with SDK sources.
  • samples directory with awsBrowser sample application.
  • Documentation directory with API documentation.
  • AWSiOSSDK.framework directory with ready to use AWS iOS SDK.
  • README.html file with description of zip content
  • NOTICE.txt – information about 3rd-party code (GTMLogger)
  • LICENSE.txt – Apache License version 2.0

Unfortunately latest version has errors in framework directory (instead of soft links we have files with link as a content). We have to change this:

-rwxr–r– 1 pedro staff 26 Jan 26 09:50 Resources
-rwxr–r– 1 pedro staff 24 Jan 26 09:50 Headers
-rwxr–r– 1 pedro staff 26 Jan 26 09:50 AWSiOSSDK
drwxr-xr-x 4 pedro staff 136 Feb 2 15:05 Versions

into this (There is one more in Version directory, it is called Current and should point to A directory):

drwxr-xr-x 5 pedro staff 170 Feb 2 14:41 Versions
lrwxr-xr-x 1 pedro staff 26 Feb 2 14:42 AWSiOSSDK -> Versions/Current/AWSiOSSDK
lrwxr-xr-x 1 pedro staff 24 Feb 2 14:42 Headers -> Versions/Current/Headers
lrwxr-xr-x 1 pedro staff 26 Feb 2 14:43 Resources -> Versions/Current/Resources

Library API

Actually AWS SDK supports Amazon S3, Amazon SimpleDB, Amazon SQS and Amazon SNS.

If you want to use other Amazon services you should subclass AmazonWebSerciceClient class and use invoke: method with AmazonServiceRequest parameter (the best way is to create subclass). The method will return AmazonServiceResponse (of course subclassing for easier access to specific information will be the best choice).

Every service has own client with specific methods for service (eg. S3 client has listBuckets: and SQS client has listQueues: method):

API is very intuitive and has very good documentation, so let us move forward to the example.

Example

OK, now we are ready to start our project.

  1. Start Xcode.
  2. Choose: Create a new Xcode project.
  3. Choose: Split View-base Application.
  4. Give name to your project.
  5. Attach AWSiOSSDK.framework to project.

RootViewController is UITableViewController, which is displayed in right master part of the split view. We will use it to show our Amazon S3 bucket list (listBuckets message). The main part will be used to display list of objects stored in bucket (listObjectsInBucket message) with additional information for current context, and that’s all.

Here you will find code: awsSimpleExample.

Summary

This library simplify integration iPhone and Android application with Amazon services. The latest iOS SDK API is described on this site docs.amazonwebservices.com/AWSiOSSDK/latest. I hope Amazon developers will add other services soon.


about me

My name is Sebastian Pietrowski. I've finished Warsaw University as Master degree. During my studies I started work for merlin.pl. The primary language I use is Java but I have also programmed in Python, Ruby and Scala. I worked as a technical solution architect at merlin.pl. infrastructure when we were moving from PL/SQL to J2EE. I engineering a great performance optimized solution that made the application 10 times faster than requirements and 85 times faster as original solution.

Currently, I am working as a Senior Expert at F.Hoffmann-La Roche to help define future roadmap in design and development of Enterprise software at Roche and Genentech and build adoption for new technologies. I'm continuously mentoring new developers, helping them understand how important test driven development is and empowering them to get better at their daily job. I'm involved in many activities which brings new technologies for better and faster development. You can find more details on my LinkedIn profile.

But don’t get me wrong, I am not your typical nerd. I'm a pleasant guy that you can drink a glass of wine with me and talk about a range of topics with. My leisure activities include playing basketball, soccer and listening to music. I try to be pragmatic while staying focused on application performance and tuning with success in my daily work.

My favorite quote from Yoda's and my life’s motto is: Do, or do not. There is no try.