You are previewing Amazon S3 Cookbook.
O'Reilly logo
Amazon S3 Cookbook

Book Description

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

About This Book

  • Learn how to store, manage, and access your data with AWS SDKs

  • Study the Amazon S3 pricing model and learn how to calculate costs by simulating practical scenarios

  • Optimize your Amazon S3 bucket by following step-by-step instructions of how to deliver your content with CloudFront, secure the S3 bucket with IAM, and lower costs with object life cycle management

  • 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.

    What You Will Learn

  • Host a static website on Amazon S3

  • Calculate costs with AWS Simple Monthly Calculators

  • Deploy a static website via CloudFormation

  • Distribute your content via CloudFront

  • Secure resources with bucket policies and IAM

  • Protect objects using server-side and client-side encryption

  • Enable Cross-Origin Resource Sharing

  • Manage objects’ life cycles to lower costs

  • Optimize performance for uploading as well as downloading objects

  • Enable S3 event notifications and create Lambda functions

  • Manage common operations with AWS SDKs

  • In Detail

    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.

    Style and approach

    A step-by-step practical guide that will show you how to efficiently store, manage, and control your data in Amazon S3.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. 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.

    Table of Contents

    1. Amazon S3 Cookbook
      1. Table of Contents
      2. Amazon S3 Cookbook
      3. Credits
      4. About the Author
      5. About the Reviewers
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
          3. Instant updates on new Packt books
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Sections
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        5. Conventions
        6. Reader feedback
        7. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      8. 1. Managing Common Operations with AWS SDKs
        1. Introduction
        2. Learning AWS SDK for Java and basic S3 operations with sample code
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        3. Learning AWS SDK for Node.js and basic S3 operations with sample code
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        4. Learning AWS SDK for Python and basic S3 operations with sample code
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        5. Learning AWS SDK for Ruby and basic S3 operations with sample code
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        6. Learning AWS SDK for PHP and basic S3 operations with sample code
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
      9. 2. Hosting a Static Website on Amazon S3 Bucket
        1. Introduction
        2. How to configure a static website on Amazon S3 bucket
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        3. How to configure S3 server access logging
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        4. How to configure a static website using a custom domain
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        5. How to configure a static website on Amazon S3 bucket with AWS CLI
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
      10. 3. Calculating Cost with the AWS Simple Monthly Calculator
        1. Introduction
        2. How to calculate and estimate S3 costs with the AWS calculator
          1. Getting ready
          2. How to do it…
            1. The first example
            2. The second example
            3. The third example
          3. How it works…
          4. There's more…
          5. See also
        3. How to annotate S3 billing by adding cost allocation tagging
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
      11. 4. Deploying a Static Website with CloudFormation
        1. Introduction
        2. How to deploy a template of a static website with CloudFormation
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Why CloudFormation failed to create a stack
            2. Deleting a stack
          5. See also
        3. How to deploy a template with AWS CLI
          1. Getting ready
          2. How to do it…
          3. How it works…
            1. Deleting a stack
            2. Validating your template
          4. See also
      12. 5. Distributing Your Contents via CloudFront
        1. Introduction
        2. How to configure a CloudFront distribution on the Amazon S3 bucket
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Using an alias record instead of alternate domain names (CNAMEs)
          5. See also
        3. How to measure throughput between S3 and CloudFront
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Amazon CloudFront limits
          5. See also
        4. How to compare costs for data transfer between S3 and CloudFront
          1. Getting ready
            1. Regional data transfer out to the Internet (per GB)
            2. Regional data transfer out to origin (per GB)
            3. Request pricing for all HTTP methods
          2. How to do it…
            1. The second example – transferred out of an S3 bucket to the Internet
            2. The third example – transferred out of CloudFront edge locations to the Internet
          3. How it works…
          4. See also
      13. 6. Securing Resources with Bucket Policies and IAM
        1. Introduction
        2. Walkthrough 1: To grant users bucket permissions
          1. Getting ready
          2. How to do it…
          3. How it works…
            1. The bucket policy
            2. The user policy
          4. See also
        3. Walkthrough 2: To grant cross-account bucket permissions
          1. Getting ready
          2. How to do it…
          3. How it works…
            1. The bucket policy
            2. The user policy
          4. See also
        4. Walkthrough 3: To grant cross-account bucket permissions to objects without ownership
          1. Getting ready
          2. How to do it…
          3. How it works…
            1. The bucket policy
          4. See also
        5. Walkthrough 4: Bucket and user policy examples
          1. Getting ready
          2. How to do it…
            1. Granting permissions to multiple accounts, specific resources, and addresses in a bucket policy
            2. Allowing a user to access a folder in a bucket in a specific region in a user policy
          3. How it works…
            1. Granting permissions to multiple accounts, specific resources and addresses in a bucket policy
            2. Allowing a user to access a folder in a bucket in a specific region in a user policy
      14. 7. Sending Authenticated Requests with AWS SDKs
        1. Introduction
        2. How to make requests using IAM user temporary credentials with AWS SDK
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        3. How to make requests using federated user temporary credentials with AWS SDK
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
      15. 8. Protecting Data Using Server-side and Client-side Encryption
        1. Introduction
        2. How to protect data using server-side encryption
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        3. How to protect data using client-side encryption
          1. AWS KMS-managed customer master key (CMK)
          2. The client-side master key
          3. Getting ready
          4. How to do it...
          5. How it works...
          6. See also
      16. 9. Enabling Cross-origin Resource Sharing
        1. Introduction
        2. Walkthrough 1: Enabling CORS through the S3 console
          1. Getting ready
          2. How to do it…
          3. How it works…
            1. The AllowedMethod element
            2. The AllowedOrigin element
            3. The AllowedHeader element
            4. The ExposeHeader element
            5. The MaxAgeSeconds element
          4. There's more…
            1. Restricting cross-origin requests from a specific domain
            2. Allowing specific headers for a preflight request
          5. See also
        3. Walkthrough 2: Enabling CORS with AWS CLI
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
      17. 10. Managing Object Lifecycle to Lower the Cost
        1. Introduction
        2. How to apply the lifecycle policy through the S3 console
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Walkthrough – applying several lifecycle policies
            2. Applying lifecycle configuration rules
            3. Object expiration for versioning and server access logging
            4. The Glacier storage class
          5. See also
        3. How to apply the lifecycle policy with AWS CLI
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Walkthrough – archiving the current version into Glacier and deleting the previous versions
            2. Archival storage charges
          5. See also…
      18. 11. S3 Performance Optimization
        1. Introduction
          1. Choosing a region to optimize latency
          2. The data consistency model
          3. Key naming schema
          4. CloudHarmony for measuring S3 performance
        2. How to optimize PUT requests
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Multipart upload specification
            2. Multipart upload and charging
          5. See also
        3. How to optimize GET requests
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Range GET request support
          5. See also
      19. 12. Creating Triggers and Notifying S3 Events to Lambda
        1. Introduction
        2. How to create a sample policy to notify S3 events
          1. Getting ready
          2. How to do it…
          3. How it works...
          4. See also
        3. How to enable S3 event notification with Lambda
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more...
          5. See also
      20. Index