benrady / learnjs Goto Github PK
View Code? Open in Web Editor NEWPrepared Workspace for "Serverless Single Page Apps" @ Pragprog
Home Page: https://pragprog.com/book/brapps
Prepared Workspace for "Serverless Single Page Apps" @ Pragprog
Home Page: https://pragprog.com/book/brapps
The current sspa script does not handle generating S3 Web host URL endpoints for EU regions
The AWS CLI can return before certain operations are complete. For example, when creating a DynamoDB table, you can get a response where the TableDescription.TableStatus field is "CREATING".
This can make the sspa script fail, if the resource being created isn't ready by the time the script needs to use it. This has already been resolved once for IAM roles, but it is likely there are other places where this can occur.
On lines 182 and 184 the sspa script has --profile admin
instead of --profile $profile
.
Also, would you consider covering more about python and boto3 ?
Thanks for writing the book.
I used git clone to copy to my local machine (ubuntu 14.04).
I am at learnjs root (young@young-PC:~/repository/js/learnjs in my machine) but I cannot start up sspa server.
young@young-PC:~/repository/js/learnjs$ ./sspa server
: No such file or directory
Having Python 3.5.2 I cannot run the follwing command
learnjs $ ./sspa server
I get python.exe: No module named SimpleHTTPServer
I guess for Python 3+
python -m http.server
should be used instead.
Adding simple check to sspa
script would be sufficient.
So in chapter 5 I added all the code shown, but now on localhost I get:
vendor.js:5 POST https://cognito-identity.us-east-1.amazonaws.com/ 400
error. it seems to be originating in:
learnjs.awsRefresh = function () {
var deferred = new $.Deferred();
AWS.config.credentials.refresh(function (err) {
if (err) {
deferred.reject(err);
} else {
deferred.resolve(AWS.config.credentials.identityId);
}
});
return deferred.promise();
}
function googleSignIn(googleUser) {
var id_token = googleUser.getAuthResponse().id_token;
AWS.config.update({
region: 'us-east-1',
credentials: new AWS.CognitoIdentityCredentials({
IdentityPoolId: learnjs.poolId,
Logins: {
'accounts.google.com': id_token
}
})
})
function refresh() {
return gapi.auth2.getAuthInstance().signIn({
prompt: 'login'
}).then(function (userUpdate) {
var creds = AWS.config.credentials;
var newToken = userUpdate.getAuthResponse().id_token;
creds.params.Logins['accounts.google.com'] = newToken;
return learnjs.awsRefresh();
});
}
learnjs.awsRefresh().then(function (id) {
learnjs.identity.resolve({
id: id,
email: googleUser.getBasicProfile().getEmail(),
refresh: refresh
});
});
}
Many thanks!
When I run the command ./sspa create_bucket learnjs.amblet.net
I get the following error.
./sspa create_bucket learnjs.amblet.net
make_bucket failed: s3://learnjs.amblet.net/ A client error (SignatureDoesNotMatch) occurred when calling the CreateBucket operation: The request signature we calculated does not match the signature you provided. Check your key and signing method.
./sspa: line 53: conf/s3/learnjs.amblet.net/endpoint.txt: No such file or directory
Website endpoint is: http://learnjs.amblet.net.s3-website-eu-west-1.amazonaws.com
A client error (SignatureDoesNotMatch) occurred when calling the PutBucketWebsite operation: The request signature we calculated does not match the signature you provided. Check your key and signing method.
Any idea on what might be the root cause?
I am trying to your learnjs example on Windows 7
I have cygwin installed
Currently I get the following error when I run ./sspa server
./sspa: line 2: $'\r': command not found
./sspa: line 8: $'\r': command not found
./sspa: line 9: syntax error near unexpected token '$'{\r''
./sspa: line 9: 'function check_python() {
Do I also have to have python installed for this script to run?
Thanks
As posted on the pragprog forums, the sspa script can sometimes fail when creating a Lambda function because the aws command line tool returns a zero return code even though the specific profile does not yet exist.
I'm hoping to find a way to detect this condition in another way, but in the meantime, I'm changing the sspa script to sleep for 5 seconds after creating the profile.
I can't use my work laptop with your script.
I have pre-existing development environments that are managed with Puppet and cannot be changed.
I cannot install npm, Python or Pip as required by your sspa script.
I have launched an EC2 instance with the Amazon AMI for this reason.
I could take a look at making changes to the SSPA script to accommodate individuals in a similar situation but wanted to check if I'm on the right track first.
Thanks.
Currently the code, in master (66ff4a7), and the book, version B1.0, don't line up. You're told to run ./sspa server
before you've set up your AWS config, but sspa
now calls check_aws
before it runs the server command, even though it doesn't really need it for the server
command to succeed.
Hi Ben,
I had to change the run time to node4.3 to get rid of an exception. Then after I run:
$ ./sspa create_service conf/lambda/functions/echo
The function does not appear in my aws web console.
any idea?
Can we please have the completed code for this book by chapter?
I'm sure I'll get this cleared up soon enough but I wanted to point out the (current) discrepancy between the kindle book and the current github repo.
Two tests failed once I switched the 'problemView' implementation to use a template. In particular, they are:
it('can show a problem view', function() {
learnjs.showView('#problem-1');
expect($('.markup .problem-view').length).toEqual(1);
});
and
it('has a title that include the problem number', function() {
var view = learnjs.problemView('1');
expect(view.text()).toEqual("Problem #1 coming soon!")
})
The before and after code of problemView() are:
Chapter 2 'Loading the Application' page 39
learnjs.problemView = function(problemNumber) {
var title = 'Problem #' + problemNumber + ' Coming soon!';
return $('<div class="problem-view">').text(title);
}
Chapter 3 'Essentials of Single Page Apps' page 50
learnjs.problemView = function(problemNumber) {
var view = $('.templates .problem-view').clone();
view.find('.title').text('Problem #' + problemNumber);
return view;
}
The app functions as intended. The problem seems to be the template based views were not put in the 'markup' div properly. Does it happen to other people too?
error when trying to create s3 bucket.
"when calling the PutBucketWebsite operation: Authorization header is invalid -- one and only one ' ' (space) required".
The error message also speaks of some endpoint.txt file that is missing.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.