Top AWS Step Functions Interview Questions (2021) | CodeUsingJava
















Most frequently asked AWS Step Functions Interview Questions


  1. What is AWS Step Functions?
  2. What are the components of AWS Step Functions?
  3. Explain the use cases of AWS Step Function?
  4. How to use the AWS Step Functions?
  5. How can we use jsonPath inside array in AWS Step Functions?
  6. Explain Genomics Workflow in AWS?
  7. How does AWS Step Function creates State Machine?
  8. How do we Invoke AWS step function using API gateway?
  9. How can we share data in AWS Step Functions without passing it between the steps?
  10. How can we retry logic in AWS step function?
  11. How can we manage error flow in AWS step-functions?
  12. How can we use AWS Step Function for offloading expotential backoffs?


What is AWS Step Functions?

Amazon Step Functions makes us easy in coordinating all the components of distributed application and microservices using visual workflows.It is used in building applications from individual components which can perform with each other discretly.It easily can helps us in scaling and changing applications easily and quickly, it provides us a way to coordinate components and step up through the functions of our application.AWS Step Function also helps in providing graphical console for arranging and visualizing the components of our application as a series of steps.

What are the components of AWS Step Functions?

Components of AWS Step Functions are as follows:
  • State Machine - State Machine represents the flow we need to achieve the final objects.
  • State - States is used in referring the names inside the State Machine.
  • Task - A tasks is defined as a lambda function where we need to specify the ARN.

Explain the use cases of AWS Step Function?


AWS Step Functions


How to use the AWS Step Functions?

We can use AWS Step Function in 3 ways:
  • AWS Console - AWS Console acts as a small set of blueprints for starting out.
  • AWS Cloud Formation - It is very simple for imlementing and also used for specifying state machine template and service role ARN.
  • AWS SPI/SDK - By using SPI/SDK we can find documentation for each of it as per requirement.

How can we use jsonPath inside array in AWS Step Functions?

We can accept an array as an input by using the following command:
The value for the field 'arrayField.$' must be a STRING that contains a JSONPath but was an ARY


Explain Genomics Workflow in AWS?


AWS Step Functions


How does AWS Step Functions connect and coordinate other AWS services?

AWS Step Function workload is used for creating, connecting and coordinating other AWS Services which are using service tasks.
Example:
Invoking AWS Lambda function.
Running AWS Elastic Container Service.
Submitting Amazon DynamoDB Table.


How does AWS Step Function creates State Machine?


AWS Step Functions


How do we Invoke AWS step function using API gateway?

We can invoke an AWS Step Function by using HTTP API.
'use strict';

const AWS = require('aws');
const stepfunctions = new AWS.StepFunctions();

exports.handler = (event, context, callback) => {
    if(!event && event.action)
        callback("Error: 'action' is required.");
    if(!event && event.params)
        callback("Error: 'params' is required.");
   
    stepfunctions[event.action](event.params, function (err, data) {
        if (err)
            console.log(err, err.stack);
        callback(err, data);
    });
};



How can we share data in AWS Step Functions without passing it between the steps?


AWS Step Functions

initStep helps in getting data and sending it to SQS for external service.
validationWaiting used fro answering from the external service which also includes data.
complete used for handling lambda function and also uses the data from the initStep.


How can we retry logic in AWS step function?

We should have States.ALL while the error is being thrown as Lambda.Unknown instead of States.Timeout.
{
  "StartAt": "Red",
  "States": {
    "Red": {
      "Type": "Task",
      "Resource": "arn:aws:states:::lambda:invoke",
      "Parameters": {
        "FunctionName": "arn:aws:lambda:ap-southeast-2:518815385770:function:errorTest:$LATEST",
        "Payload": {
          "Input.$": "$"
        }
      },
      "Retry" : [
        {
          "ErrorEquals": [ "States.All", "States.Timeout" ],
          "IntervalSeconds": 1,
          "MaxAttempts": 3,
          "BackoffRate": 1.0
        }
      ],
       "Next": "Fail"
    },
    "Fail": {
      "Type": "Fail"
    }


How can we manage error flow in AWS step-functions?

We can manage manage error flow in AWS step function by defining state machine passes execution to NotifyOfError where we are able to mail and sms about the error.
Closure:
  Type: FLOW
  Resource: >-
    arn:aws:lambda:{AWS::Region}:{AWS::AccountId}:function:xxx-services-{opt:stage}-transportClosure
  Next: WaitForCloudWatch
  Catch:
    - ErrorEquals:
        - "States.ALL"
      ResultPath: "$.error-info"
      Next: NotifyOfError


How can we use AWS Step Function for offloading expotential backoffs?


AWS Step Functions