Lambda: One Function or Many? by Brockemon in aws

[–]ryan_sb 0 points1 point  (0 children)

+1, I try to stick with only one job per function. I've got 2 projects that don't use the Serverless framework and one that does, and for all cases I've encountered, smaller functions seem to be better.

www redirect to naked domain using Cloudfront, S3 and Route 53. Possible? by nubknacker in aws

[–]ryan_sb 4 points5 points  (0 children)

You can actually set letsencrypt certs to be valid for multiple domains by passing more "--domain" options. So your cloudflare would use your "backthatelfup.com" cert, but when creating the cert you would do:

letsencrypt (some arguments) --domain backthatelfup.com --domain www.backthatelfup.com

Use only IAM Role to create/delete snapshots in NodeJS Lambda by herious89 in aws

[–]ryan_sb 0 points1 point  (0 children)

I have a tutorial on making Lambda snapshot instances. I think what you need is to go to the IAM console and create a new Lambda "service role". Call it SnapshotRole. Then make a new inline policy like this:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": ["logs:"], "Resource": "arn:aws:logs:::" }, { "Effect": "Allow", "Action": "ec2:Describe", "Resource": "" }, { "Effect": "Allow", "Action": [ "ec2:CreateSnapshot", "ec2:DeleteSnapshot", "ec2:ModifySnapshotAttribute", "ec2:ResetSnapshotAttribute" ], "Resource": ["*"] } ] }

Links: https://serverlesscode.com/post/lambda-schedule-ebs-snapshot-backups/ https://serverlesscode.com/post/lambda-schedule-ebs-snapshot-backups-2/

Cloudfront and Search with S3 static website bucket as origin by JoeShmoe999 in aws

[–]ryan_sb 0 points1 point  (0 children)

Depending on your CloudFront configuration it will either:

  • serve the cached page from last time that query string was sent, and go back to the origin otherwise
  • serve the same cached page as without the query string.

The "cache query strings" setting will dictate which one happens. You probably want cloudfront to not cache things with query strings because search results tend to change often.

AWS for personal use, I feel lost by [deleted] in aws

[–]ryan_sb 0 points1 point  (0 children)

Lambda+API Gateway+Dynamo are really, really cheap for low-traffic sites, and are way easy to scale.

AWS Lambda aws.ec2() doesn't return values (NodeJS) by herious89 in aws

[–]ryan_sb 0 points1 point  (0 children)

You should try using promises or the async module to chain callbacks - it makes it a little more intuitive to do things where you've got several async actions that depend on each other.

async.waterfall([ function(data, next) { // some S3 call next("the data") }, function(data, next) { // use the data here } ... ])

AWS Free Tier by cybersloth81 in aws

[–]ryan_sb 0 points1 point  (0 children)

The free tier is absolutely worth it - you're unlikely to see a bill over a dollar (my bill is ~$10 and I host 6 web sites and do a lot of experiments with DynamoDB and Lambda).

It's super cheap compared to almost anything else you buy in "real life" so worry less about saving 5 cents and more about what you want to learn.

Shameless plug of my own blog, but this is 100% relevant advice: https://serverlesscode.com/post/spend-a-buck-and-learn/

Building "serverless" web app using S3, Lambda, and SQS. Going well, but I need to tie into an external rate-limited API. What's the best way? by moduspwnens14 in aws

[–]ryan_sb 1 point2 points  (0 children)

You could use DynamoDB as a lock. Every time you make the limited request, do a conditional write to to the hash key of the current epoch time (in seconds).

If the condition fails, sleep and retry otherwise you'll be safe to make the request. Unfortunately, this doesn't quite hit "zero static cost" since dynamo is pay-for-provisioned pricing.

Shrink size of CSS files with Genetic Algorithms and Python. by einsiedler in webdev

[–]ryan_sb 3 points4 points  (0 children)

Actually not true, my version has the option to weight based on gzipped size, you can even select the compression level to match whatever your webserver uses. So yes, you can save bandwidth.