corley cloud angular in cloud

35
AngularJS on Cloud AngularConf 2015

Upload: corley-srl

Post on 09-Jan-2017

538 views

Category:

Engineering


6 download

TRANSCRIPT

Page 1: Corley cloud   angular in cloud

AngularJSon Cloud

AngularConf 2015

Page 2: Corley cloud   angular in cloud

Who am I?Gianluca Arbezzano

@gianarb

Page 3: Corley cloud   angular in cloud

I'm here to protect you

Page 4: Corley cloud   angular in cloud

Software Engineer @CorleyCloud

Page 5: Corley cloud   angular in cloud

When you think "Infrastructure"

Page 6: Corley cloud   angular in cloud
Page 7: Corley cloud   angular in cloud

Think of word without SysAdmin

Page 8: Corley cloud   angular in cloud

Great!

Page 9: Corley cloud   angular in cloud
Page 10: Corley cloud   angular in cloud

The mission:

build an application managed byAWS

to avoid sysadmin

Page 11: Corley cloud   angular in cloud
Page 12: Corley cloud   angular in cloud

Security Issues

Without servers where do you store private credentials?

Page 13: Corley cloud   angular in cloud

Cognito identity

Helps your client app to manage authentication and it opens the doors of AWS world

Page 14: Corley cloud   angular in cloud
Page 15: Corley cloud   angular in cloud

in AngularJS// app/app.js.config([function() var creds = new AWS.CognitoIdentityCredentials( IdentityPoolId: 'us­east­1:0000000000000008c3c­5397a17ad174' ); AWS.config.update( region: 'us­east­1', credentials: creds );]);

Page 16: Corley cloud   angular in cloud

in AngularJS

ng-newsletter.com/aws-js-sdk

Page 17: Corley cloud   angular in cloud
Page 18: Corley cloud   angular in cloud

in AngularJS.directive('googleSignin', function() return restrict: 'A', template: '<span id="signinButton"></span>', replace: true, scope: afterSignin: '&' , link: function(scope, ele, attrs) // see ng­newsletter.com/posts/aws­js­sdk.html ;)

Page 19: Corley cloud   angular in cloud

in AngularJS// app/view/view.tpl.html<p>This is the partial for view 1.</p><h2>Signin to ngroad</h2>

<div google­signin client­id='3818201' after­signin="signedIn(oauth)" data­user="user"></div><pre> user | json </pre>

Page 20: Corley cloud   angular in cloud

in AngularJS$scope.signedIn = function(oauth) var creds = params: ; $scope.user = oauth; creds = AWS.config.credentials; creds.params.Logins = ; creds.params.Logins['accounts.google.com'] = oauth.id_token; AWS.config.update( credentials: creds ); AWS.config.credentials.refresh(function(err) if (err) console.log(err); ); ;

Page 21: Corley cloud   angular in cloud

Chamber of Secrets was open

Page 22: Corley cloud   angular in cloud

in AngularJS

Page 23: Corley cloud   angular in cloud

in AngularJS

Page 24: Corley cloud   angular in cloud

DynamoDBis a fully managed NoSQL database service that erovides

fast and predictable performance

with seamless scalability

Page 25: Corley cloud   angular in cloud

in AngularJS

Page 26: Corley cloud   angular in cloud

in AngularJS

Page 27: Corley cloud   angular in cloud
Page 28: Corley cloud   angular in cloud

in AngularJS<p>This is the partial for view 1.</p><h2>Signin to ngroad</h2>

<div google­signin client­id='38182010900­e5l22mddk7oliohktn747trqgsfau1rd' after­signin="signedIn(oauth)" data­user="user"></div><pre> user | json </pre>

<form ng­submit="send(item)"><input ng­model="item.title"><button type="submit">Save</button></form>

Page 29: Corley cloud   angular in cloud

in AngularJS$scope.send = function(item) AWS.config.getCredentials(function() var dynamodb = new AWS.DynamoDB(apiVersion: '2012­08­10'); dynamodb.putItem( Item: "title": "S": item.title , TableName: "angular­conf" , function(err, data) if(err) throw err; ); );;

Page 30: Corley cloud   angular in cloud

DynamoDB

Page 31: Corley cloud   angular in cloud

DynamoDB

Page 32: Corley cloud   angular in cloud

working on your data

Allow permission for singlelines

Allow permission for singlecolumns

Page 33: Corley cloud   angular in cloud

working on your data "Version": "2012­10­17", "Statement": [ "Effect": "Allow", "Action": [ "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem", "dynamodb:DeleteItem" ], "Resource": ["arn:aws:dynamodb:us­west­2::table/GameScores"], "Condition": "ForAllValues:StringEquals": "dynamodb:LeadingKeys": ["$www.amazon.com:user_id"] ]

Page 34: Corley cloud   angular in cloud

Other AWS servicesSQS

S3

Cognito Sync

docs.aws.amazon.com/AWSJavaScriptSDK

Page 35: Corley cloud   angular in cloud

Thanksgithub.com/gianarb