<p>From your comment above: </p>

<blockquote>
  <p>The main difficult is launch the second lambda with a delay from the
  first one and without doing a pooling constantly</p>
</blockquote>

<p>As using SQS queues are an option for you, you can make <a href="http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/MonitorSQSwithCloudWatch.html" rel="nofollow noreferrer">CloudWatch alarms which can monitor for activity in the queues</a>, and link them up with SNS, which can be used as a trigger for LambdaB.</p>

<p>So, your flow can be:</p>

<pre><code>Lambda1 --&gt; SQS --&gt; CloudWatch metric linked to an alarm --&gt; SNS --&gt; Lambda2
</code></pre>

CC BY-SA 3.0
2017-08-10T12:53:47.473Z
I was testing ClodWatch Events but I'm not able to get a working filter for catching SQS message events . I'll test with Cloudwatch as you suggested
RuBiCK
CC BY-SA 3.0
2017-08-10T13:13:10.570Z
CloudWatch alarms --> SNS --> Lambda works. I run multiple workloads with the same pipeline. However, you need to poll SQS from LambdaB though. No escape from that.  even if you take the S3 route, you need to receive from S3.
Dawny33
CC BY-SA 3.0
2017-08-10T21:40:51.270Z
That solutions seems to work for the subject of this question :) but unfortunately it doesn't fit in my specific needs. I need a delay of 3-4min but `CloudWatch metrics for your Amazon SQS queues are automatically collected and pushed to CloudWatch every five minutes. (Detailed monitoring, or one-minute metrics, is currently unavailable for Amazon SQS.)`
RuBiCK
CC BY-SA 3.0
2017-08-12T14:25:08.993Z
@RuBiCK You can set that in CloudWatch itself, like example `200 messages in queue for 5 minutes` condition will send an alarm only if there were 200 messages in the queue for >= 5 mins
Dawny33
CC BY-SA 3.0
2017-08-10T12:33:16.040Z
2017-08-10T12:33:16.040Z
Dawny33
<p>Use Step Functions. They allow you to coordinate lambda functions and have an inbuilt wait state</p>

CC BY-SA 3.0
2017-08-13T21:17:39.873Z
That's the best method rather than configure more services to achieve the same, definitively
RuBiCK
CC BY-SA 3.0
2017-08-15T17:24:03.243Z
I'm having some problems because when I launch the step function I need get back the first lambda a http response to the api gw call. I was unable to find documentation about if that is possible.
RuBiCK
CC BY-SA 3.0
2017-08-16T06:14:05.380Z
Have you looked at this? https://docs.aws.amazon.com/step-functions/latest/dg/tutorial-api-gateway.html
Robo
CC BY-SA 3.0
2017-08-16T07:26:30.560Z
That's the doc I followed to call step functions from Spi Gateway but it doesn't tell you how to send back a response from a lambda which is executed by a Step function. There are the same question in AWS forum without response
RuBiCK
CC BY-SA 3.0
2017-08-16T07:32:52.930Z
Checkout http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-method-settings-execution-console.html for the possible integration responses. The example uses passthrough but it looks like the gateway doesn't wait for a response it just starts the state machine
Robo
CC BY-SA 3.0
2017-08-16T08:31:35.557Z
That's right. It only returns the arn of the Step Function Launched
RuBiCK
CC BY-SA 3.0
2017-08-12T06:14:33.970Z
2017-08-12T06:14:33.970Z
Robo
<p>I need to launch a LambdaA function and after X minutes I need to launch a LambdaB function with parameters passed from LamdaA</p>

<p>I have testing the following:</p>

<p>APIGW > LambdaA > SQS with delay  > SQS can't trigger lambda functions
APIGW > LambdaA > SNS > trigger LambdaB . In that case I can't add a delay</p>

<p>I need to do it serverless and without constant pooling for a queue or new messages.</p>

<p>Is there any other possibility to trigger a second lambda function with a "big" delay?</p>

CC BY-SA 3.0
2017-08-10T11:43:12.173Z
`with parameters passed from LamdaA` <-- How exactly are you (trying to) achieve this?
Dawny33
CC BY-SA 3.0
2017-08-10T12:27:23.400Z
It depends on the solution. If i use SQS, it's just a json in the payload. Any other solution could be using S3 files for that purpose. I'm not worried about this point. The main difficult is launch the second lambda with a delay from the first one and without doing a pooling constantly ;)
RuBiCK
<amazon-web-services><aws-lambda><serverless>
LambdaA -> delay mins -> lambdaB
RuBiCK
# LambdaA -> delay mins -> lambdaB

(Asked by: username_0 on 2017-08-10)

I need to launch a LambdaA function and after X minutes I need to launch a LambdaB function with parameters passed from LamdaA

I have testing the following:

APIGW > LambdaA > SQS with delay > SQS can't trigger lambda functions
APIGW > LambdaA > SNS > trigger LambdaB . In that case I can't add a delay

I need to do it serverless and without constant pooling for a queue or new messages.

Is there any other possibility to trigger a second lambda function with a "big" delay?

**Tags:** amazon-web-services, aws-lambda, serverless

> **Comments:**
> **username_1**: `with parameters passed from LamdaA` <-- How exactly are you (trying to) achieve this?  
> **username_0**: It depends on the solution. If i use SQS, it's just a json in the payload. Any other solution could be using S3 files for that purpose. I'm not worried about this point. The main difficult is launch the second lambda with a delay from the first one and without doing a pooling constantly ;)  

---

## 2 answers

### Answer by username_2 on 2017-08-12. Score: 5 | Accepted answer

Use Step Functions. They allow you to coordinate lambda functions and have an inbuilt wait state

> **Comments:**
> **username_0**: That's the best method rather than configure more services to achieve the same, definitively  
> **username_0**: I'm having some problems because when I launch the step function I need get back the first lambda a http response to the api gw call. I was unable to find documentation about if that is possible.  
> **username_2**: Have you looked at this? https://docs.aws.amazon.com/step-functions/latest/dg/tutorial-api-gateway.html  
> **username_0**: That's the doc I followed to call step functions from Spi Gateway but it doesn't tell you how to send back a response from a lambda which is executed by a Step function. There are the same question in AWS forum without response  
> **username_2**: Checkout http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-method-settings-execution-console.html for the possible integration responses. The example uses passthrough but it looks like the gateway doesn't wait for a response it just starts the state machine  
> **username_0**: That's right. It only returns the arn of the Step Function Launched  

---

### Answer by username_1 on 2017-08-10. Score: 2

From your comment above: 

The main difficult is launch the second lambda with a delay from the
  first one and without doing a pooling constantly

As using SQS queues are an option for you, you can make CloudWatch alarms which can monitor for activity in the queues, and link them up with SNS, which can be used as a trigger for LambdaB.
So, your flow can be:
Lambda1 --> SQS --> CloudWatch metric linked to an alarm --> SNS --> Lambda2

> **Comments:**
> **username_0**: I was testing ClodWatch Events but I'm not able to get a working filter for catching SQS message events . I'll test with Cloudwatch as you suggested  
> **username_1**: CloudWatch alarms --> SNS --> Lambda works. I run multiple workloads with the same pipeline. However, you need to poll SQS from LambdaB though. No escape from that.  even if you take the S3 route, you need to receive from S3.  
> **username_0**: That solutions seems to work for the subject of this question :) but unfortunately it doesn't fit in my specific needs. I need a delay of 3-4min but `CloudWatch metrics for your Amazon SQS queues are automatically collected and pushed to CloudWatch every five minutes. (Detailed monitoring, or one-minute metrics, is currently unavailable for Amazon SQS.)`  
> **username_1**: @username_0 You can set that in CloudWatch itself, like example `200 messages in queue for 5 minutes` condition will send an alarm only if there were 200 messages in the queue for >= 5 mins  

---

