(dev306) building cross-platform applications using the aws sdk for javascript | aws re:invent 2014
TRANSCRIPT
![Page 1: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/1.jpg)
November 13, 2014 Las Vegas, NV
Aditya Manohar, Amazon Web Services
![Page 2: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/2.jpg)
AWS SDK for JavaScript
December2012
AWS SDK for Node.jsDeveloperPreview
![Page 3: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/3.jpg)
AWS SDK for JavaScript
December2012
AWS SDK for Node.jsDeveloperPreview
October 2013
AWS SDK for JavaScriptDeveloper Preview
![Page 4: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/4.jpg)
AWS SDK for JavaScript
December2012
October 2013
AWS SDK for JavaScriptDeveloper Preview
AWS SDK for
JavaScript
June2014
AWS SDK for Node.jsDeveloperPreview
![Page 5: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/5.jpg)
AWS SDK for JavaScript
December2012
October 2013
AWS SDK for JavaScriptDeveloper Preview
AWS SDK for
JavaScript
June2014
re:Invent 2014
AWS SDK for Node.jsDeveloperPreview
![Page 6: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/6.jpg)
ubiquitous
• Not just browsers and Node.js anymore
• Android and iOS (e.g., PhoneGap)
• WinRT: Windows Desktop & Windows Phone
• Embedded devices: Cylon.js and Johnny-Five
![Page 7: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/7.jpg)
Goals
Overview of application
SDK features
Multiple environments & operational differences
![Page 8: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/8.jpg)
Video Transcoder
![Page 9: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/9.jpg)
Upload, encode, and download videos
AmazonS3
AmazonElastic
Transcoder
Upload
Download
![Page 10: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/10.jpg)
Demo
![Page 11: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/11.jpg)
github.com/awslabs/
aws-sdk-js-sample-video-transcoder
![Page 12: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/12.jpg)
ArchitectureAWS SDK for JavaScript
app.js
![Page 13: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/13.jpg)
![Page 14: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/14.jpg)
var AWS = require('aws-sdk');
// Construct a service object
var s3 = new AWS.S3();
// Making requests
s3.listObjects({Bucket: 'bucket'}, function(err,data){
if (err) console.log(err);
else console.log(data);
});
![Page 15: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/15.jpg)
var s3 = new AWS.S3();
var req = s3.listObjects({Bucket: 'bucket'});
// Attaching life cycle callbacks
req.on('success', function(response){
console.log(response.data);
});
req.send();
![Page 16: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/16.jpg)
httpUploadProgress & httpDownloadProgress
req.on('httpUploadProgress', function(progress) {
console.log(progress.loaded + ' of ' + progress.total);
});
![Page 17: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/17.jpg)
var params = {id: 'jobId'};
transcoder.waitFor('jobComplete', params, function(err, data) {
if (err) console.log(err);
else console.log(data);
});
![Page 18: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/18.jpg)
Video Transcoder (contd.)
![Page 19: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/19.jpg)
Application workflow
Start Create Pipeline
1
Upload Files
2
Create Job
3
Attach Waiter
4 5
PollJob
6
DownloadFiles
![Page 20: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/20.jpg)
Node.js
console.js
github.com/awslabs/
aws-sdk-js-sample-video-transcoder
AWS SDK for JavaScript
app.js
![Page 21: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/21.jpg)
$> npm install aws-sdk
![Page 22: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/22.jpg)
credentials
# Shared credentials file
# ~/.aws/credentials
[default]
aws_access_key_id = foo
aws_secret_access_key = bar
[development]
aws_access_key_id = baz
aws_secret_access_key = quux
![Page 23: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/23.jpg)
app.jsApp.prototype.jobCreated = function(response) {
self.publish('app:request-success', data, message);
self.publish('app:job-complete', data);
};
![Page 24: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/24.jpg)
console.js
Application.subscribe('app:request-success', printNotification);
Application.subscribe('app:job-complete', downloadObject);
![Page 25: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/25.jpg)
console.js
var printNotification = function(response, message) {
process.stdout.write(message.text + '\n');
};
![Page 26: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/26.jpg)
console.js
var downloadObject = function(responseData){
// . . .
var req = s3.getObject({Bucket: Application.contentBucket, Key:key});
var stream = req.createReadStream();
// . . .
stream.on('data', function(data){
progress.loaded += data.length;
}).pipe(writeStream);
// . . .
};
![Page 27: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/27.jpg)
Why?
![Page 28: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/28.jpg)
Single
![Page 29: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/29.jpg)
Reduced maintenance cost
![Page 30: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/30.jpg)
Easy
![Page 31: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/31.jpg)
Easy
![Page 32: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/32.jpg)
Any application that can be written in JavaScript will eventually be written in JavaScript
- Jeff Atwood, 2007
![Page 33: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/33.jpg)
![Page 34: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/34.jpg)
Web Application
view.js
github.com/awslabs/
aws-sdk-js-sample-video-transcoder
AWS SDK for JavaScript
app.js
![Page 35: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/35.jpg)
$> bower install aws-sdk
![Page 36: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/36.jpg)
Use Amazon Cognito
No localStorage
![Page 37: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/37.jpg)
Configure CORS on Amazon S3
![Page 38: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/38.jpg)
Application.subscribe('app:request-progress', showProgress);
<progress max="100" data-message-id></progress>
jQuery UI
![Page 39: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/39.jpg)
Application.subscribe('app:request-success', notify);
Application.subscribe('app:request-failure', notify);
(noty, Notify.js, MiniJS, etc.)
![Page 40: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/40.jpg)
AWS SDK for JavaScript
app.js
Google Chrome Extension
ui.js options.js
github.com/awslabs/
aws-sdk-js-sample-video-transcoder
![Page 41: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/41.jpg)
No CORS Configuration: manifest.json
{
"manifest_version": 2,
"name": "Transcoder",
"permissions": [
"notifications",
"https://*.amazonaws.com/"
]
}
![Page 42: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/42.jpg)
options.js
var saveConfiguration = function (evt) {
localStorage.config = JSON.stringify(config);
}
![Page 43: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/43.jpg)
ui.js: N
var notify = function(response, message) {
var options = {
type: 'basic',
iconUrl: assetUrls[message.sender],
title: 'Status',
message: message.text
};
chrome.notifications.create('', options, noop);
};
![Page 44: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/44.jpg)
AWS SDK for JavaScriptApps for
Windows RT
github.com/awslabs/
aws-sdk-js-sample-video-transcoder
home.js progress.js
transcoder.js
app.js
![Page 45: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/45.jpg)
But first…
![Page 46: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/46.jpg)
Windows Runtime Windows API surface
- msdn.microsoft.com
![Page 47: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/47.jpg)
transcoder.js
setCredentials: function (resource, username, password) {
var vault = new Windows.Security.Credentials.PasswordVault();
var credential = new Windows.Security.Credentials
.PasswordCredential(resource, username, password);
vault.add(credential);
}
![Page 48: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/48.jpg)
transcoder.js
saveConfiguration: function (config) {
localSettings.values.config = composite;
}
![Page 49: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/49.jpg)
progress.js
<progress max="100" data-message-id></progress>
(+custom progress manager code)
![Page 50: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/50.jpg)
home.jsnotify: function (response, message) {
toast = new notifications.ToastNotification(toastXml);
toastNotifier = notifications.ToastNotificationManager
.createToastNotifier();
toastNotifier.show(toast);
}
![Page 51: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/51.jpg)
Summary
![Page 52: (DEV306) Building Cross-Platform Applications Using the AWS SDK for JavaScript | AWS re:Invent 2014](https://reader036.vdocuments.site/reader036/viewer/2022062514/55a22f291a28ab7d428b46d7/html5/thumbnails/52.jpg)
http://bit.ly/awsevals
@awsforjs
github.com/
aws/aws-sdk-js
blogs.aws.amazon.com/
javascript/