Lambda / microservice architecture

Hi @jsancho,

Thanks for answering. I think you get me wrong.

This wasn’t an issue, just a statement that using SNS between functions decouples them, which is a good thing :slight_smile:

I thought that was clear. Let me explain, function A has a code that refers to function B’s ARN and invokes/executes function B.

An example from AWS Docs:

var params = {
  FunctionName: 'STRING_VALUE', /* required */
  ClientContext: 'STRING_VALUE',
  InvocationType: Event | RequestResponse | DryRun,
  LogType: None | Tail,
  Payload: new Buffer('...') || 'STRING_VALUE' /* Strings will be Base-64 encoded on your behalf */,
  Qualifier: 'STRING_VALUE'
};
lambda.invoke(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

This is an anti-pattern as you admit :slight_smile:

Anyway, I end up with two functions:

  1. First function is triggered by CloudWatch Event (cron) and loades data from DynamoDB, performs some lookup for each item from db and pushes results for each item to SNS message.
  2. Second function is performing work on payload received from first function via SNS message (loose coupling :exclamation:) and saving results to DynamoDB.

As you can see I resigned from and idea of having separate function for accessing data.