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

Walkthrough 1: Enabling CORS through the S3 console


This section introduces the process of enabling S3 CORS applying CORS configuration with your S3 buckets and checking if it works uploading a sample JSON code.

Getting ready

You do not have to request permissions to enable S3 CORS. All you need to do is:

  • Sign up on AWS and access S3 with your IAM credentials

  • Launch an EC2 instance and start the web server

How to do it…

First, we configure the CORS configuration to the S3 bucket through the S3 console, and verify that the CORS configuration is applied by putting a JSON file in your S3 bucket and an HTML file in a web server on the EC2 instance. The JSON file named test.json holds sample data (id, email, and username) in the JSON format. The HTML file named index.html uses JavaScript and retrieves the sample data by sending XMLHttpRequest to the JSON file:

  1. Sign in to the AWS management console and move to the S3 console at https://console.aws.amazon.com/s3.

  2. In the S3 console, click on the bucket...