Book Image

Amazon S3 Essentials

By : Sunil Gulabani
Book Image

Amazon S3 Essentials

By: Sunil Gulabani

Overview of this book

Amazon Simple Storage Service (Amazon S3), provides developers and IT teams with secure, durable, and highly-scalable object storage. Amazon S3 is easy to use, with a simple web services interface to store and retrieve any amount of data from anywhere on the web. S3 is automatically web scalable and responds to the requirements of your application and traffic, and therefore offers a key element to help companies deal dynamically with any spike in traffic for their application (such as a free e-book offer). This book starts with the basics of the Amazon S3 and its features, and you will quickly get an understanding how to use the Amazon Management Console for Amazon S3 which is the simplest way to manage Amazon S3. Next, we will cover basic operations on bucket, folder, objects. Once the basic operations are understood, you will know how to use Amazon S3 using Java SDK. Following that, you will learn about Copy Objects and Multipart copy objects for large objects size. You will also learn to manage the life cycle of bucket and how to share resources to the different domain by configuring CORS. The book will then guide you through the development and deployment of a static website on Amazon S3 using different services of Amazon. By the end of the book, you will be able to create a scalable application using Amazon S3.
Table of Contents (12 chapters)

Preface

The Amazon Simple Storage Service (Amazon S3) is an online object storage service. It can be used to store and get any data via the following:

  • The REST web service interface

  • The SOAP web service interface

  • BitTorrent

Amazon S3 is easy to configure; it's a reliable and scalable storage that stores files (objects) with high security at a nominal price. Developers or system teams don't have to worry about the data that is stored at or retrieved from Amazon S3. Amazon S3 manages the web-scale computing by itself.

What this book covers

Chapter 1, Know-How about S3, gives a brief introduction to Amazon S3, covering the basic concepts, buckets, objects, and keys. We will also discuss the features of Amazon S3 that can be utilized at minimal cost and its reliable storage service.

Chapter 2, S3 using the AWS Management Console, teaches you how to use AWS Management Console and manage buckets, folders, objects, and operations on it. Along with basic operations, you will also learn about logging and versioning.

Chapter 3, S3 using AWS SDK – Java (Part 1), shows you how to use Amazon SDK—Java for Amazon S3 web services. We will take a look at how to create, upload, get, and delete the bucket, folder, and objects.

Chapter 4, S3 using AWS SDK – Java (Part 2), explains how to copy objects. It discusses multipart copy objects, which are used for large object sizes; the bucket life cycle, which defines two ways—transition (moving to Glacier) and removal; and CORS configuration, which is used to provide access via different domains.

Chapter 5, Deploying a Website on S3, shows how to configure static website hosting along with the bucket. We will consider how to map our custom domain name with the bucket.

What you need for this book

You need the following for this book:

  • An understanding of Java

  • The Eclipse IDE

  • A browser (compatible with Amazon Management Console)

Who this book is for

This book is intended for system engineers or developers, software architects, project managers, and users who want to explore Amazon S3 SDK Java. If you want to learn about Amazon S3 quickly, then this book is for you. Basic knowledge of Java programming is expected.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Replace bucketName with the actual bucket name and OBJECT_KEY_OR_FOLDER_NAME with either your object key or the name of the folder which is supposed to be deleted."

A block of code is set as follows:

package com.chapter3;

import java.util.Date;

import com.amazonaws.AmazonClientException;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.services.s3.model.Bucket;

public class CreateBucket  extends AmazonS3ClientInitializer{
  public CreateBucket() {
    super();
  }

  public static void main(String[] args) {
    String bucketName = "sg-bucket-2015-using-java-api-" + new Date().getTime();

    CreateBucket object = new CreateBucket();
    object.createBucket(bucketName);
    object.listBucket();
  }

  public void createBucket(String bucketName){
    System.out.println("================ Create Bucket ================ ");
    try {
      System.out.println("Bucket Name: " + bucketName + "\n");
      s3.createBucket(bucketName);
    } catch (AmazonServiceException exception) {
      exception.printStackTrace();
    } catch (AmazonClientException exception) {
      exception.printStackTrace();
    }
  }

  public void listBucket(){
    System.out.println("================ Listing Buckets ================ ");
    for (Bucket bucket : s3.listBuckets()) {
      System.out.println(" - " + bucket.getName());
    }
  }
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

BucketVersioningConfiguration configuration = new
  BucketVersioningConfiguration(BucketVersioningConfiguration.ENABLED);

SetBucketVersioningConfigurationRequest request = new
  SetBucketVersioningConfigurationRequest(bucketName, configuration);

s3.setBucketVersioningConfiguration(request);

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Click on the Create New Group button."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from: https://www.packtpub.com/sites/default/files/downloads/4898OS_Graphics.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.