RSS

Getting started with Amazon Web Services

21 Jun

We are going to follow the Getting started manual which we can find in the Amazon official webpage.

First thing we have to use Amazon Web Services is subscribing as an Amazon user. We can do that in here. Basically, we should click in the ‘create an AWS account’ that we can find in the left upper part.

Once our Amazon account is created, Amazon welcome us to his service.

We need two access keys to use Amazon Web Services. The first one is an access key (ID) and the second one is a secret access key we must save to a property file in our Java project. We can get this two keys from our Amazon account from this link. In my case these is what is showed up:

After that we need to install some Eclipse tools for working with AWS projects. It is a simple thing, we should move to the Installing new software section in Eclipse. We have to add the next link to download everything we are going to work with.

After restart Eclipse we will find a new Eclipse perspective called Amazon EC2 Management which allow us to create a Java project that uses Amazon Web Services.

We change to this perspective and we can create a new AWS Java project.

As we can see we can choose among some Amazon example projects. In my case I will select the AWS Console Application checkbox. We need to add the security credentials previously seen. This security credentials will be used to connect to Amazon Web Services.

Our project explorer looks like this way :

  • AwsConsoleApp.java. It allows us to test AWS EC2Amazon S3 and Amazon SimpleDB.
  • AwsCredentials.properties. Where we are going to save our credentials keys.
  • AWS SDK for Java. These are the required libraries to use Amazon Web Services.
As we launch our java class as a console application we can see this in our Log:
===========================================
Welcome to the AWS Java SDK!
===========================================
29-may-2011 12:47:57 com.amazonaws.http.AmazonHttpClient executeHelper
INFO: Sending Request: POST https://ec2.amazonaws.com / Parameters: (SignatureVersion: 2, Signature: jxxxxxxxxxxxxxxxxxxxxxxxxB7U=, SignatureMethod: HmacSHA256, Action: DescribeAvailabilityZones, Version: 2011-02-28, AWSAccessKeyId: AxxxxxxxxxxxA, Timestamp: 2011-05-29T10:47:57.191Z, )
29-may-2011 12:47:58 org.apache.http.impl.client.DefaultRequestDirector handleResponse
ADVERTENCIA: Authentication error: Unable to respond to any of these challenges: {}
29-may-2011 12:47:58 com.amazonaws.http.AmazonHttpClient handleErrorResponse
INFO: Received error response: Status Code: 401, AWS Request ID: 4xxxxxxxxxxxxxe, AWS Error Code: OptInRequired, AWS Error Message: You are not subscribed to this service. Please go to http://aws.amazon.com to subscribe.
Caught Exception: You are not subscribed to this service. Please go to http://aws.amazon.com to subscribe.
Reponse Status Code: 401
Error Code: OptInRequired
Request ID: 4xxxxxxxxxxxxxxxxxxxxxxxxxxe
29-may-2011 12:47:58 com.amazonaws.http.AmazonHttpClient executeHelper
INFO: Sending Request: POST https://sdb.amazonaws.com / Parameters: (SignatureVersion: 2, Signature: +jxxxxxxxxxxxxxxxxxxxxxxzJYs=, SignatureMethod: HmacSHA256, Action: ListDomains, Version: 2009-04-15, AWSAccessKeyId: AxxxxxxxxxxxxxA, MaxNumberOfDomains: 100, Timestamp: 2011-05-29T10:47:58.979Z, )
29-may-2011 12:47:59 org.apache.http.impl.client.DefaultRequestDirector handleResponse
ADVERTENCIA: Authentication error: Unable to respond to any of these challenges: {}
29-may-2011 12:47:59 com.amazonaws.http.AmazonHttpClient handleErrorResponse
INFO: Received error response: Status Code: 401, AWS Request ID: 6xxxxxxxxxxxxx1, AWS Error Code: SubscriptionCheckFailed, AWS Error Message: Subscription check failed. Please sign up for Amazon SimpleDB service.
Caught Exception: Subscription check failed. Please sign up for Amazon SimpleDB service.
Reponse Status Code: 401
Error Code: SubscriptionCheckFailed
Request ID: 6xxxxxxxxxxxxxxxxxxxxxxxxx1
29-may-2011 12:47:59 com.amazonaws.http.AmazonHttpClient executeHelper
INFO: Sending Request: GET https://s3.amazonaws.com / Headers: (Content-Type: application/x-www-form-urlencoded; charset=utf-8, )
29-may-2011 12:48:00 com.amazonaws.http.AmazonHttpClient handleErrorResponse
INFO: Received error response: Status Code: 403, AWS Request ID: 7xxxxxxxxxxxxx1, AWS Error Code: NotSignedUp, AWS Error Message: Your account is not signed up for the S3 service. You must sign up before you can use S3., S3 Extended Request ID: bG/2xxxxxxxxxxxxxxxxxxxxxxxxI
Error Message:    Your account is not signed up for the S3 service. You must sign up before you can use S3.
HTTP Status Code: 403
AWS Error Code:   NotSignedUp
Error Type:       Client
Request ID:       7xxxxxxxxxxxxx1

Upppps, what’s happening?. Besides to create an Amazon Web Services acount you should subscribe to each Amazon Web Service you want to use. You need to know that Amazon services are free for a limited time. Before that tim, if you still want to access to AWS (or if you want to improve some basic functionality) you have to pay for use them. Prices are clearly showed depending on what and how much we use them.

To test our example we should subscribe to Amazon EC2Amazon S3 and Amazon SimpleDB services we saw a previous post.

For Amazon EC2 service we must verify our identity by phone.

Once we had finished with our registration we can see our AWS’s account activity. Here we can see to which Amazon services we are subscribe to.

Once we had subscribe to the different Amazon services we see that our Log looks like much better:

===========================================
Welcome to the AWS Java SDK!
===========================================
29-may-2011 13:35:21 com.amazonaws.http.AmazonHttpClient executeHelper
INFO: Sending Request: POST https://ec2.amazonaws.com / Parameters: (SignatureVersion: 2, Signature: BxxxxxxxxxxxxxxxxQ=, SignatureMethod: HmacSHA256, Action: DescribeAvailabilityZones, Version: 2011-02-28, AWSAccessKeyId: AxxxxxxxxxxxxxxA, Timestamp: 2011-05-29T11:35:21.321Z, )
29-may-2011 13:35:22 com.amazonaws.http.AmazonHttpClient handleResponse
INFO: Received successful response: 200, AWS Request ID: 4xxxxxxxxxxxxxxx5
You have access to 3 Availability Zones.
29-may-2011 13:35:22 com.amazonaws.http.AmazonHttpClient executeHelper
INFO: Sending Request: POST https://ec2.amazonaws.com / Parameters: (SignatureVersion: 2, Signature: d/xxxxxxxxxxIR0=, SignatureMethod: HmacSHA256, Action: DescribeInstances, Version: 2011-02-28, AWSAccessKeyId: AxxxxxxxxxxxxA, Timestamp: 2011-05-29T11:35:22.797Z, )
29-may-2011 13:35:23 com.amazonaws.http.AmazonHttpClient handleResponse
INFO: Received successful response: 200, AWS Request ID: 4xxxxxxxxxx-xxxxxxxxb90
You have 0 Amazon EC2 instance(s) running.
29-may-2011 13:35:23 com.amazonaws.http.AmazonHttpClient executeHelper
INFO: Sending Request: POST https://sdb.amazonaws.com / Parameters: (SignatureVersion: 2, Signature: uxxxxxxxxxxxxxxx0k=, SignatureMethod: HmacSHA256, Action: ListDomains, Version: 2009-04-15, AWSAccessKeyId: AxxxxxxxxxA, MaxNumberOfDomains: 100, Timestamp: 2011-05-29T11:35:23.008Z, )
29-may-2011 13:35:23 com.amazonaws.http.AmazonHttpClient handleResponse
INFO: Received successful response: 200, AWS Request ID: 3xxxxxf-c05b-c103xxxxxxxxxxxxxb
You have 0 Amazon SimpleDB domain(s)containing a total of 0 items.
29-may-2011 13:35:23 com.amazonaws.http.AmazonHttpClient executeHelper
INFO: Sending Request: GET https://s3.amazonaws.com / Headers: (Content-Type: application/x-www-form-urlencoded; charset=utf-8, )
29-may-2011 13:35:24 com.amazonaws.http.AmazonHttpClient handleResponse
INFO: Received successful response: 200, AWS Request ID: Exxxxxxxxxxxxx6
You have 0 Amazon S3 bucket(s), containing 0 objects with a total size of 0 bytes.

Great! …we can see that there aren’t any exception when this services are called. However, we still have to configure them.

....
You have access to 3 Availability Zones.
.....
You have 0 Amazon EC2 instance(s) running.
.....
You have 0 Amazon SimpleDB domain(s)containing a total of 0 items.
....
You have 0 Amazon S3 bucket(s), containing 0 objects with a total size of 0 bytes.

We are going to configure an Amazon EC2 instance. For not mess aroung among different services, we are going to comment the Java code required to Amazon SimpleDB and Amazon S3.

If we want to configure a new Amazon EC2 instance we need to use the AWS Management Console from our Amazon account. The AWS Management Console looks like as follows:

Something important to notice is that we have to choose our region (left upper part). In my particular case I thought that was EU West (Ireland). However, if we debug our java code we can notice that the available region only allow us to launch a new instance in the US East (Virginia) region.

We have to choose US East (Virginia) in the combobox and after that we have to click in the Launch Instance button. The wizard to create a new instances is pretty straightforward and you can configure your instances in multiple ways.

Once our instances is launched we can inspect the admin console to know lots of details about it.

Finally, we launch our Java project and we can see in our log that a new Amazon EC2 instance has been created. We can use this instance to learn more about AWS.

===========================================
Welcome to the AWS Java SDK!
===========================================
29-may-2011 16:08:24 com.amazonaws.http.AmazonHttpClient executeHelper
INFO: Sending Request: POST https://ec2.amazonaws.com / Parameters: (SignatureVersion: 2, Signature: lzcxxxxxxxxxx5q2i4=, SignatureMethod: HmacSHA256, Action: DescribeAvailabilityZones, Version: 2011-02-28, AWSAccessKeyId: AxxxxxxxxxxYA, Timestamp: 2011-05-29T14:08:23.037Z, )
29-may-2011 16:08:26 com.amazonaws.http.AmazonHttpClient handleResponse
INFO: Received successful response: 200, AWS Request ID: fxxxxxxxxxxxf
You have access to 3 Availability Zones.
29-may-2011 16:08:31 com.amazonaws.http.AmazonHttpClient executeHelper
INFO: Sending Request: POST https://ec2.amazonaws.com / Parameters: (SignatureVersion: 2, Signature: EPxxxxxxxxxxxxxxxxvUQ=, SignatureMethod: HmacSHA256, Action: DescribeInstances, Version: 2011-02-28, AWSAccessKeyId: AxxxxxxxxxxxxxxxxA, Timestamp: 2011-05-29T14:08:31.358Z, )
29-may-2011 16:08:31 com.amazonaws.http.AmazonHttpClient handleResponse
INFO: Received successful response: 200, AWS Request ID: 7cxxxxxxxxxxxxxx5
You have 1 Amazon EC2 instance(s) running.

Some helpful info can be found here:
– Docs.
– Articles and tutorials.

Remember, you are using web services. So if you want to know the available AWS operations, you can take a look at their WSDLs. For example, Amazon SimpleDB’s WSDL is this.

 
1 comentario

Publicado por en 21 junio, 2011 en Amazon Web Services

 

Etiquetas:

Una respuesta a “Getting started with Amazon Web Services

  1. Simple DB Explorer

    5 julio, 2011 at 7:31 am

    SDB Explorer has been made as an industry leading graphical user interface (GUI) to explore Amazon SimpleDB service thoroughly and in a very efficient and user friendly way.

    http://www.sdbexplorer.com/

     

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s

 
A %d blogueros les gusta esto: