Contents (hide)

Amazon Web Services

Main Services

Elastic Compute Cloud (EC2)

Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides resizable compute capacity in the cloud. It is designed to make web-scale computing easier for developers… more

  1. import java.io.File;
  2. import java.util.List;
  3. import com.amazonaws.AmazonServiceException;
  4. import com.amazonaws.auth.AWSCredentials;
  5. import com.amazonaws.auth.PropertiesCredentials;
  6. import com.amazonaws.services.ec2.AmazonEC2;
  7. import com.amazonaws.services.ec2.AmazonEC2Client;
  8. import com.amazonaws.services.ec2.model.Instance;
  9. import com.amazonaws.services.ec2.model.InstanceType;
  10. import com.amazonaws.services.ec2.model.RunInstancesRequest;
  11.  
  12. public class EC2Launch {
  13.     public static void main(String[] args) throws Exception {
  14.         AmazonEC2 ec2;
  15.         
  16.         AWSCredentials credentials = new PropertiesCredentials(EC2Launch.class.getResourceAsStream("AwsCredentials.properties"));
  17.         ec2 = new AmazonEC2Client(credentials);
  18.  
  19.         try {
  20.             // Basic 32-bit Amazon Linux AMI 1.0 (AMI Id: ami-08728661)
  21.             RunInstancesRequest request = new RunInstancesRequest("ami-08728661"11);
  22.             request.setInstanceType(InstanceType.T1Micro.toString());
  23.             List<Instanceinstances = ec2.runInstances(request).getReservation().getInstances();
  24.             System.out.println("Launch instances: " + instances);
  25.  
  26.         } catch (AmazonServiceException ase) {
  27.             System.out.println("Caught Exception: " + ase.getMessage());
  28.             System.out.println("Reponse Status Code: " + ase.getStatusCode());
  29.             System.out.println("Error Code: " + ase.getErrorCode());
  30.             System.out.println("Request ID: " + ase.getRequestId());
  31.         }
  32.  
  33.     }
  34. }

Simple Storage Service (S3)

Amazon S3 is storage for the Internet. It is designed to make web-scale computing easier for developers…more

  1. /*
  2.  * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3.  *
  4.  * Licensed under the Apache License, Version 2.0 (the "License").
  5.  * You may not use this file except in compliance with the License.
  6.  * A copy of the License is located at
  7.  *
  8.  *  http://aws.amazon.com/apache2.0
  9.  *
  10.  * or in the "license" file accompanying this file. This file is distributed
  11.  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  12.  * express or implied. See the License for the specific language governing
  13.  * permissions and limitations under the License.
  14.  */
  15. import java.io.BufferedReader;
  16.  
  17. import java.io.File;
  18. import java.io.FileOutputStream;
  19. import java.io.IOException;
  20. import java.io.InputStream;
  21. import java.io.InputStreamReader;
  22. import java.io.OutputStreamWriter;
  23. import java.io.Writer;
  24.  
  25. import com.amazonaws.AmazonClientException;
  26. import com.amazonaws.AmazonServiceException;
  27. import com.amazonaws.auth.AWSCredentials;
  28. import com.amazonaws.auth.PropertiesCredentials;
  29. import com.amazonaws.services.s3.AmazonS3;
  30. import com.amazonaws.services.s3.AmazonS3Client;
  31. import com.amazonaws.services.s3.model.GetObjectRequest;
  32. import com.amazonaws.services.s3.model.ListObjectsRequest;
  33. import com.amazonaws.services.s3.model.PutObjectRequest;
  34. import com.amazonaws.services.s3.model.Bucket;
  35. import com.amazonaws.services.s3.model.S3Object;
  36. import com.amazonaws.services.s3.model.ObjectListing;
  37. import com.amazonaws.services.s3.model.S3ObjectSummary;
  38.  
  39. /**
  40.  * This sample demonstrates how to make basic requests to Amazon S3 using
  41.  * the AWS SDK for Java.
  42.  * <p>
  43.  * <b>Prerequisites:</b> You must have a valid Amazon Web Services developer
  44.  * account, and be signed up to use Amazon S3. For more information on
  45.  * Amazon S3, see http://aws.amazon.com/s3.
  46.  * <p>
  47.  * <b>Important:</b> Be sure to fill in your AWS access credentials in the
  48.  *                   AwsCredentials.properties file before you try to run this
  49.  *                   sample.
  50.  * http://aws.amazon.com/security-credentials
  51.  */
  52. public class S3Sample {
  53.  
  54.     public static void main(String[] args) throws IOException {
  55.         /*
  56.          * Important: Be sure to fill in your AWS access credentials in the
  57.          *            AwsCredentials.properties file before you try to run this
  58.          *            sample.
  59.          * http://aws.amazon.com/security-credentials
  60.          */
  61.         AWSCredentials credentials = new PropertiesCredentials(
  62.                 S3Sample.class.getResourceAsStream("AwsCredentials.properties"));
  63.         AmazonS3 s3 = new AmazonS3Client(credentials);
  64.  
  65.         String directoryName = args[0];
  66.         
  67.         String bucketName =
  68.             credentials.getAWSAccessKeyId() + "_" + directoryName.replace('\\''_').replace('/','_').replace(':''_');
  69.         String key=null;
  70.  
  71.         System.out.println("===========================================");
  72.         System.out.println("Getting Started with Amazon S3");
  73.         System.out.println("===========================================\n");
  74.  
  75.         try {
  76.             /*
  77.              * Create a new S3 bucket - Amazon S3 bucket names are globally unique,
  78.              * so once a bucket name has been taken by any user, you can't create
  79.              * another bucket with that same name.
  80.              *
  81.              * You can optionally specify a location for your bucket if you want to
  82.              * keep your data closer to your applications or users.
  83.              */
  84.             System.out.println("Creating bucket " + bucketName + "\n");
  85.             s3.createBucket(bucketName);
  86.  
  87.             /*
  88.              * List the buckets in your account
  89.              */
  90.             System.out.println("Listing buckets");
  91.             for (Bucket bucket : s3.listBuckets()) {
  92.                 System.out.println(" - " + bucket.getName());
  93.             }
  94.             System.out.println();
  95.  
  96.             /*
  97.              * Upload an object to your bucket - You can easily upload a file to
  98.              * S3, or upload directly an InputStream if you know the length of
  99.              * the data in the stream. You can also specify your own metadata
  100.              * when uploading to S3, which allows you set a variety of options
  101.              * like content-type and content-encoding, plus additional metadata
  102.              * specific to your applications.
  103.              */
  104.             System.out.println("Uploading a new object to S3 from a file\n");
  105.             File dir = new File(directoryName);
  106.             for (File file : dir.listFiles()) {
  107.                 key = file.getName().replace('\\''_').replace('/','_').replace(':''_');
  108.                 PutObjectRequest req = new PutObjectRequest(bucketNamekeyfile);
  109.                 s3.putObject(req);
  110.             }
  111.  
  112.             /*
  113.              * Download an object - When you download an object, you get all of
  114.              * the object's metadata and a stream from which to read the contents.
  115.              * It's important to read the contents of the stream as quickly as
  116.              * possibly since the data is streamed directly from Amazon S3 and your
  117.              * network connection will remain open until you read all the data or
  118.              * close the input stream.
  119.              *
  120.              * GetObjectRequest also supports several other options, including
  121.              * conditional downloading of objects based on modification times,
  122.              * ETags, and selectively downloading a range of an object.
  123.              */
  124.             System.out.println("Downloading an object");
  125.             S3Object object = s3.getObject(new GetObjectRequest(bucketNamekey));
  126.             System.out.println("Content-Type: "  + object.getObjectMetadata().getContentType());
  127.             displayTextInputStream(object.getObjectContent());
  128.  
  129.             /*
  130.              * List objects in your bucket by prefix - There are many options for
  131.              * listing the objects in your bucket.  Keep in mind that buckets with
  132.              * many objects might truncate their results when listing their objects,
  133.              * so be sure to check if the returned object listing is truncated, and
  134.              * use the AmazonS3.listNextBatchOfObjects(...) operation to retrieve
  135.              * additional results.
  136.              */
  137.             System.out.println("Listing objects");
  138.             ObjectListing objectListing = s3.listObjects(new ListObjectsRequest()
  139.                     .withBucketName(bucketName)
  140.                     .withPrefix("My"));
  141.             for (S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) {
  142.                 System.out.println(" - " + objectSummary.getKey() + "  " +
  143.                                    "(size = " + objectSummary.getSize() + ")");
  144.             }
  145.             System.out.println();
  146.  
  147.             /*
  148.              * Delete an object - Unless versioning has been turned on for your bucket,
  149.              * there is no way to undelete an object, so use caution when deleting objects.
  150.              */
  151.             System.out.println("Deleting an object\n");
  152.             s3.deleteObject(bucketNamekey);
  153.  
  154.             /*
  155.              * Delete a bucket - A bucket must be completely empty before it can be
  156.              * deleted, so remember to delete any objects from your buckets before
  157.              * you try to delete them.
  158.              */
  159.             System.out.println("Deleting bucket " + bucketName + "\n");
  160.             s3.deleteBucket(bucketName);
  161.         } catch (AmazonServiceException ase) {
  162.             System.out.println("Caught an AmazonServiceException, which means your request made it "
  163.                     + "to Amazon S3, but was rejected with an error response for some reason.");
  164.             System.out.println("Error Message:    " + ase.getMessage());
  165.             System.out.println("HTTP Status Code: " + ase.getStatusCode());
  166.             System.out.println("AWS Error Code:   " + ase.getErrorCode());
  167.             System.out.println("Error Type:       " + ase.getErrorType());
  168.             System.out.println("Request ID:       " + ase.getRequestId());
  169.         } catch (AmazonClientException ace) {
  170.             System.out.println("Caught an AmazonClientException, which means the client encountered "
  171.                     + "a serious internal problem while trying to communicate with S3, "
  172.                     + "such as not being able to access the network.");
  173.             System.out.println("Error Message: " + ace.getMessage());
  174.         }
  175.     }
  176.  
  177.     /**
  178.      * Displays the contents of the specified input stream as text.
  179.      *
  180.      * @param input
  181.      *            The input stream to display as text.
  182.      *
  183.      * @throws IOException
  184.      */
  185.     private static void displayTextInputStream(InputStream input) throws IOException {
  186.         BufferedReader reader = new BufferedReader(new InputStreamReader(input));
  187.         while (true) {
  188.             String line = reader.readLine();
  189.             if (line == null) break;
  190.  
  191.             System.out.println("    " + line);
  192.         }
  193.         System.out.println();
  194.     }
  195.  
  196. }

Simple Queue Service

Amazon Simple Queue Service (Amazon SQS) offers a reliable, highly scalable, hosted queue for storing messages as they travel between computers. By using Amazon SQS, developers can simply move data between distributed components of their applications that perform different tasks, without losing messages or requiring each component to be always available. Amazon SQS makes it easy to build an automated workflow, working in close conjunction with the Amazon Elastic Compute Cloud (Amazon EC2) and the other AWS infrastructure web services…more

  1. /*
  2.  * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3.  *
  4.  * Licensed under the Apache License, Version 2.0 (the "License").
  5.  * You may not use this file except in compliance with the License.
  6.  * A copy of the License is located at
  7.  *
  8.  *  http://aws.amazon.com/apache2.0
  9.  *
  10.  * or in the "license" file accompanying this file. This file is distributed
  11.  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  12.  * express or implied. See the License for the specific language governing
  13.  * permissions and limitations under the License.
  14.  */
  15. import java.util.List;
  16. import java.util.UUID;
  17. import java.util.Map.Entry;
  18.  
  19. import com.amazonaws.AmazonClientException;
  20. import com.amazonaws.AmazonServiceException;
  21. import com.amazonaws.auth.PropertiesCredentials;
  22. import com.amazonaws.services.sqs.AmazonSQS;
  23. import com.amazonaws.services.sqs.AmazonSQSClient;
  24. import com.amazonaws.services.sqs.model.CreateQueueRequest;
  25. import com.amazonaws.services.sqs.model.DeleteMessageRequest;
  26. import com.amazonaws.services.sqs.model.DeleteQueueRequest;
  27. import com.amazonaws.services.sqs.model.Message;
  28. import com.amazonaws.services.sqs.model.ReceiveMessageRequest;
  29. import com.amazonaws.services.sqs.model.SendMessageRequest;
  30.  
  31. /**
  32.  * This sample demonstrates how to make basic requests to Amazon SQS using the
  33.  * AWS SDK for Java.
  34.  * <p>
  35.  * <b>Prerequisites:</b> You must have a valid Amazon Web
  36.  * Services developer account, and be signed up to use Amazon SQS. For more
  37.  * information on Amazon SQS, see http://aws.amazon.com/sqs.
  38.  * <p>
  39.  * <b>Important:</b> Be sure to fill in your AWS access credentials in the
  40.  *                   AwsCredentials.properties file before you try to run this
  41.  *                   sample.
  42.  * http://aws.amazon.com/security-credentials
  43.  */
  44. public class SimpleQueueServiceSample {
  45.  
  46.     public static void main(String[] args) throws Exception {
  47.         /*
  48.          * Important: Be sure to fill in your AWS access credentials in the
  49.          *            AwsCredentials.properties file before you try to run this
  50.          *            sample.
  51.          * http://aws.amazon.com/security-credentials
  52.          */
  53.         AmazonSQS sqs = new AmazonSQSClient(new PropertiesCredentials(
  54.                 SimpleQueueServiceSample.class.getResourceAsStream("AwsCredentials.properties")));
  55.  
  56.         System.out.println("===========================================");
  57.         System.out.println("Getting Started with Amazon SQS");
  58.         System.out.println("===========================================\n");
  59.  
  60.         try {
  61.             // Create a queue
  62.             System.out.println("Creating a new SQS queue called MyQueue.\n");
  63.             CreateQueueRequest createQueueRequest = new CreateQueueRequest("MyQueue"UUID.randomUUID());
  64.             String myQueueUrl = sqs.createQueue(createQueueRequest).getQueueUrl();
  65.  
  66.             // List queues
  67.             System.out.println("Listing all queues in your account.\n");
  68.             for (String queueUrl : sqs.listQueues().getQueueUrls()) {
  69.                 System.out.println("  QueueUrl: " + queueUrl);
  70.             }
  71.             System.out.println();
  72.  
  73.             // Send a message
  74.             System.out.println("Sending a message to MyQueue.\n");
  75.             sqs.sendMessage(new SendMessageRequest(myQueueUrl"This is my message text."));
  76.  
  77.             // Receive messages
  78.             System.out.println("Receiving messages from MyQueue.\n");
  79.             ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(myQueueUrl);
  80.             List<Messagemessages = sqs.receiveMessage(receiveMessageRequest).getMessages();
  81.             for (Message message : messages) {
  82.                 System.out.println("  Message");
  83.                 System.out.println("    MessageId:     " + message.getMessageId());
  84.                 System.out.println("    ReceiptHandle: " + message.getReceiptHandle());
  85.                 System.out.println("    MD5OfBody:     " + message.getMD5OfBody());
  86.                 System.out.println("    Body:          " + message.getBody());
  87.                 for (Entry<StringStringentry : message.getAttributes().entrySet()) {
  88.                     System.out.println("  Attribute");
  89.                     System.out.println("    Name:  " + entry.getKey());
  90.                     System.out.println("    Value: " + entry.getValue());
  91.                 }
  92.             }
  93.             System.out.println();
  94.  
  95.             // Delete a message
  96.             System.out.println("Deleting a message.\n");
  97.             String messageRecieptHandle = messages.get(0).getReceiptHandle();
  98.             sqs.deleteMessage(new DeleteMessageRequest(myQueueUrlmessageRecieptHandle));
  99.  
  100.             // Delete a queue
  101.             System.out.println("Deleting the test queue.\n");
  102.             sqs.deleteQueue(new DeleteQueueRequest(myQueueUrl));
  103.         } catch (AmazonServiceException ase) {
  104.             System.out.println("Caught an AmazonServiceException, which means your request made it " +
  105.                     "to Amazon SQS, but was rejected with an error response for some reason.");
  106.             System.out.println("Error Message:    " + ase.getMessage());
  107.             System.out.println("HTTP Status Code: " + ase.getStatusCode());
  108.             System.out.println("AWS Error Code:   " + ase.getErrorCode());
  109.             System.out.println("Error Type:       " + ase.getErrorType());
  110.             System.out.println("Request ID:       " + ase.getRequestId());
  111.         } catch (AmazonClientException ace) {
  112.             System.out.println("Caught an AmazonClientException, which means the client encountered " +
  113.                     "a serious internal problem while trying to communicate with SQS, such as not " +
  114.                     "being able to access the network.");
  115.             System.out.println("Error Message: " + ace.getMessage());
  116.         }
  117.     }
  118. }

Simple DB

Amazon SimpleDB is a highly available, scalable, and flexible non-relational data store that offloads the work of database administration. Developers simply store and query data items via web services requests, and Amazon SimpleDB does the rest…more

  1. /*
  2.  * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3.  *
  4.  * Licensed under the Apache License, Version 2.0 (the "License").
  5.  * You may not use this file except in compliance with the License.
  6.  * A copy of the License is located at
  7.  *
  8.  *  http://aws.amazon.com/apache2.0
  9.  *
  10.  * or in the "license" file accompanying this file. This file is distributed
  11.  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  12.  * express or implied. See the License for the specific language governing
  13.  * permissions and limitations under the License.
  14.  */
  15. import java.util.ArrayList;
  16. import java.util.List;
  17.  
  18. import com.amazonaws.AmazonClientException;
  19. import com.amazonaws.AmazonServiceException;
  20. import com.amazonaws.auth.AWSCredentials;
  21. import com.amazonaws.auth.PropertiesCredentials;
  22. import com.amazonaws.services.simpledb.AmazonSimpleDB;
  23. import com.amazonaws.services.simpledb.AmazonSimpleDBClient;
  24. import com.amazonaws.services.simpledb.model.Attribute;
  25. import com.amazonaws.services.simpledb.model.BatchPutAttributesRequest;
  26. import com.amazonaws.services.simpledb.model.CreateDomainRequest;
  27. import com.amazonaws.services.simpledb.model.DeleteAttributesRequest;
  28. import com.amazonaws.services.simpledb.model.DeleteDomainRequest;
  29. import com.amazonaws.services.simpledb.model.Item;
  30. import com.amazonaws.services.simpledb.model.PutAttributesRequest;
  31. import com.amazonaws.services.simpledb.model.ReplaceableAttribute;
  32. import com.amazonaws.services.simpledb.model.ReplaceableItem;
  33. import com.amazonaws.services.simpledb.model.SelectRequest;
  34.  
  35. /**
  36.  * This sample demonstrates how to make basic requests to Amazon SimpleDB using
  37.  * the AWS SDK for Java.
  38.  * <p>
  39.  * <b>Prerequisites:</b> You must have a valid Amazon Web Services developer
  40.  * account, and be signed up to use Amazon SimpleDB. For more information on
  41.  * Amazon SimpleDB, see http://aws.amazon.com/simpledb.
  42.  * <p>
  43.  * <b>Important:</b> Be sure to fill in your AWS access credentials in the
  44.  *                   AwsCredentials.properties file before you try to run this
  45.  *                   sample.
  46.  * http://aws.amazon.com/security-credentials
  47.  */
  48. public class SimpleDBSample {
  49.  
  50.     public static void main(String[] args) throws Exception {
  51.         /*
  52.          * Important: Be sure to fill in your AWS access credentials in the
  53.          *            AwsCredentials.properties file before you try to run this
  54.          *            sample.
  55.          * http://aws.amazon.com/security-credentials
  56.          */
  57.         
  58.         AmazonSimpleDB sdb = new AmazonSimpleDBClient(new PropertiesCredentials(
  59.                 SimpleDBSample.class.getResourceAsStream("AwsCredentials.properties")));
  60.  
  61.         System.out.println("===========================================");
  62.         System.out.println("Getting Started with Amazon SimpleDB");
  63.         System.out.println("===========================================\n");
  64.  
  65.         try {
  66.             // Create a domain
  67.             String myDomain = "MyStore";
  68.             System.out.println("Creating domain called " + myDomain + ".\n");
  69.             sdb.createDomain(new CreateDomainRequest(myDomain));
  70.  
  71.             // List domains
  72.             System.out.println("Listing all domains in your account:\n");
  73.             for (String domainName : sdb.listDomains().getDomainNames()) {
  74.                 System.out.println("  " + domainName);
  75.             }
  76.             System.out.println();
  77.  
  78.             // Put data into a domain
  79.             System.out.println("Putting data into " + myDomain + " domain.\n");
  80.             sdb.batchPutAttributes(new BatchPutAttributesRequest(myDomaincreateSampleData()));
  81.  
  82.             // Select data from a domain
  83.             // Notice the use of backticks around the domain name in our select expression.
  84.             String selectExpression = "select * from `" + myDomain + "` where Category = 'Clothes'";
  85.             System.out.println("Selecting: " + selectExpression + "\n");
  86.             SelectRequest selectRequest = new SelectRequest(selectExpression);
  87.             for (Item item : sdb.select(selectRequest).getItems()) {
  88.                 System.out.println("  Item");
  89.                 System.out.println("    Name: " + item.getName());
  90.                 for (Attribute attribute : item.getAttributes()) {
  91.                     System.out.println("      Attribute");
  92.                     System.out.println("        Name:  " + attribute.getName());
  93.                     System.out.println("        Value: " + attribute.getValue());
  94.                 }
  95.             }
  96.             System.out.println();
  97.  
  98.             // Delete values from an attribute
  99.             System.out.println("Deleting Blue attributes in Item_O3.\n");
  100.             Attribute deleteValueAttribute = new Attribute("Color""Blue");
  101.             sdb.deleteAttributes(new DeleteAttributesRequest(myDomain"Item_03")
  102.                     .withAttributes(deleteValueAttribute));
  103.  
  104.             // Delete an attribute and all of its values
  105.             System.out.println("Deleting attribute Year in Item_O3.\n");
  106.             sdb.deleteAttributes(new DeleteAttributesRequest(myDomain"Item_03")
  107.                     .withAttributes(new Attribute().withName("Year")));
  108.  
  109.             // Replace an attribute
  110.             System.out.println("Replacing Size of Item_03 with Medium.\n");
  111.             List<ReplaceableAttributereplaceableAttributes = new ArrayList<ReplaceableAttribute>();
  112.             replaceableAttributes.add(new ReplaceableAttribute("Size""Medium"true));
  113.             sdb.putAttributes(new PutAttributesRequest(myDomain"Item_03"replaceableAttributes));
  114.  
  115.             // Delete an item and all of its attributes
  116.             System.out.println("Deleting Item_03.\n");
  117.             sdb.deleteAttributes(new DeleteAttributesRequest(myDomain"Item_03"));
  118.  
  119.             // Delete a domain
  120.             System.out.println("Deleting " + myDomain + " domain.\n");
  121.             sdb.deleteDomain(new DeleteDomainRequest(myDomain));
  122.         } catch (AmazonServiceException ase) {
  123.             System.out.println("Caught an AmazonServiceException, which means your request made it "
  124.                     + "to Amazon SimpleDB, but was rejected with an error response for some reason.");
  125.             System.out.println("Error Message:    " + ase.getMessage());
  126.             System.out.println("HTTP Status Code: " + ase.getStatusCode());
  127.             System.out.println("AWS Error Code:   " + ase.getErrorCode());
  128.             System.out.println("Error Type:       " + ase.getErrorType());
  129.             System.out.println("Request ID:       " + ase.getRequestId());
  130.         } catch (AmazonClientException ace) {
  131.             System.out.println("Caught an AmazonClientException, which means the client encountered "
  132.                     + "a serious internal problem while trying to communicate with SimpleDB, "
  133.                     + "such as not being able to access the network.");
  134.             System.out.println("Error Message: " + ace.getMessage());
  135.         }
  136.     }
  137.  
  138.     /**
  139.      * Creates an array of SimpleDB ReplaceableItems populated with sample data.
  140.      *
  141.      * @return An array of sample item data.
  142.      */
  143.     private static List<ReplaceableItemcreateSampleData() {
  144.         List<ReplaceableItemsampleData = new ArrayList<ReplaceableItem>();
  145.  
  146.         sampleData.add(new ReplaceableItem("Item_01").withAttributes(
  147.                 new ReplaceableAttribute("Category""Clothes"true),
  148.                 new ReplaceableAttribute("Subcategory""Sweater"true),
  149.                 new ReplaceableAttribute("Name""Cathair Sweater"true),
  150.                 new ReplaceableAttribute("Color""Siamese"true),
  151.                 new ReplaceableAttribute("Size""Small"true),
  152.                 new ReplaceableAttribute("Size""Medium"true),
  153.                 new ReplaceableAttribute("Size""Large"true)));
  154.  
  155.         sampleData.add(new ReplaceableItem("Item_02").withAttributes(
  156.                 new ReplaceableAttribute("Category""Clothes"true),
  157.                 new ReplaceableAttribute("Subcategory","Pants"true),
  158.                 new ReplaceableAttribute("Name""Designer Jeans"true),
  159.                 new ReplaceableAttribute("Color""Paisley Acid Wash"true),
  160.                 new ReplaceableAttribute("Size""30x32"true),
  161.                 new ReplaceableAttribute("Size""32x32"true),
  162.                 new ReplaceableAttribute("Size""32x34"true)));
  163.  
  164.         sampleData.add(new ReplaceableItem("Item_03").withAttributes(
  165.                 new ReplaceableAttribute("Category""Clothes"true),
  166.                 new ReplaceableAttribute("Subcategory""Pants"true),
  167.                 new ReplaceableAttribute("Name""Sweatpants"true),
  168.                 new ReplaceableAttribute("Color""Blue"true),
  169.                 new ReplaceableAttribute("Color""Yellow"true),
  170.                 new ReplaceableAttribute("Color""Pink"true),
  171.                 new ReplaceableAttribute("Size""Large"true),
  172.                 new ReplaceableAttribute("Year""2006"true),
  173.                 new ReplaceableAttribute("Year""2007"true)));
  174.  
  175.         sampleData.add(new ReplaceableItem("Item_04").withAttributes(
  176.                 new ReplaceableAttribute("Category""Car Parts"true),
  177.                 new ReplaceableAttribute("Subcategory""Engine"true),
  178.                 new ReplaceableAttribute("Name""Turbos"true),
  179.                 new ReplaceableAttribute("Make""Audi"true),
  180.                 new ReplaceableAttribute("Model""S4"true),
  181.                 new ReplaceableAttribute("Year""2000"true),
  182.                 new ReplaceableAttribute("Year""2001"true),
  183.                 new ReplaceableAttribute("Year""2002"true)));
  184.  
  185.         sampleData.add(new ReplaceableItem("Item_05").withAttributes(
  186.                 new ReplaceableAttribute("Category""Car Parts"true),
  187.                 new ReplaceableAttribute("Subcategory""Emissions"true),
  188.                 new ReplaceableAttribute("Name""O2 Sensor"true),
  189.                 new ReplaceableAttribute("Make""Audi"true),
  190.                 new ReplaceableAttribute("Model""S4"true),
  191.                 new ReplaceableAttribute("Year""2000"true),
  192.                 new ReplaceableAttribute("Year""2001"true),
  193.                 new ReplaceableAttribute("Year""2002"true)));
  194.  
  195.         return sampleData;
  196.     }
  197. }

Java SDK for Amazon Web Services

AWS SDK for Java

API Reference

The Difference Between Amazon S3 and Amazon EBS

Amazon S3 vs Amazon EBS

Use case: Running MySQL on Amazon EC2 with EBS

Tutorial