webinar aws 201 delivering apps without servers

Post on 22-Nov-2014

617 Views

Category:

Internet

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

Businesses around the world are running their websites and applications in the cloud to lower costs, improve time-to-market, and enable rapid scalability. Regardless of your use case or industry it is crucial that your website and applications are always available, auto-scale up and down according to demand and operate at a low cost. Join this webinar to learn about Amazon's S3 which provides highly durable and available cloud storage for a variety of content, ranging from web applications to media files and allows you to distribute your content directly from Amazon S3. In this session we will showcase the AWS SDKs for JavaScript for Node.js and JavaScript for the Browser.

TRANSCRIPT

AWS$201$

Delivering$Apps$and$Websites$Without$Servers$

Markku$Lepistö$=$Technology$Evangelist$@markkulepisto$

Housekeeping$

•  Q&A$using$the$quesHons$panel$during$the$presentaHon$•  Reminder$–$Fill$in$the$survey!$

JavaScript!is everywhere. !

AWS SDK for !JavaScript in Node.js !

AWS SDK for !JavaScript in the Browser !

Desktop or mobile devices !

Let’s use them. !

Goals!

1.  Learn about AWS SDK for Node.js!

2.  Introduce AWS SDK for JavaScript in the Browser!

3. Write a two-tiered web application using JavaScript, HTML, and CSS!

AWS SDK for !Node.js!

Full Service Coverage !Support for over 30 AWS services !

Extensible Clients !Customize any part of the request cycle !

Standard Node.js Idioms !Streams, EventEmitter, Domains!

Open Source !Apache License, Version 2.0 !

http://github.com/aws/aws-sdk-js !

AWS SDK!for Node.js!

30+ Services!Extensible!Idiomatic!Open Source!

Getting Started!AWS SDK for Node.js !

$ npm install aws-sdkBash!

Installing!

var AWS = require(‘aws-sdk’);JS!

Loading !

Configuring!the SDK!AWS.config!

Credentials *!Region *!Extras!

* Required by the SDK!

Configuring Credentials!

IAM roles for EC2 Instances"Environment Variables !File System (outside source control)!

Do Not Hardcode Credentials!

Unless they are read-only and scoped to specific resources. !

IAM Roles for EC2 Instances !

=!Zero Configuration!

Environment Variables !AWS_ACCESS_KEY_ID!AWS_SECRET_ACCESS_KEY!AWS_REGION* !

Configuring!Region and Extras !

AWS.config.update({ region: ‘ap-southeast-1’, // AWS_REGION maxRetries: 10, // default: 3 logger: process.stdout, // ... more options ...});

JS!

AWS.config.loadFromPath(‘./config.json’);JS!

Config From a File !

If this file contains credentials, keep it out of source control !

Working with Services!

Service Objects !

AWS.S3!AWS.EC2!AWS.DynamoDB!AWS.SQS!AWS.SNS!...!

var ec2 = new AWS.EC2([config]);JS!

Constructing a Service Object!

ec2.describeInstances(params, callback);JS!

Calling an Operation !

function (err, data) { ... }JS!

The Callback!

var req = ec2.describeInstances(params);JS!

Getting a Request Object !

var resp = req.send(callback);JS!

Sending the Request Object!

req.on(‘complete’, function(resp) { ... });JS!

Adding Listeners !to the Request Object !

The Request Cycle!

Send AWS.Request !Get AWS.Response !

AWS.Request"

Operation"

AWS.Response"

build! sign! send!

complete!success!

error!

Emitted Lifecycle Events"

... ... ...

Request Lifecycle !

callback!send()!

AWS.Request!.send(callback)!.on(event, callback)!.httpRequest!...!

AWS.Response!

.error!

.data!

.retryCount!

.httpResponse!

...!

Request!Lifecycle !Recap!

Send AWS.Request !Emits Lifecycle Events !Callback with AWS.Response !

Features!of the SDK!

SDK Features!

Global Configuration Object!Bound Parameters !Response Pagination!Event Listeners (Per-Service and Global)!API Version Locking!Secure Credential Management !

Demo!

AWS SDK!for JavaScript!in the Browser !

language!

Getting the SDK !<script src=”https://sdk.amazonaws.com/js/aws-sdk-2.0.18.min.js” />

7 Supported Services!

S3!DynamoDB!SQS!SNS!STS!Kinesis!CloudWatch!

All Modern Browsers!

28.0+! 23.0+! 10+! 17.0+! 5.1+!

Usage is the same. !But in your browser or mobile device !

Configuration!is Different !

Two-Tier Web Applications !

Why is it different?!

Traditional Application Architecture!

Other Services!Node.js Backend !

Your Services!

Two-Tier Application Architecture !

Your Services !

SDK on the Device !

Benefits!

Fewer moving parts!Easy prototyping!Deploying as simple as copying files to Amazon S3 !Fully dynamic app for pennies a month !

Next Level!Web Apps !

App!Ideas!

Forum Software!Blog Commenting Service!Blogging Platform !Firefox/Chrome Extensions !WinRT (Metro Style) Apps!Any Mobile App!!

Let’s Look at a!Web Application!

Using nothing but !HTML, CSS, and JavaScript!

A Simple Blog!Content stored in Amazon DynamoDB !

Assets in Amazon S3 !

Demo!

Key Differences!Three-Tier to Two-Tier !

Browser Security !CORS in the browser Credentials on device !

Cross-Origin Resource Sharing !

CORS!Browser sends pre-flight request to external host.!Host acknowledges browser.!Browser sends XHR request.!

CORS!+ S3!

CORS needs special configuration on Amazon S3.!Configure CORS with bucket policy.!

Configuring CORS on Amazon S3 !

Getting Credentials !Onto Your Device!

Getting!Credentials!

Onto Your Device!

Never hardcode credentials"Use Web Identity Federation !

Web Identity Federation!Use Facebook, Google, or log in with

Amazon as third-party identity providers !

Web Identity Federation!Set up IAM roles for !

these identity providers !

1

2

3

Web Identity Federation!Set up permissions for IAM role !

AWS.config.credentials = new AWS.WebIdentityCredentials({ RoleArn: ‘arn:aws:iam::<ACCOUNT_ID>:role/<ROLE_NAME>’, ProviderId: ‘graph.facebook.com’, WebIdentityToken: fbAccessToken});

JS!

AWS.WebIdentityCredentials !

// 1. Load the FB JS SDK// 2. Call FB.login()FB.login(function (response) { if (response.authResponse) { fbAccessToken = response.authResponse.accessToken; AWS.config.credentials = new AWS.WebIdentityCredentials({...});});

JS!

Get a Facebook Access Token !

Same Concept !For other identity providers !

Amazon Cognito support in!AWS SDKs for JavaScript in !

Node.js & the Browser !Easy Identity Management & Content Sync!

Our Community !

We ♥!Open Source !

https://github.com/ !aws/aws-sdk-js !

Contributing!to the SDK!

Improve Documentation !Report Issues!Submit Pull Requests!Third-Party Plugins!

Third Party Plugins!A great way to add features!

Node.js!

Write More! !

Thank$you$

Markku$Lepistö$=$Technology$Evangelist$@markkulepisto$

Your$feedback$is$important$

Please$complete$the$Survey!$What’s'good,'what’s'not'

What'you'want'to'see'at'these'events'

What'you'want'AWS'to'deliver'for'you'

top related