Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Amazon S3 Cookbook (n)
Amazon S3 Cookbook (n)

Amazon S3 Cookbook (n): Over 30 hands-on recipes that will get you up and running with Amazon Simple Storage Service (S3) efficiently

eBook
$9.99 $43.99
Paperback
$54.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Amazon S3 Cookbook (n)

Chapter 2. Hosting a Static Website on Amazon S3 Bucket

Instead of running Web servers such as Apache or Nginx on EC2 instances, Amazon S3 supports hosting a static website content over Amazon S3 buckets. It is much easier rather than installing, running, and managing your web servers on your own because all you need to do is to create a bucket, add a website configuration to your bucket, apply a bucket policy, and upload your contents, plus configure a custom domain if you want to use your own domain.

In this chapter, you will learn how to:

  • How to configure a static website on Amazon S3 bucket
  • How to configure S3 server access logging
  • How to configure a static website using a custom domain
  • How to configure a static website on Amazon S3 bucket with AWS CLI

Introduction

Amazon S3 is not only storing objects on buckets and accessing them over the Internet, but is also available as a static website with client-side techniques such as HTML, CSS, and JavaScript, which does not require server-side scripts such as ASP.NET, PHP, or JSP.

The benefits of hosting a static website on Amazon S3 are as follows:

  • Low cost: The charges are data storing and data transfer fees
  • Reliable routing: This allows you to map a custom domain and route customers to your website with Route53
  • Low latency: This delivers the content from the closest location to the customer by caching the content in the edge location over the world with CloudFront
  • Low maintenance: Amazon S3 consists of an automatic self-hearing infrastructure and is designed with 99.999999999 percent durability and 99.99 percent availability of objects over a given year by synchronously storing your data across multiple facilities

How to configure a static website on Amazon S3 bucket

In this section, we will create an S3 bucket and enable website hosting configuring properties and adding a bucket policy on the bucket through the S3 console. Next, we will upload a sample static content to the bucket, and verify that the content is available over the Internet in the browser.

Getting ready

You don't need to request or fill-in any form to host a static website on Amazon S3 through the Amazon Management Console; nor do you pay any initial cost.

Before configuring a static website on Amazon S3, all you need to do is sign up to the AWS management console and access S3 using your IAM credentials.

How to do it…

Proceed with the following steps to host a static website on the Amazon S3 bucket. The point is to apply a bucket policy and enable a static website over the bucket after creating an S3 bucket and uploading your content through the S3 management console. Finally, an S3 website endpoint is generated, and you...

How to configure S3 server access logging

This section describes about how to record access logging for access to your bucket because S3 server access logging is disabled, by default, and S3 does not store server access in the log files. We will configure server access logging over an S3 bucket and verify that log files are generated when we access the S3 website.

Getting ready

If you run a web server, you may want to see and analyze the web server's access log files for the access to your website. To configure server access logging, you need to enable S3 Server Access Logging for your bucket on your own because it is not enabled by default. You can choose two ways to store access log objects in an S3 bucket, as follows:

  1. Create another bucket for server access logging.
  2. Use the same bucket for a static website and specify a target prefix under the bucket.

We will be using the same bucket for logging by specifying a target prefix.

How to do it…

It is simple to enable S3 Server Access...

How to configure a static website using a custom domain

In the How to configure a static website on Amazon S3 bucket recipe, we created a static website on Amazon S3 bucket and we can access the website through a website endpoint. However, most of the customers want to use your custom domain for your website such as http://<your-blog-site>.com/ or http://www.<your-blog-site>.com/. In order to use a custom domain, we need to create two S3 buckets, configure a website redirect, and use Route 53 for creating a DNS record.

Getting ready

We hosted a static website on Amazon S3. Then, let's configure a static website using your custom domain.

We use two buckets to allow access for both http://www.<your_domain>/ and http://<your_domain> by redirecting from www.<your_domain> to <your_domain>.

Regarding redirect, this section describes from www.hashnao.info to hashnao.info.

Make sure that you meet the following requirements:

  • Request and register your domain name...

How to configure a static website on Amazon S3 bucket with AWS CLI

We created or configured S3 buckets through the S3 management console so far. However, the problem is that it takes time if you do the same thing again and again. If you use AWS CLI, you don't need to sign in on the AWS management console and can finish your work with the command-line alone.

Getting ready

It is sometimes tiresome to operate or integrate through Amazon management console because the interface may change even if you create an instruction and capture several images for it. We learn how to create a static website with Amazon Command Line Interface (AWS CLI). You need to meet the following requirements:

  • Install and set up AWS CLI on your PC at http://aws.amazon.com/cli/
  • Configure an IAM user and a policy to enable full access to S3 and issue an IAM credential

    Tip

    For more information about how to install and set up AWS CLI, refer to https://github.com/aws/aws-cli.

    On the other hand, one of the easiest ways to use...

Left arrow icon Right arrow icon

Description

Amazon S3 is one of the most famous and trailblazing cloud object storage services, which is highly scalable, low-latency, and economical. Users only pay for what they use and can store and retrieve any amount of data at any time over the Internet, which attracts Hadoop users who run clusters on EC2. The book starts by showing you how to install several AWS SDKs such as iOS, Java, Node.js, PHP, Python, and Ruby and shows you how to manage objects. Then, you’ll be taught how to use the installed AWS SDKs to develop applications with Amazon S3. Furthermore, you will explore the Amazon S3 pricing model and will learn how to annotate S3 billing with cost allocation tagging. In addition to this, the book covers several practical recipes about how to distribute your content with CloudFront, secure your content with IAM, optimize Amazon S3 performance, and notify S3 events with Lambada. By the end of this book, you will be successfully implementing pro-level practices, techniques, and solutions in Amazon S3.

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Aug 27, 2015
Length: 280 pages
Edition : 1st
Language : English
ISBN-13 : 9781785280702
Vendor :
Amazon
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Aug 27, 2015
Length: 280 pages
Edition : 1st
Language : English
ISBN-13 : 9781785280702
Vendor :
Amazon
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 130.97
Amazon S3 Cookbook (n)
$54.99
Amazon S3 Essentials
$38.99
Amazon EC2 Cookbook
$36.99
Total $ 130.97 Stars icon
Banner background image

Table of Contents

13 Chapters
1. Managing Common Operations with AWS SDKs Chevron down icon Chevron up icon
2. Hosting a Static Website on Amazon S3 Bucket Chevron down icon Chevron up icon
3. Calculating Cost with the AWS Simple Monthly Calculator Chevron down icon Chevron up icon
4. Deploying a Static Website with CloudFormation Chevron down icon Chevron up icon
5. Distributing Your Contents via CloudFront Chevron down icon Chevron up icon
6. Securing Resources with Bucket Policies and IAM Chevron down icon Chevron up icon
7. Sending Authenticated Requests with AWS SDKs Chevron down icon Chevron up icon
8. Protecting Data Using Server-side and Client-side Encryption Chevron down icon Chevron up icon
9. Enabling Cross-origin Resource Sharing Chevron down icon Chevron up icon
10. Managing Object Lifecycle to Lower the Cost Chevron down icon Chevron up icon
11. S3 Performance Optimization Chevron down icon Chevron up icon
12. Creating Triggers and Notifying S3 Events to Lambda Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
(2 Ratings)
5 star 0%
4 star 50%
3 star 0%
2 star 50%
1 star 0%
Andrea Oct 07, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Amazon Simple Storage Service (Amazon S3) is a cloud object storage service provided by Amazon Web Services. It’s a powerful public cloud service, usable with public cloud solutions or as a target for some on-prem servers (like backup software). But it’s also becoming a standard interface of object storage and some on-prem solutions may direcly export this service.Compared to other services this require a good understand of API and the SDK in order to use it the right way.This book help in those aspects but using practical examples and sample codes.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 a user case of 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).Chapter 3, Calculating Cost with the AWS Simple Monthly Calculator, talks about calculating the total cost of storing data and delivering objects through S3, based on a couple of scenarios.Chapter 4, Deploying a Static Website with CloudFormation, came back with the web site user cases, by 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.So several specific users cases, lot of examples, but maybe was nice start with a project and implement it step by step by using all those tools.
Amazon Verified review Amazon
Jascha Casadio Oct 07, 2015
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
Amazon S3 is one of the storage solutions offered by Amazon, as well as one of the first services of the ecosystem to be made publicly available. Despite being almost 10 years old, S3 keeps getting enriched with new features and offers scalability, high availability, and low latency at commodity costs. This makes it the obvious storage choice of everyone working with the Amazon Web Services. Still, despite this and the fact that it's there since 2006, the books dedicated to it are not many. In fact, I don't remember a single title focusing on S3, although, being one of the most basic services among those offered, any book introducing the readers to the ecosystem somehow touches it. On the other hand, it is also true that this lack of titles entirely dedicated to S3 has been compensated by the extensive, and free!, official documentation, which is easy to follow, full of examples and constantly updated. This makes it very hard for any author interested in writing a book about S3, since adding value to what Amazon already does provide is not an easy task. Still, not impossible. Amazon S3 Cookbook, a recently released title, is probably the first book entirely centered on S3.I have reread the whole S3 developers' guide recently. It's good to keep up to date with the latest whistles and bells offered by the service. Then, when I heard that this title was released at the end of August of 2015, I was very excited to get a copy and get through those almost 300 pages. Having the official documentation so fresh in my mind would have allowed me to better evaluate the value of this text. There are indeed things that the developers' guide does not cover. There were questions that I wanted answered. And I wanted this book to provide those answers. Among them, how to organize the files of the many different projects a DevOps manages into S3, through delimiters and prefixes; how to switch from a standard VCS, such as Git, to S3, allowing instances to push, pull and merge without problems; how to allow external users to access to specific resources, limiting their permissions both in space and time. Apart from these questions, there were other generic expectations. Among them, for example, a good coverage of the CLI. There are many bindings specific to different programming languages: Ruby, Java, PHP, Python. What makes everyone happy is the command line. I do honestly expect each book that doesn't explicitly claim to cover a specific language to present the examples through the CLI. Is that asking too much?Before getting into the content of the book a first quick (negative) note: the book is called a cookbook, but it is not. Cookbooks are titles that present recipes that get the reader solving a problem through the winning step-by-step approach. Amazon S3 Cookbook does not provide this typical question-answer scenario.But let's dive into the book itself! The very first thing that caught my eye is something that, unfortunately, is not new to Packt Publishing titles: faulty proofreading. Some of the commands of the examples used to present the service have, indeed, typos. Nothing fancy that the expert eye won't catch. Still, this suggests a quick and cheap proofreading which lowers the overall value of the book.Typos apart, the book feels like more about CloudFormation rather than S3. True, CloudFormation can be on top of S3 and other services, such as EC2 and Auto Scaling. Still, this book should be about S3, not CloudFormation. Chapters 4 and 5, for example, should be probably part of a different title.Another thing that I did not like is the waste of pages dedicated to do stuff through the console, rather than the CLI. In chapter 6, for example, the author takes six pages showing how to set up an IAM user that has administrator's permissions through the console. Six pages plenty of colorful screenshots that take the reader hand by hand in such a delicate and hard process. Very little space is given to do the same with the command line, which is probably the way DevOps will interact with AWS. DevOps love the command line. And coffee.Another thing that leaves a bad taste in the mouth is that concepts are not clearly explained. Let's stay on chapter 6. Chapter 6, as stated, is centered about buckets' policies and IAM. It presents different interesting scenarios of limiting access to the resources, such as granting cross-account bucket permissions. The topics covered are real-world and interesting indeed, but far from being well explained. Let's see why: "First, we create a bucket and attach a bucket policy to the bucket in Account A, and then create an IAM user in Account A and one in Account B. Lastly attach a bucket policy to the bucket owed by Account A". Attaching a bucket policy was the first thing we did, wasn't it?I must admit that when I have finished reading this book I was disappointed. It's not that most of my questions were not answered, but rather that the concepts were not clearly covered. Chapter 7, for example, which is about temporary permissions and thus among those that I was very interested in, got me more puzzled than enlightened. Overall, I don't feel like the book gives more than the official documentation does already.As usual, you can find more reviews on my personal blog: http://books.lostinmalloc.com. Feel free to pass by and share your thoughts!
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.