Today, we see how use the Step Function for try to create an automation with Lambda.


In AWS console, in the service Step Function, create a new step function and past this code:

Copy to Clipboard

In the startInstances, at the Resource we have specified the arn of our lamda function for start the instances. We create a new lambda function for check the status of instances. In this case, we can che monitoring e know if the instances is started capturing the error (if it’s exist). This is the code for the lambda function checkStatusInstances (we can assing the same role as executeCode).

Copy to Clipboard

In this code is important to see this part:

Copy to Clipboard

If we find a instances not started, we launch an exception (we must define it after the import) captured by the step Function in “Pol Instances Status”. For do this, it’s important to define the arn of our Lambda function checkStatusInterfaces and write this retry:

Copy to Clipboard

What does this part of code do? Capture the exception error of our lambda function “ErrorEquals”: [“instancesNotStarted”], and try to execute the code in 10 seconds “IntervalSeconds”: 10, for a maximum of two times “MaxAttempts”: 2. Now we can decide to do something in case the instances don’t start, for example, we can send at email (we’ll see in the next post). For the moment we capture the error and go to another state (our future sends e-mail). For do this, we have this part of the code:

Copy to Clipboard

So simple to understand.

When we start the execution, we need insert a JSON code. This code is the same as the last post (in our example):

Copy to Clipboard


Let us know if you have solved the problem!

AWS Certified Solutions Architect Official Study Guide:

AWS Certified Solutions Architect Associate Practice Tests:

Recent Tweets

For privacy reasons Twitter needs your permission to be loaded.
I Accept