Book Image

Amazon S3 Cookbook (n)

By : Naoya Hashimoto
Book Image

Amazon S3 Cookbook (n)

By: Naoya Hashimoto

Overview of this book

Table of Contents (19 chapters)
Amazon S3 Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Amazon Simple Storage Service (Amazon S3) is one of the most popular online object storage services with high scalability, durability, and automatic self-healing. It also enables programmatic access with AWS SDKs that simplify your programming tasks.

Amazon S3 Cookbook is a recipe-based practical guide that will get you up and running with using Amazon S3 efficiently. This book will not only tell you how to use several functions of Amazon S3, but it will also give you valuable information and a deeper understanding of, for example, managing buckets and objects with AWS SDKs, cost calculation, how to secure your contents, lifecycle management, and performance optimization to leverage Amazon S3 to build amazing cloud-based apps.

What this book covers

Chapter 1, Managing Common Operations with AWS SDKs, introduces what AWS SDKs can do with Amazon S3 by using the official AWS SDK sample application code to create S3 buckets and upload, list, get, and download objects into and from a bucket.

Chapter 2, Hosting a Static Website on Amazon S3 Bucket, covers hosting a static website's contents by using a custom domain on Amazon S3 instead of using web servers such as Apache or Nginx on EC2 through a management console (GUI) and AWS CLI (command line). You will also learn the merits of using Amazon S3 as a website.

Chapter 3, Calculating Cost with the AWS Simple Monthly Calculator, talks about calculating the total cost of storing data and delivering objects through S3 with the Amazon Web Services Simple Monthly Calculator (the AWS calculator), based on a couple of scenarios.

Chapter 4, Deploying a Static Website with CloudFormation, covers deploying a template of a static website with CloudFormation via the S3 console and using AWS CLI.

Chapter 5, Distributing Your Contents via CloudFront, talks about delivering a static website on S3 buckets through the CloudFront edge location (CDN), configuring S3 buckets as an origin store to minimize network latency.

Chapter 6, Securing Resources with Bucket Policies and IAM, covers managing access to resources such as buckets and objects, configuring bucket policies, and IAM users, groups, and policies.

Chapter 7, Sending Authenticated Requests with AWS SDKs, talks about making requests using IAM and federated users' temporary credentials with AWS SDKs to grant permissions to temporarily access Amazon S3 resources.

Chapter 8, Protecting Data Using Server-side and Client-side Encryption, deals with encrypting and decrypting your data using server-side and client-side encryption to securely upload and download your contents.

Chapter 9, Enabling Cross-origin Resource Sharing, shows you how to enable cross-origin resource sharing (CORS) and allow cross-origin access to S3 resources to interact with resources in a different domain for client web applications.

Chapter 10, Managing Object Lifecycle to Lower the Cost, talks about configuring lifetime cycle policies on S3 buckets to automatically delete after a certain time, using Reduced Redundancy Storage (RRS) or by archiving objects into Amazon Glacier.

Chapter 11, S3 Performance Optimization, deals with improving the performance of uploading, downloading, and getting and listing objects.

Chapter 12, Creating Triggers and Notifying S3 Events to Lambda, covers sending notifications to let AWS Lambda execute Lambda functions that enable S3 event notifications.

What you need for this book

The following packages are required to install and use AWS CLI:

  • Python 2.7 or later

  • pip

For Chapter 1, Managing Common Operations with AWS SDKs, the following packages are required to install several AWS SDKs. The details are introduced in each section:

  • J2SE Development Kit 6.0 or later for AWS SDK for Java

  • Node.js for AWS SDK for Node.js

  • Python 2.6 or 2.7 for AWS SDK for Python (Boto)

  • Ruby for AWS SDK for Ruby V2

  • PHP for AWS SDK for PHP

Who this book is for

This book is for cloud developers who have experience of using Amazon S3 and are also familiar with Amazon S3.

Sections

In this book, you will find several headings that appear frequently (Getting ready, How to do it, How it works, There's more, and See also).

To give clear instructions on how to complete a recipe, we use these sections as follows:

Getting ready

This section tells you what to expect in the recipe, and describes how to set up any software or any preliminary settings required for the recipe.

How to do it…

This section contains the steps required to follow the recipe.

How it works…

This section usually consists of a detailed explanation of what happened in the previous section.

There's more…

This section consists of additional information about the recipe in order to make the reader more knowledgeable about the recipe.

See also

This section provides helpful links to other useful information for the recipe.

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: "We can include other contexts through the use of the include directive."

A block of code is set as follows:

{
"Version":"2012-10-17",
"Statement":[{
"Sid":"PublicReadGetObjects", "Effect":"Allow", "Principal": "*", "Action":["s3:GetObject"], "Resource":["arn:aws:s3:::<your_bucket>/*"]
}]
}

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

$ aws s3 sync <your_document_directory>/ s3://<your_bucket> --region <region_name>

Example:

$ aws s3 syncmy_doc_dir/ s3://hashnao.info --region ap-northeast-1

Any command-line input or output is written as follows:

$ dig hashweb.s3-website-ap-northeast-1.amazonaws.com

; <<>>DiG 9.8.3-P1 <<>> hashweb.s3-website-ap-northeast-1.amazonaws.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 45068
;; flags: qrrdra; QUERY: 1, ANSWER: 2, AUTHORITY: 4,

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 Static Website Hosting and then select Enable website hosting."

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.

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.