Bref – Serverless PHP Functions on AWS

Bref comes as a Composer package and helps you deploy PHP applications to AWS and run them on AWS Lambda.

Bref uses the Serverless framework to configure and deploy serverless applications. Being the most popular tool, Serverless comes with a huge community, a lot of examples online and a simple configuration format.

After installing an initing Bref …

composer require bref/bref
vendor/bin/bref init

… all you need to do is wrap your code logic into the Bref-provided lambda fn:

require __DIR__.'/vendor/autoload.php';

lambda(function (array $event) {
    // Do anything you want here
    // For example:
    return 'Hello ' . ($event['name'] ?? 'world');

Bref – Serverless PHP made simple →

Using AWS’ “Server­less Image Han­dler” to roll your own Image Transform Service

Ama­zon AWS has offered a Server­less Image Han­dler for a while that allows you to spin up an AWS Lamb­da func­tion to cre­ate your own pri­vate lit­tle image trans­form ser­vice that is inex­pen­sive, fast, and is front­ed by the Cloud­Front con­tent deliv­ery net­work (CDN).

Whenever an image is uploaded to the bucket, a Lambda function processes it and creates all other required versions.

Under the hood it uses SharpJS, so you could always use their code to make it run on other Cloud Providers 😉

serverless-image-handler Source Code (GitHub) →
Setting Up Your Own Image Transform Service →

Secrets in Serverless

Good post on how and where to store your secrets when working in a Serverless / Cloud Environment — something I was wondering about myself a little while ago

Serverless applications and cloud functions often need to communicate with an upstream API or service. Perhaps they require a username and password to connect to a database, an API key to talk to an upstream service, or a certificate to authenticate to an API. This raises questions like: How do I manage secrets in serverless environments? How do I get credentials into my serverless lambda or cloud function? How can I use secrets AWS Lambda or Google Cloud Functions?

This post describes common patterns and approaches for managing secrets in serverless, including the benefits and drawbacks of each approach.

Secrets in Serverless →

🌍 If you’re using Terraform then the google_kms_secret datasource will come in handy.

LocalStack – A fully functional local AWS cloud stack

At work we’ve been using several separate docker images – such as instructure/fake-s3 and airdock/fake-sqs, orchestrated by docker-compose – to run a few of the Amazon Web Services locally.

LocalStack provides the whole lot in one:

LocalStack provides an easy-to-use test/mocking framework for developing Cloud applications. Currently, the focus is primarily on supporting the AWS cloud stack. LocalStack spins up the following core Cloud APIs on your local machine:

  • API Gateway
  • Kinesis
  • DynamoDB
  • DynamoDB Streams
  • Elasticsearch
  • S3
  • Firehose
  • Lambda
  • SNS
  • SQS
  • Redshift

LocalStack – A fully functional local AWS cloud stack →

If you’re looking to emulate Lambda, this article is also worth checking out.

MoonMail – Send e-mail marketing campaigns using AWS, SES, and Lambda

Send email marketing campaigns with Amazon SES. Let Amazon Lambda compose email by email and literaly scale it to infinite.

With MoonMail you can: create & edit lists of recipients (email addresses) and store them within a DynamoDB. Create & edit html email marketing campaigns, send them and track their opens and clicks.

MoonMail →

(via cron.weekly)

Building an image processor on AWS Lambda using The Serverless Framework

Good writeup on setting up an image processor using The Serverless Framework, a thing comparable to the aforementioned apex (and with an awfully generic and confusing name imho 😉).

  1. When a user uploads a file an ObjectCreated event is produced and a Lambda function is invoked.
  2. The Lambda function calls Amazon Rekognition to detect the faces and emotion of each face in the uploaded image.
  3. The Lambda function processes the image and persists the image in Amazon S3

Here’s an example set of results:

The code of the Lambda function that calls Amazon Rekognition and processes uploaded images is available on GitHub.

How to build powerful back-ends easily with Serverless →

30K Page Views for $0.21: A Serverless Story

Pete built the Fantasy Movie League Lineup Calculator. In July it got about 30K pageviews, resulting in a $0.21 bill from Amazon AWS:

The Lineup Calculator is comprised of a set of AWS Lambda functions. Boiling what I’ve done down to its essentials, I’m using Lambda as a free batch server where I’m well below the free tier of 1M transactions per month and using S3 as a low cost web host where my primary cost is the egress.

At work we’re also heavy AWS users. Some of our projects – like the meme generator – run using a likewise setup: static (and generated) files are stored on S3, with some Lambda sprinkled on top.

30K Page Views for $0.21: A Serverless Story →

Apex – Serverless Infrastructure


Apex lets you build, deploy, and manage AWS Lambda functions with ease. A variety of workflow related tooling is provided for testing functions, rolling back deploys, viewing metrics, tailing logs, hooking into the build system and more.

Define a project.json as so …

  "name": "bar",
  "description": "Node.js example function",
  "runtime": "nodejs",
  "memory": 128,
  "timeout": 5,
  "role": "arn:aws:iam::293503197324:role/lambda"

… and then place your function inside the functions/{name}/ folder, and finally deploy it by running apex deploy.

Apex augments AWS Lambda by supporting more languages than Node(JS)/Python/Java:

With Apex you can use languages that are not natively supported by AWS Lambda, such as Golang, through the use of a Node.js shim injected into the build.

Apex – Serverless Infrastructure →