How to deploy Step functions composed of 3 Lambdas using AWS CDK (Typescript)

Install and configure packages

1. Install and Configure the AWS CLI by following the steps mentioned in the below link

https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html#cli-configure-quickstart-config

2. Install NodeJS by the following the instructions in the following link

https://nodejs.org/en/

3. Install the AWS CDK by running the following command

4. Running the following commands to create a directory “aws-cdk-step-functions”, initialize the app “step-functions”, and install the required npm packages

Setup Lambdas

5. Create a folder lambda in the root of your project

6. Create the required lambdas (using your favorite IDE)

a. generateRandomNumber.js – to generate a random number in the given range

b. greater.js – to send the message “greater”

c. lessOrEqual.js – to send message “lessOrEqual”

7. Open the file bin/step-functions.ts and uncomment the following line

8. Now open the file lib/step-functions.ts and modify it so that it looks something like this

Deploy and Test

9. Bootstrap the CDK

10. Synthesize and Deploy the CDK by running the following commands

11. Test the functionality by login into AWS Console > Step functions > randomNumberStateMachine > Start Execution, using the following payload

12. To delete all generated AWS resources, run the following command

References

Rate this post

Leave a Reply