Would you like to build rich, browser-based applications that make direct calls to AWS services without the need for any server-side code?
- Amazon S3 to store and retrieve objects at any scale.
- Amazon SQS to read from and write to message queues.
- Amazon SNS to generate and process notifications to mobile devices and other distributed services.
- Amazon DynamoDB to store and retrieve any amount of data, at any access rate.
The SDK supports access to all of the functionality provided by each of the services listed above. You can create and populate S3 buckets, manage message queues, create, populate, and query DynamoDB tables, and much more!
Add the following tag to your HTML file to get started:
If you plan to use the S3 APIs you will first need to enable CORS (Cross-Origin Resource Sharing) on the target buckets. Using the AWS Management Console, create or open a bucket, click on Properties, and Edit CORS Configuration. The sample configuration in the box below will allow your application to perform GET, PUT, POST, and DELETE operations on the objects in the bucket:
Amazon DynamoDB, Amazon SQS, and Amazon SNS now support CORS, so you can start calling these services with no additional configuration.
Authentication and Access Control
Amazon DynamoDB now supports fine-grained access control (see my new post for more information). You can now assign permissions at the item or attribute level (or both) to your authenticated users. For example, a user can have read access to an entire table and write access to the rows (items) that they own. Read the documentation on Fine-Grained Access Control for Amazon DynamoDB to learn more.
Similarly, when using Amazon S3 with web identity federation, you can tailor read and write access to the needs of each user at the prefix or object level.
To learn more about how to configure web identity federation, read the guide on Creating Temporary Security Credentials for Mobile Apps Using Identity Providers.
Using the SDK
I wrote a little function to list the objects in an S3 bucket and display them as images. Here’s the code:
The function is invoked using a button and generates output into a pair of HTML <div> elements:
The S3 bucket contains four images:
Here’s what the page looks like before I push the button:
And here’s what it looks like after I push the button and the code runs:
As you can see, you could create a very simple photo album with a very modest amount of code. Since there’s no server-side code at all, you don’t even need a web server to host your application. Deploying your web application can be as simple as uploading it to your S3 bucket with public-read permissions. Think about the implications of this architecture, and let me know what you come up with!
Here’s some very simple uploading code:
This function is invoked by a button. Use the Browse button to select an image to upload before clicking the Upload to S3 button:
Talk to Us