Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

144
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified, or distributed in whole or in part without the express consent of Amazon.com, Inc. by Loren Segal November 15th, 2013 Writing JavaScript Applications with the AWS SDK Wednesday, November 27, 13

description

We give a guided tour of using the AWS SDK for JavaScript to create powerful web applications. Learn the best practices for configuration, credential management, streaming requests, as well as how to use some of the higher level features in the SDK. We also show a live demonstration of using AWS services with the SDK to build a real-world JavaScript application.

Transcript of Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Page 1: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified, or distributed in whole or in part without the express consent of Amazon.com, Inc.

by Loren SegalNovember 15th, 2013

Writing JavaScript Applications with the AWS SDK

Wednesday, November 27, 13

Page 2: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

JavaScriptis everywhere.

Wednesday, November 27, 13

Page 3: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

AWS SDK forJavaScript in Node.js

Almost a year old!

Wednesday, November 27, 13

Page 4: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

AWS SDK forJavaScript in the Browser

Desktop or mobile devices

Wednesday, November 27, 13

Page 5: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Let’s use them.

Wednesday, November 27, 13

Page 6: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Goals

Wednesday, November 27, 13

Page 7: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Goals

1. Learn about AWS SDK for Node.js

Wednesday, November 27, 13

Page 8: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Goals

1. Learn about AWS SDK for Node.js

2. Introduce AWS SDK for JavaScript in the Browser

Wednesday, November 27, 13

Page 9: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

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

Wednesday, November 27, 13

Page 10: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

AWS SDK for Node.js

Wednesday, November 27, 13

Page 11: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Full Service CoverageSupport for over 30 AWS services

Wednesday, November 27, 13

Page 12: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Extensible ClientsCustomize any part of the request cycle

Wednesday, November 27, 13

Page 13: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Standard Node.js IdiomsStreams, EventEmitter, Domains

Wednesday, November 27, 13

Page 14: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Open SourceApache License, Version 2.0

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

Wednesday, November 27, 13

Page 15: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Getting StartedAWS SDK for Node.js

Wednesday, November 27, 13

Page 16: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

$ npm install aws-sdkBash

Installing

Wednesday, November 27, 13

Page 17: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

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

Loading

Wednesday, November 27, 13

Page 18: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Configuringthe SDKAWS.config

Wednesday, November 27, 13

Page 19: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Configuringthe SDKAWS.config

Credentials *

* Required by the SDK

Wednesday, November 27, 13

Page 20: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Configuringthe SDKAWS.config

Credentials *Region *

* Required by the SDK

Wednesday, November 27, 13

Page 21: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Configuringthe SDKAWS.config

Credentials *Region *Extras

* Required by the SDK

Wednesday, November 27, 13

Page 22: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Configuring Credentials

Wednesday, November 27, 13

Page 23: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Configuring Credentials

IAM roles for EC2 Instances

Wednesday, November 27, 13

Page 24: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Configuring Credentials

IAM roles for EC2 InstancesEnvironment Variables

Wednesday, November 27, 13

Page 25: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Configuring Credentials

IAM roles for EC2 InstancesEnvironment VariablesFile System (outside source control)

Wednesday, November 27, 13

Page 26: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Do Not Hardcode Credentials

Unless they are read-only and scoped to specific resources.Wednesday, November 27, 13

Page 27: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

IAM Roles for EC2 Instances

=Zero Configuration

Wednesday, November 27, 13

Page 28: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Environment VariablesAWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYAWS_REGION*

Wednesday, November 27, 13

Page 29: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

ConfiguringRegion and Extras

Wednesday, November 27, 13

Page 30: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

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

JS

Wednesday, November 27, 13

Page 31: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

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

Config From a File

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

Wednesday, November 27, 13

Page 32: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Working with Services

Wednesday, November 27, 13

Page 33: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Service Objects

Wednesday, November 27, 13

Page 34: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Service Objects

AWS.S3

Wednesday, November 27, 13

Page 35: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Service Objects

AWS.S3AWS.EC2

Wednesday, November 27, 13

Page 36: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Service Objects

AWS.S3AWS.EC2AWS.DynamoDB

Wednesday, November 27, 13

Page 37: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Service Objects

AWS.S3AWS.EC2AWS.DynamoDBAWS.SQS

Wednesday, November 27, 13

Page 38: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Service Objects

AWS.S3AWS.EC2AWS.DynamoDBAWS.SQSAWS.SNS

Wednesday, November 27, 13

Page 39: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Service Objects

AWS.S3AWS.EC2AWS.DynamoDBAWS.SQSAWS.SNS...

Wednesday, November 27, 13

Page 40: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

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

Constructing a Service Object

Wednesday, November 27, 13

Page 41: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

ec2.describeInstances(params, callback);JS

Calling an Operation

Wednesday, November 27, 13

Page 42: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

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

The Callback

Wednesday, November 27, 13

Page 43: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

var req = ec2.describeInstances(params);JS

Getting a Request Object

Wednesday, November 27, 13

Page 44: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

var resp = req.send(callback);JS

Sending the Request Object

Wednesday, November 27, 13

Page 45: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

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

Adding Listenersto the Request Object

Wednesday, November 27, 13

Page 46: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

The Request Cycle

Wednesday, November 27, 13

Page 47: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Send AWS.RequestGet AWS.Response

Wednesday, November 27, 13

Page 48: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Request Lifecycle

Wednesday, November 27, 13

Page 49: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Operation

Request Lifecycle

Wednesday, November 27, 13

Page 50: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Operation

Request Lifecycle

Wednesday, November 27, 13

Page 51: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

AWS.Request

Operation

Request Lifecycle

Wednesday, November 27, 13

Page 52: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

AWS.Request

Operation

Request Lifecycle

send()

Wednesday, November 27, 13

Page 53: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

AWS.Request

Operation

build sign send

completesuccess

error

Emitted Lifecycle Events

... ... ...

Request Lifecycle

send()

Wednesday, November 27, 13

Page 54: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

AWS.Request

Operation

build sign send

completesuccess

error

Emitted Lifecycle Events

... ... ...

Request Lifecycle

callbacksend()

Wednesday, November 27, 13

Page 55: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

AWS.Request

Operation

AWS.Response

build sign send

completesuccess

error

Emitted Lifecycle Events

... ... ...

Request Lifecycle

callbacksend()

Wednesday, November 27, 13

Page 56: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

AWS.Request

Wednesday, November 27, 13

Page 57: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

AWS.Request.send(callback)

Wednesday, November 27, 13

Page 58: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

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

Wednesday, November 27, 13

Page 59: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

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

Wednesday, November 27, 13

Page 60: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

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

Wednesday, November 27, 13

Page 61: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

AWS.Response

Wednesday, November 27, 13

Page 62: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

AWS.Response

.error

Wednesday, November 27, 13

Page 63: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

AWS.Response

.error

.data

Wednesday, November 27, 13

Page 64: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

AWS.Response

.error

.data

.retryCount

Wednesday, November 27, 13

Page 65: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

AWS.Response

.error

.data

.retryCount

.httpResponse

Wednesday, November 27, 13

Page 66: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

AWS.Response

.error

.data

.retryCount

.httpResponse

...Wednesday, November 27, 13

Page 67: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

RequestLifecycleRecap

Wednesday, November 27, 13

Page 68: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

RequestLifecycleRecap

Send AWS.Request

Wednesday, November 27, 13

Page 69: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

RequestLifecycleRecap

Send AWS.RequestEmits Lifecycle Events

Wednesday, November 27, 13

Page 70: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

RequestLifecycleRecap

Send AWS.RequestEmits Lifecycle EventsCallback with AWS.Response

Wednesday, November 27, 13

Page 71: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Featuresof the SDK

Wednesday, November 27, 13

Page 72: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

SDK Features

Wednesday, November 27, 13

Page 73: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

SDK Features

Global Configuration Object

Wednesday, November 27, 13

Page 74: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

SDK Features

Global Configuration ObjectBound Parameters

Wednesday, November 27, 13

Page 75: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

SDK Features

Global Configuration ObjectBound ParametersResponse Pagination

Wednesday, November 27, 13

Page 76: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

SDK Features

Global Configuration ObjectBound ParametersResponse PaginationEvent Listeners (Per-Service and Global)

Wednesday, November 27, 13

Page 77: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

SDK Features

Global Configuration ObjectBound ParametersResponse PaginationEvent Listeners (Per-Service and Global)API Version Locking

Wednesday, November 27, 13

Page 78: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

SDK Features

Global Configuration ObjectBound ParametersResponse PaginationEvent Listeners (Per-Service and Global)API Version LockingSecure Credential Management

Wednesday, November 27, 13

Page 79: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

AWS SDKfor JavaScriptin the Browser

Wednesday, November 27, 13

Page 80: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Developer PreviewLooking for Feedback

Wednesday, November 27, 13

Page 81: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

language

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

Wednesday, November 27, 13

Page 82: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

5 Supported Services

Wednesday, November 27, 13

Page 83: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

5 Supported Services

Amazon S3

Wednesday, November 27, 13

Page 84: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

5 Supported Services

Amazon S3Amazon DynamoDB

Wednesday, November 27, 13

Page 85: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

5 Supported Services

Amazon S3Amazon DynamoDBAmazon SQS

Wednesday, November 27, 13

Page 86: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

5 Supported Services

Amazon S3Amazon DynamoDBAmazon SQSAmazon SNS

Wednesday, November 27, 13

Page 87: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

5 Supported Services

Amazon S3Amazon DynamoDBAmazon SQSAmazon SNSSTS

Wednesday, November 27, 13

Page 88: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

All Modern Browsers

28.0+ 23.0+ 10+ 17.0+ 5.1+

Wednesday, November 27, 13

Page 89: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

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

Wednesday, November 27, 13

Page 90: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Configurationis Different

Wednesday, November 27, 13

Page 91: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Two-Tier Web Applications

Why is it different?

Wednesday, November 27, 13

Page 92: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Traditional Application Architecture

Other ServicesNode.js Backend

nodeJS

Your Services

Wednesday, November 27, 13

Page 93: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Two-Tier Application Architecture

Your ServicesnodeJS

nodeJS

nodeJS

SDK on the Device

Wednesday, November 27, 13

Page 94: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Benefits

Wednesday, November 27, 13

Page 95: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Benefits

Fewer moving parts

Wednesday, November 27, 13

Page 96: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Benefits

Fewer moving partsEasy prototyping

Wednesday, November 27, 13

Page 97: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Benefits

Fewer moving partsEasy prototypingDeploying as simple as copying files to Amazon S3

Wednesday, November 27, 13

Page 98: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Benefits

Fewer moving partsEasy prototypingDeploying as simple as copying files to Amazon S3Fully dynamic app for pennies a month

Wednesday, November 27, 13

Page 99: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Next LevelWeb Apps

Wednesday, November 27, 13

Page 100: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

AppIdeas

Wednesday, November 27, 13

Page 101: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

AppIdeas

Forum Software

Wednesday, November 27, 13

Page 102: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

AppIdeas

Forum SoftwareBlog Commenting Service

Wednesday, November 27, 13

Page 103: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

AppIdeas

Forum SoftwareBlog Commenting ServiceBlogging Platform

Wednesday, November 27, 13

Page 104: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

AppIdeas

Forum SoftwareBlog Commenting ServiceBlogging PlatformFirefox/Chrome Extensions

Wednesday, November 27, 13

Page 105: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

AppIdeas

Forum SoftwareBlog Commenting ServiceBlogging PlatformFirefox/Chrome ExtensionsWinRT (Metro Style) Apps

Wednesday, November 27, 13

Page 106: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

AppIdeas

Forum SoftwareBlog Commenting ServiceBlogging PlatformFirefox/Chrome ExtensionsWinRT (Metro Style) AppsAny Mobile App!

Wednesday, November 27, 13

Page 107: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Let’s Look at aWeb Application

Using nothing butHTML, CSS, and JavaScript

Wednesday, November 27, 13

Page 108: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

A Simple BlogContent stored in Amazon DynamoDB

Assets in Amazon S3

Wednesday, November 27, 13

Page 109: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Key DifferencesThree-Tier to Two-Tier

Wednesday, November 27, 13

Page 110: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Key DifferencesThree-Tier to Two-Tier

Browser Security

Wednesday, November 27, 13

Page 111: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Key DifferencesThree-Tier to Two-Tier

Browser SecurityCORS in the browser Credentials on device

Wednesday, November 27, 13

Page 112: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Cross-Origin Resource Sharing

Wednesday, November 27, 13

Page 113: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

CORS

Wednesday, November 27, 13

Page 114: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

CORSBrowser sends pre-flight request to external host.

Wednesday, November 27, 13

Page 115: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

CORSBrowser sends pre-flight request to external host.Host acknowledges browser.

Wednesday, November 27, 13

Page 116: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

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

Wednesday, November 27, 13

Page 117: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

CORS+ S3

Wednesday, November 27, 13

Page 118: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

CORS+ S3

CORS needs special configuration on Amazon S3.

Wednesday, November 27, 13

Page 119: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

CORS+ S3

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

Wednesday, November 27, 13

Page 120: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Configuring CORS on Amazon S3

Wednesday, November 27, 13

Page 121: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Getting CredentialsOnto Your Device

Wednesday, November 27, 13

Page 122: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

GettingCredentials

Onto Your Device

Wednesday, November 27, 13

Page 123: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

GettingCredentials

Onto Your Device

Never hardcode credentials

Wednesday, November 27, 13

Page 124: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

GettingCredentials

Onto Your Device

Never hardcode credentialsUse Web Identity Federation

Wednesday, November 27, 13

Page 125: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Web Identity FederationUse Facebook, Google, or Login with

Amazon as third-party identity providers

Wednesday, November 27, 13

Page 126: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Web Identity FederationSet up IAM roles for

these identity providers

Wednesday, November 27, 13

Page 127: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

1

2

3

Wednesday, November 27, 13

Page 128: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Web Identity FederationSet up permissions for IAM role

Wednesday, November 27, 13

Page 129: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

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

JS

AWS.WebIdentityCredentials

Wednesday, November 27, 13

Page 130: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

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

Wednesday, November 27, 13

Page 131: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Same ConceptFor other identity providers

Wednesday, November 27, 13

Page 132: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Our Community

Wednesday, November 27, 13

Page 133: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

We ♥Open Source

Wednesday, November 27, 13

Page 134: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

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

Wednesday, November 27, 13

Page 135: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Contributingto the SDK

Wednesday, November 27, 13

Page 136: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Contributingto the SDK

Improve Documentation

Wednesday, November 27, 13

Page 137: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Contributingto the SDK

Improve DocumentationReport Issues

Wednesday, November 27, 13

Page 138: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Contributingto the SDK

Improve DocumentationReport IssuesSubmit Pull Requests

Wednesday, November 27, 13

Page 139: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Contributingto the SDK

Improve DocumentationReport IssuesSubmit Pull RequestsThird-Party Plugins

Wednesday, November 27, 13

Page 140: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Third Party PluginsA great way to add features

Wednesday, November 27, 13

Page 141: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Node.js

Wednesday, November 27, 13

Page 142: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Wednesday, November 27, 13

Page 143: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Write More!

Wednesday, November 27, 13

Page 144: Writing JavaScript Applications with the AWS SDK (TLS303) | AWS re:Invent 2013

Please give us your feedback on this presentation

As a thank you, we will select prize winners daily for completed surveys!

TLS303 Thank You

Wednesday, November 27, 13