webinar aws 201 delivering apps without servers

80
AWS 201 Delivering Apps and Websites Without Servers Markku Lepistö = Technology Evangelist @markkulepisto

Upload: amazon-web-services

Post on 22-Nov-2014

616 views

Category:

Internet


1 download

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

Page 1: Webinar AWS 201 Delivering apps without servers

AWS$201$

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

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

Page 2: Webinar AWS 201 Delivering apps without servers

Housekeeping$

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

Page 3: Webinar AWS 201 Delivering apps without servers

JavaScript!is everywhere. !

Page 4: Webinar AWS 201 Delivering apps without servers

AWS SDK for !JavaScript in Node.js !

Page 5: Webinar AWS 201 Delivering apps without servers

AWS SDK for !JavaScript in the Browser !

Desktop or mobile devices !

Page 6: Webinar AWS 201 Delivering apps without servers

Let’s use them. !

Page 7: Webinar AWS 201 Delivering apps without servers

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!

Page 8: Webinar AWS 201 Delivering apps without servers

AWS SDK for !Node.js!

Page 9: Webinar AWS 201 Delivering apps without servers

Full Service Coverage !Support for over 30 AWS services !

Page 10: Webinar AWS 201 Delivering apps without servers

Extensible Clients !Customize any part of the request cycle !

Page 11: Webinar AWS 201 Delivering apps without servers

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

Page 12: Webinar AWS 201 Delivering apps without servers

Open Source !Apache License, Version 2.0 !

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

Page 13: Webinar AWS 201 Delivering apps without servers

AWS SDK!for Node.js!

30+ Services!Extensible!Idiomatic!Open Source!

Page 14: Webinar AWS 201 Delivering apps without servers

Getting Started!AWS SDK for Node.js !

Page 15: Webinar AWS 201 Delivering apps without servers

$ npm install aws-sdkBash!

Installing!

Page 16: Webinar AWS 201 Delivering apps without servers

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

Loading !

Page 17: Webinar AWS 201 Delivering apps without servers

Configuring!the SDK!AWS.config!

Credentials *!Region *!Extras!

* Required by the SDK!

Page 18: Webinar AWS 201 Delivering apps without servers

Configuring Credentials!

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

Page 19: Webinar AWS 201 Delivering apps without servers

Do Not Hardcode Credentials!

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

Page 20: Webinar AWS 201 Delivering apps without servers

IAM Roles for EC2 Instances !

=!Zero Configuration!

Page 21: Webinar AWS 201 Delivering apps without servers

Environment Variables !AWS_ACCESS_KEY_ID!AWS_SECRET_ACCESS_KEY!AWS_REGION* !

Page 22: Webinar AWS 201 Delivering apps without servers

Configuring!Region and Extras !

Page 23: Webinar AWS 201 Delivering apps without servers

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

JS!

Page 24: Webinar AWS 201 Delivering apps without servers

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

Config From a File !

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

Page 25: Webinar AWS 201 Delivering apps without servers

Working with Services!

Page 26: Webinar AWS 201 Delivering apps without servers

Service Objects !

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

Page 27: Webinar AWS 201 Delivering apps without servers

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

Constructing a Service Object!

Page 28: Webinar AWS 201 Delivering apps without servers

ec2.describeInstances(params, callback);JS!

Calling an Operation !

Page 29: Webinar AWS 201 Delivering apps without servers

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

The Callback!

Page 30: Webinar AWS 201 Delivering apps without servers

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

Getting a Request Object !

Page 31: Webinar AWS 201 Delivering apps without servers

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

Sending the Request Object!

Page 32: Webinar AWS 201 Delivering apps without servers

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

Adding Listeners !to the Request Object !

Page 33: Webinar AWS 201 Delivering apps without servers

The Request Cycle!

Page 34: Webinar AWS 201 Delivering apps without servers

Send AWS.Request !Get AWS.Response !

Page 35: Webinar AWS 201 Delivering apps without servers

AWS.Request"

Operation"

AWS.Response"

build! sign! send!

complete!success!

error!

Emitted Lifecycle Events"

... ... ...

Request Lifecycle !

callback!send()!

Page 36: Webinar AWS 201 Delivering apps without servers

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

Page 37: Webinar AWS 201 Delivering apps without servers

AWS.Response!

.error!

.data!

.retryCount!

.httpResponse!

...!

Page 38: Webinar AWS 201 Delivering apps without servers

Request!Lifecycle !Recap!

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

Page 39: Webinar AWS 201 Delivering apps without servers

Features!of the SDK!

Page 40: Webinar AWS 201 Delivering apps without servers

SDK Features!

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

Page 41: Webinar AWS 201 Delivering apps without servers

Demo!

Page 42: Webinar AWS 201 Delivering apps without servers

AWS SDK!for JavaScript!in the Browser !

Page 43: Webinar AWS 201 Delivering apps without servers

language!

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

Page 44: Webinar AWS 201 Delivering apps without servers

7 Supported Services!

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

Page 45: Webinar AWS 201 Delivering apps without servers

All Modern Browsers!

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

Page 46: Webinar AWS 201 Delivering apps without servers

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

Page 47: Webinar AWS 201 Delivering apps without servers

Configuration!is Different !

Page 48: Webinar AWS 201 Delivering apps without servers

Two-Tier Web Applications !

Why is it different?!

Page 49: Webinar AWS 201 Delivering apps without servers

Traditional Application Architecture!

Other Services!Node.js Backend !

Your Services!

Page 50: Webinar AWS 201 Delivering apps without servers

Two-Tier Application Architecture !

Your Services !

SDK on the Device !

Page 51: Webinar AWS 201 Delivering apps without servers

Benefits!

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

Page 52: Webinar AWS 201 Delivering apps without servers

Next Level!Web Apps !

Page 53: Webinar AWS 201 Delivering apps without servers

App!Ideas!

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

Page 54: Webinar AWS 201 Delivering apps without servers

Let’s Look at a!Web Application!

Using nothing but !HTML, CSS, and JavaScript!

Page 55: Webinar AWS 201 Delivering apps without servers

A Simple Blog!Content stored in Amazon DynamoDB !

Assets in Amazon S3 !

Page 56: Webinar AWS 201 Delivering apps without servers

Demo!

Page 57: Webinar AWS 201 Delivering apps without servers

Key Differences!Three-Tier to Two-Tier !

Browser Security !CORS in the browser Credentials on device !

Page 58: Webinar AWS 201 Delivering apps without servers

Cross-Origin Resource Sharing !

Page 59: Webinar AWS 201 Delivering apps without servers

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

Page 60: Webinar AWS 201 Delivering apps without servers

CORS!+ S3!

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

Page 61: Webinar AWS 201 Delivering apps without servers

Configuring CORS on Amazon S3 !

Page 62: Webinar AWS 201 Delivering apps without servers

Getting Credentials !Onto Your Device!

Page 63: Webinar AWS 201 Delivering apps without servers

Getting!Credentials!

Onto Your Device!

Never hardcode credentials"Use Web Identity Federation !

Page 64: Webinar AWS 201 Delivering apps without servers

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

Amazon as third-party identity providers !

Page 65: Webinar AWS 201 Delivering apps without servers

Web Identity Federation!Set up IAM roles for !

these identity providers !

Page 66: Webinar AWS 201 Delivering apps without servers

1

2

3

Page 67: Webinar AWS 201 Delivering apps without servers

Web Identity Federation!Set up permissions for IAM role !

Page 68: Webinar AWS 201 Delivering apps without servers

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

JS!

AWS.WebIdentityCredentials !

Page 69: Webinar AWS 201 Delivering apps without servers

// 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 !

Page 70: Webinar AWS 201 Delivering apps without servers

Same Concept !For other identity providers !

Page 71: Webinar AWS 201 Delivering apps without servers

Amazon Cognito support in!AWS SDKs for JavaScript in !

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

Page 72: Webinar AWS 201 Delivering apps without servers

Our Community !

Page 73: Webinar AWS 201 Delivering apps without servers

We ♥!Open Source !

Page 74: Webinar AWS 201 Delivering apps without servers

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

Page 75: Webinar AWS 201 Delivering apps without servers

Contributing!to the SDK!

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

Page 76: Webinar AWS 201 Delivering apps without servers

Third Party Plugins!A great way to add features!

Page 77: Webinar AWS 201 Delivering apps without servers

Node.js!

Page 78: Webinar AWS 201 Delivering apps without servers

Write More! !

Page 79: Webinar AWS 201 Delivering apps without servers

Thank$you$

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

Page 80: Webinar AWS 201 Delivering apps without servers

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'