Configuring CloudWatch Scheduled Events in the Serverless Framework

In the last article we saw how to execute a AWS Lambda with a scheduled CloudWatch event. Today, we are going to see how to set this up in the serverless.yml file of our services when using the serverless frameworkRead More »

Serverless and Crontabless: Welcome CloudWatch Events and Lambdas

It's really common to have different jobs setup in cron for our applications. These are always needed in order to perform different tasks, either for cleaning up stuff, run reports, gather metrics, send alerts, and other types of periodic tasks. The downside is that you need a server to run cron, and the associated cost of hosting and maintaining it. In this article we are going to see how we can replace cron jobs with AWS Lambda functions and CloudWatchRead More »

Serverless hangs when checking the stack update process

If you are noticing that the serverless framework is getting stuck with the message "Checking Stack update process" when deploying, this might be helpful for you. Read More »

AWS Lambda to start and stop EC2 instances

There are a variety of situations where having a microservice available that can start or stop EC2 instances at will can be handy. In this article we are going to see how we can use an AWS Lambda to do such a thing on demand without using any extra servers or instances at all. Read More »

Thou Shalt Honour Thy Bugs (or How I Learned to Stop Worrying and Love the bug)

It happened to all of us. On a bad day, a bug report arriving at your inbox can make you cry, scream, or do a table flip. Others can't really stand any kind of bug reports or issues with their code, even on a good day. If you feel like this is happening to you, perhaps there's something that might help you out. And no, I'm not talking about a pill or a smokeable substance. But just a way of looking at these things differently. Read More »

How to compile NGINX with external OpenSSL libraries and custom linker options

We are all used to the environment variables like CFLAGS, LDFLAGS that can be used when configuring a source tree before building it. Thing is, Nginx does this a bit different, so if you try to build it and link it against an OpenSSL installation that is not in the standard paths (like /usr/lib, /usr/local/lib, etc) by setting LDFLAGS to your OpenSSL installation, you will fail miserably. Read More »

Using CloudWatch to Monitor your AWS Lambda and send Alerts on Errors

CloudWatch is an amazing tool that Amazon has to gather logs and metrics, and also create alarms based on them. In this article we're going to see some useful tips to create alarms and send notifications when your Lambda functions end with error or log messages with a specific pattern. Note that in all cases, CloudWatch with send the notifications through an SNS Topic, and you can create as many SNS topic subscriptions as needed to deliver the notifications where you need to (SMS, HTTP, Email, etc). Read More »

Using AWS Lambda to check if your website is online

Services like Pingdom and UptimeRobot are a great way to check your websites for availability, but sometimes there is need for something cheaper or with better ways to customize checks and alerts. In this article we are going to see how to use an Amazon Lambda to periodically check if your website is online, and also use CloudWatch and SNS to send SMS alerts when the website if offlineRead More »

Expirable user sessions with MySQL events

One awesome feature of Redis is that you can set an expiration time in a database key, and this works great to handle your user session expirations. If a session token is used for any kind of operation you can just renew that time after completing it. If the token is not used for a given period of time, it will be deleted automagically and the operation will be denied, so the user will need to login again in order to get a new session token. This can also be achieved by using MySQL, through the MySQL Event Scheduler, that can be used to setup a one-time or recurring event to cleanup stale or unused sessions. Let's see how! Read More »

Transcoding Audio Files with AWS Lambda and SQS without Elastic Transcoder

If you find that using AWS Elastic Transcoder is too expensive, and you don't want to use an EC2 instance for transcoding, perhaps this might help you out. In the previous post we created a static SOX binary that can be executed inside an AWS Lambda Container. In this post we are going to use it to trigger it when uploading an audio file to an S3 bucket, transcode it, and upload the result to another bucket. Read More »

How to create a static SOX executable to invoke it in AWS Lambda

SOX is an awesome tool that can transcode audio files in many different formats. But if you want to use SOX inside an AWS Lambda Container you should generate a binary that includes all the code needed to run in an isolated environment, because you won't have some needed libraries preinstalled (like lame and libmad). This is really useful if you can't afford the Amazon Elastic Transcoder service and need a cheaper solution instead. A great application for this is to transcode your Asterisk Monitor recordings to MP3 in a server-less way.  Read More »

How to use Curl and Json from the Asterisk Dialplan to control call flow

It's very common that we want to use external services from our Asterisk Dialplan, and many times those external services are accessible via HTTP (such as a REST HTTP API). In this article we are going to see how we can use cURL to query an external HTTP service and read a response in JSON format and take action on the values returned to control the call flow in our dialplan. Read More »

Selectively Receiving incoming calls from Asterisk Queues while dialing out

One of our clients has a call center with a particular business logic. Their agents can place calls and they can also take calls that come from an Asterisk Queue. Nothing new there, but there are some corner cases that are very important. Read More »

Giving your Call Center Agents or Queue Members some extra time after a call finishes with Asterisk Queues

It's very common in Call Centers that agents need a few extra seconds to do some administrative tasks before taking new calls. For example, let's say that the software you use in your call center (or for that matter, the workflow your employees follow) require agents to fill in some information after each call, so they need 15 seconds approximately to accomplish this and they can't take another call while at it. In this article we are going to see how to do just that with the queues in Asterisk PBX. Read More »

How to Return Custom HTTP Status codes from a Lambda function in Amazon API Gateway

HTTP status codes in a REST API are a very useful way to communicate operation results to the clients. For example you should use the HTTP status 400s family of codes to signal client errors, meaning that the request has something that is syntactically or semantically wrong (also meaning that the client should probably never try the same request again because it will never work as it is). And you should use the 500s family of errors to signal that something went wrong at the server side, so perhaps the client might return the operation later. Read More »

Using Comodo SSL Certificates in Amazon API Gateway

If you want to host your REST API in Amazon API Gateway with a Comodo SSL Certificate you will have to a few things in order to correctly setup the SSL Certificate Chain for your domain. When creating the domain by clicking in Custom Domain Name in your API Gateway Console, you will notice these options used to setup SSL: Read More »

Monitoring SIP trunks for availability by issuing test calls with SIPp

SIPp is an awesome tool to do load testing for your SIP infrastructure or applications, it uses a simple XML file to setup a test scenario and then you can pick up the results in different ways. And we can also use it to test the availability of our own VoIP infrastructure. It may happen that your business relies on an Asterisk PBX or FreeSWITCH system to take calls (for example inbound calls for customer support), and it may also happen that these servers might be temporarily down for some reason (perhaps a misconfiguration ot any other temporal errors). This is emabarrasing when the customer wants to reach out to you by phone and it's not possible. Read More »

Setting DND (Do Not Disturb) in FOP2 Programmatically

FOP2 (from Flash Operator Panel) is one of the most used graphical interfaces to the Asterisk PBX. By using it we can see in realtime what is going on with the queues and extensions (or agents). In this article we're going to see how we can integrate our systems with FOP2 so we can change the status of the extensions without using the graphical interface. Read More »

Solving MISSING_PATH_PARAMETER_DEFINITION when exporting from AWS API Gateway in Swagger Format

A few days ago I stumbled upon what it seems to be a bug in AWS API Gateway, triggered when exporting an API in Swagger format. The bug in question generates an invalid Swagger file format that can be noticed when using the Online Swagger Editor Read More »

HipChat Notifications from AWS CodeDeploy

In a previous article I described how you can create a Lambda function and use it through SNS to send HipChat notifications. In this article we're going to take this one step further and integrate another awesome Amazon service, AWS CodeDeploy so we can receive HipChat notifications during the lifecycle of a deploy, and keep the whole team updated about the deploy status. Read More »

Send HipChat Notifications with SNS and Lambda

Amazon AWS Lambda is a great service and really fun to use. In this article, I'm going to describe how we are using it for a project in combination with Amazon Simple Notification Service to send notifications to HipChatRead More »

Get your AWS instance tags from your EC2 instance

There's a quick way that you can use to read the tags of your EC2 instance from inside the same instance. If you have the instance id (and you can get it by using the EC2 MetaData) you can use the AWS Command Line tools. More specifically, by using the Describe Tags command of the AWS CLI you can get your instance tags in the following way: . Read More »

Getting the AWS instance ID from within the EC2 instance

Sometimes it can be quite useful to be able to get the instance information from within the EC2 instance. A clear example is to be able to get the instance id. Luckily for us, Amazon made this information available through the EC2 instance MetaDataRead More »

Accessing the Internet and other AWS Resources in your VPC from AWS Lambda

AWS Lambda is a great service from Amazon that can be used for a lot of things. It is the key to a Server Less architecture/application but it can also be useful to develop monitoring applications (or functions, actually) for your own services. Truth be told, whatever is your use case, it is highly probable that you need to access the Internet or other AWS Resources (like RDS) to fully accomplish your tasks. In the first days, you couldn't easily do this, but since Feb 2016 Amazon made publicly available this new feature. Read More »

WebRTC with Asterisk and Amazon AWS

In a previous article I described how to install Webrtc2sip to include SIP signalling in your webrtc applications. Unluckily there were some issues with webrtc2sip reported by Rosario Santoro (@RosSantoro1) and further discussed in the Doubango Google Group. Without having a solution yet, I decided to give Asterisk another shot. So in this article I'll describe how to use Asterisk only (without webrtc2sip) to setup a webrtc scenario without any other third party applications. This article is loosely based on this one.  Read More »

Using ACL by IP Address in HaProxy TCP Mode

haproxy is an awesome load balancer for TCP and HTTP connections. Let's see how to add some simple security rules based on the source IP address.  Read More »

Automatized daily mysql backups to S3 buckets

If you are not using RDS to host your databases, it is very probable that you are doing your own backups. In this article we'll see a very simple shell script to do automatic daily backups for your mysql databases into an S3 bucket.  Read More »

Compiling and Installing WebRTC2SIP

A lot of sources around the Internet explain how to compile and install Webrtc2sip so one can have SIP as the signaling protocol in a webrtc application, mostly in conjunction with Asterisk and/or FreeSWITCH. Most of the time those instructions are outdated or incomplete, so here is the updated way of installing webrtc2sip and its dependencies, using Amazon Linux in an EC2 instance inside AWS, altough I'm pretty sure this could also be used for any CentOS like OS.  Read More »

Installing DaemonTools in Amazon Linux (or CentOS like OS)

DaemonTools is an excellent piece of software created by Daniel J. Bernstein, and composed of several tools used to launch and monitor processes in a unix environment. They are fast, reliable, and are my favourites whenever I get to wear the devops hat to setup a new server. Sadly, there's no default package available for distros like Amazon Linux or CentOS, so here are the steps involved for setting them up manually.  Read More »

ABNF Grammars in Elixir

ABNF grammars are widely used in the Internet today. They serve as the basic building blocks for a lot of highly used protocols, like HTTP, SIP, SMTP, FTP, etc. And they are also very useful to design DSLs (Domain Specific Language). In this article we'll learn how to use a tool called ex_abnf to quickly create grammar parsers using the Elixir language.  Read More »

Starting WebRTC2SIP as a service without screen or console

Webrtc2sip is a much needed tool created by the Doubango guys, to enable the use of SIP as the signaling protocol in a webrtc application, and used with Asterisk and/or FreeSWITCH mostly. Unfortunately this handy tool can't be started as a service as it is, since it will always start and read from standard input for commands (as of today, the only command available seems to be quit).  Read More »

Sólo un sueño (a short story, non-technical -sorry- written in spanish)

Read More »

Professional Telephony Applications using PAMI and PAGI, in Software Developer Journal

The march issue of Software Developer Journal shows complete applications of PAGI and PAMI in telephony applications using Asterisk and PHP. Read More »

PAMI and PAGI at the PHP Conference Argentina 2013

Check the slides (english) and the video (spanish) about writing telephony applications using Asterisk, PHP, and PAGI and PAMI, at the PHP Conference Argentina 2013. You can download the slides, don't forget to see the notes! The complete talk is right there if you missed it :) Read More »

Common Test: Cobertura Coverage report for Jenkins using covertool

Aside from what the cover application can offer in terms of code coverage reports, we can also get some "nicer" graphs for our erlang projects, integrated with Jenkins, by using covertool to convert the coverage information into the cobertura format  Read More »

Common Test: Generating JUnit style xml reports for Jenkins

JUnit/Surefire -style reports are very useful, because you can make Jenkins use them to display nice reports. Fortunately, since Mar 20th, the default common test distribution comes with a cth_surefire hook  Read More »

Every-day Erlang: Quick and effective cache using ETS (Inaka blog)

Hello again! To continue the "Every Day Erlang" series, I'd like to show you how to implement a quick and simple (yet effective) cache using ets, very suitable to wrap your expensive function calls with it. The complete source code is in form of a rebar library application, at github, that you can easily include for fun and/or profit into your own project.  Read More »

Erlang Event Driven Applications (Inaka blog)

Events are one of the best tools to have around in your personal toolbox. There's even a special chapter in the OTP design principles about events, and that's because having an Event driven architecture can do marvels for your code  Read More »

A plan is not only good for business

As a developer, one of the things that really keeps me motivated is to know where I'm going. This means that the short and medium term objectives are clear (by whoever might be in charge of gathering requirements or making the specs), and in a somewhat detailed way. This makes it possible (again, as a developer) to make your work flow from one day to the other in a more natural way, mentally planning what you want to accomplish "today" in your trip to the office, and plan "tomorrow" as you work your way to the end of the day  Read More »

Every-day Erlang: Handling crashes when calling gen_server:start link outside a supervisor (Inaka blog)

This post is about a nifty trick we used when in need of starting a gen_server process with a start_link call, while at the same time, handling any errors gracefully (i.e: avoid propagating a crash to the supervisors).  Read More »

Epers, Erlang, and Domain Events when persisting your entities

In the last article, I presented epers, a small project intended to help build erlang applications that need to persist entities to a database. In this new article, I'll describe the built-in domain events available in the framework.  Read More »

Link and Monitor differences in Erlang

link/1 and monitor/2 are 2 different ways of notifying (or know) that a process died. Thing is, these are really very different in nature and these differences are not widely understood by beginners. So let's shed some light on this subject!  Read More »

Persisting your entities in erlang

In this article, I'll describe epers, which is a small project I've been working on. It's currently a "small" project, but quite ambitious, and the idea is to try some "new" ideas and concepts in the erlang we do every day. epers stands for "erlang persistence". As the name suggests, it tries to make it easy to use databases in erlang programs, to make it a little more agile, and (humbly) offer a nice adapter for several databases, hiding their implementation details  Read More »

Common Test: Code coverage on subdirectories

Sometimes its useful to organice your source files into subdirectories. Thing is, it's not that easy to create html reports for code coverage for them. Let's see why, and a possible solution for this.  Read More »

Dealing with a failed configure when building a php extension

If you happen to get stuck when compiling a php pecl extension with a libtool error like  Read More »

Erlang Special Processes without behaviours

OTP has (in its design principles), things like behaviours, applications, releases, and supervision trees. If we zoom into the latter, we'll find supervisors, which supervise processes, that can also be supervisors themselves.  Read More »

Erlang Websocket Server using Cowboy

Out of curiosity, and because some of my own projects needed it, I decided to go ahead and try writing a websocket server in erlang. After evaluating some of the available options (so I dont have to implement the whole websocket RFC -and their different drafts/versions- myself), I chose the Cowboy framework  Read More »

Generate code coverage for EUnit tests in rebar

To configure rebar to generate the code coverage report in html after running the EUnit tests, add to your rebar.config  Read More »

Skipping build steps for dependencies in rebar

If you happen to want to clean, compile, run tests, etc in your project but not in your dependencies, try the skips_deps=true, like  Read More »

Making your ivr nodes (call) flow with PAGI

The last article was about how to create call flow nodes for asterisk, using pagi and php, to easily create telephony applications. It's now time to add a layer on top of it, and create a complete call flow with several nodes.  Read More »

PHP Continuous integration, with Jenkins and Phing

This article is about how to use Phing in your projects, so a continuous integration server (in this case Jenkins -ex Hudson-) can generate the necessary artifacts for your php application (deployment artifacts, documentation, code metrics, etc). I'll try to show why this will make your life easier when developing or auditing code, generating releases and deploying new versions, trace bugs, etc.  Read More »

Advanced telephony applications with PHP and PAGI using call flow nodes

In the last article I've talked about how to create telephony applications using nothing else than the standard pagi client. Also, in this article I've shown how to unit test them, by using the mocked client pagi. Now, since version 1.10.0, PAGI comes with a neat feature, which is a small abstraction layer over the pagi client, called "Nodes". Also, the "NodeController" will orchestrate how those nodes interact with each other. Nodes are essentially call flow nodes.  Read More »

Unit test your PHP IVR applications with PAGI

Since version 1.9.2, PAGI comes with a mock of a pagi client, suitable to be used in your own unit tests, so you can test your telephony applications, like IVRs. The idea behind the mocked client is to let you test the callflow side of your application, the user interaction and the exact sequence an ivr application should obey.  Read More »

Dependency injection with Xml and Yaml in the Ding container

In this past article I've discussed the dependency injection features when using annotations. This time, we'll see how to use the xml and yaml drivers to do the same. In the ding manual you can find extensive examples (almost all with xml and annotations). You are encouraged to take a look at if. This article will reproduce some of the examples there, extending the concepts a little bit  Read More »

Aspect Oriented Programming in PHP with Ding

Aspect Oriented Programming (just AOP from now on), is a very powerful tool we can use to implement the infamous cross cutting concerns we have in our applications (auditing, logging, security, etc). In this article, I'll show how we can easily use AOP in a very simple language like PHP, by using the Ding container  Read More »

Sniffing in PHP using libpcap: Thank you SWIG!

I've been wanting to try SWIG for a long time, but never got the chance, for one thing or the other. So this weekend I've finally decided to give it a try by trying to create a php extension that access a small C++ wrapper for libpcap, so I can sniff packets directly from PHP. Just for fun (and actually because I couldn't find any active pecl extension to use libpcap, so it might as well be something useful). I've named it "SimplePcap".  Read More »

Dispatching and listening for events in the Ding container

Events in the ding container are strings. This is not a great level of abstraction but still provides a powerful tool to work with. Events also have associated data, sent to the listeners as an argument when firing the event. This simple workflow will allow you to extend your system with autonomous components that react to events, totally decoupled from the rest of the code.  Read More »

Use Annotations in your PHP Code to achieve Dependency Injection with the Ding Container

In the previous article I've shown how to declare your beans. Now it's time to see how to achieve DI (dependency injection), also using annotations.  Read More »

Use annotations in your PHP Application to define Reusable Components with Ding

Everything shown here using annotations, is also available by using the XML and YAML bean definition providers, so you are free to use any of the 3 drivers (XML, YAML, Annotations) to define your beans and mix them anyway you like or need to  Read More »

Hooks into the bean lifecycle in the Ding container

Sometimes it's useful (or needed) to have the container call certain methods right before injecting (or giving away) our beans, and right before destructing it, as a way of setup-teardown or init-shutdown. Ding provides a way to execute code in some of the points  Read More »

Ding container: Using the Xml, Yaml, and Annotations drivers

In a previous article I've shown how to download and install the ding container. The article ended with getting a container instance, but didn't show how to actually define and use your beans. So that's what this article is all about.  Read More »

PAGI: Quick telephony applications using AGI and PHP

PAGI is a PHP 5.3 client for AGI: Asterisk Gateway Interface. AGI is a very simple protocol, and it has been implemented in a wide variety of languages, allowing to quickly create telephony applications, like IVR's, voicemails, prepaid telephony systems, etc. If you want or need to create this kind of telephony applications using PHP, you will find PAGI very useful  Read More »

Getting Started with the PAMI: PHP Asterisk Manager Interface = Easy Asterisk Monitoring

PAMI is a PHP 5.3 client for AMI: Asterisk Manager Interface. Asterisk is one of the hot topics in the IT world due to its broad acceptance and use case scenarios.  Read More »

Installing and using the Ding DI Container

Ding is DI (Dependency Injection) container, featuring IoC (Inversion of Control), and AOP ( Aspect Orientend Programming) for PHP 5.3 (actually, it needs >= 5.3.3). It also supports some Event Driven programming too.  Read More »

Writing PHP applications with Doctrine2 as ORM and Ding as DI container

This article will show how we can develop software in php with a nifty design and architecture, and very much like other languages like java, using an ORM and an AOP, DI, Events container.  Read More »

Creating isolated environments for PHP applications with PEAR dependencies

Many times php applications need some special configuration in their ini files (like extra modules, or any option that can be tweaked) and of course different versions of pear packages (some may use a deprecated package, or a special version that fixes some bug, etc)  Read More »

Using DIME with SOAP and PHP

As you may be aware by now, PHP native SOAP implementation does not support DIME transfers (this implies that the one from Zend Framework(tm) does not support them either). Also, the PEAR soap implementation lacks enough documentation to make it work (at least, I couldn´t from the client side.  Read More »

Mocking Global Php 5.3 Functions Using Namespaces

Let´s say you´d like to achieve a 100% coverage of your code in your php application (you obsessive geek..). It´s almost certain you´ll need to start mock´ing things around. So far so good.. but sooner or later you will need to deal with the test cases for the code that use global php functions. How can you mock them?  Read More »

Generating a cross compiler for freebsd in linux

I manage a Hudson CI Server that runs on a linux system where I work, and one of our projects is written in plain C code that should be able to run on linux and also freebsd 7. Up to now we were using a freebsd (hudson) slave node in order to build the freebsd binaries.  Read More »

AMI (Asterisk Manager Interface) Protocol tutorial

The Asterisk Manager Interface (AMI) protocol is a very simple protocol that allows you to communicate and manage your asterisk server, almost completely. It has support to edit/create asterisk configuration files and also manage the calls, clients, agents, dialplan, etc.

You might also be interested in PAMI. An AMI client/framework that allows you to quickly develop ami clients in an oop/event-driven fashion.  Read More »

The Asterisk Gateway Protocol: A practical introduction and tutorial to agi applications

The Asterisk Gateway Protocol (AGI from now on) is the protocol used by the Asterisk server as its interface for telephony applications. AGI is just a way that allows you (as a software developer) to easily make telephony applications that asterisk will run someway along the dialplan.  Read More »

Create VoIP applications for Asterisk using PHP, PAMI, and Ding (Inversion of control and dependency injection in your php telephony applications)

Here, I'll write about AsterTrace (, a simple project that will help you get started using the asterisk manager interface.  Read More »

Bami: A Proof of concept Asterisk Manager Interface (AMI) client written in bash for the Asterisk PBX

In this article I explained the inners of the AMI protocol, and talked about actions, events, and responses. As a complement of that article I wrote (just for fun) a little shell script  Read More »

Una pequeña historia sobre como se viaja en el subte b, apretado y lleno de gente en horario pico hacia el centro

Una mini anecdota/observacion no-tecnica (como para variar un poco.. ), que pueden bypassear tranquilamente :) como todos los dias, afronte la dura realidad de tomar el subte b  Read More »

How to setup nginx to work with FastCGI and different (multiple) PHP versions

Nginx seems to be the new silver bullet nowadays, so I've decided to give it a try. Of course it is fun to get it up and running and serve static content  Read More »

Configuring postfix to forward all email to a smtp gateway

Suppose you want all your web servers to locally send all email (maybe from your contact forms, or whatever) to a real smtp gateway. If you're running postfix as your mta, this is quite easily to achieve.  Read More »

Different SMTP relays in postfix based on regular expressions

So I had this particular situation where a site sends lots of emails to its registered users, and some of those emails go directly to the Spam folder of hotmail, yahoo, or gmail, for various reasons. This was acceptable for the majority of the emails, but some of them were really important (like password resets, registration confirmations, and the like) so the site hired a payed smtp relay to be used for sending *only* those emails  Read More »