In this step, we will create an AWS Lambda Function that adds all the operands provided in the input payload. We will create this Lambda manually using the console. Later, we will use a full CI/CD pipeline (with the help of AWS CodeStar) to deploy a Lambda function that will provide full arithmetic calculation for our calculator.
We will change the definition of the State machine we copied.
Click Edit
We will see the definition from the previous implementation.
Locate the state.process.operator.add state ( line 31 ) and change its type to Task.
Add a new attribute Resource to state.process.operator.add vand for its value, select the idevelop_basic_calculator Lambda function you have created previously.
Your new definition should look like similar to this:
"state.process.operator.add": {
"Type": "Task",
"Comment": "Performs an addition on the operands provided",
"Next": "state.process.displayResult",
"Resource" : "arn:aws:lambda:ap-southeast-1:272538243902:function:idevelop_basic_calculator"
}
Click Save
If you see an IAM Role warning, you can safely ignore and Click Save anyway
Click Start excution
In the Input section, type
{
"operator" : "add",
"operands" : [
1,
2
]
}
Click Start excution.
If all is well, you should see a successful result
Click tab Excution ouput to see the result of your calculation