# Invoke an AWS Step Functions workflow from AWS Lambda The pattern creates a Lambda function, and a Step Functions workflow, a Log group and the IAM resources required to run the application. A Lambda function uses the AWS SDK to asyncronously invoke the Step Function workflow, passing the event body. The Step Function workflow showcasing the different States. ![](./images/stepfunctions_graph.png) ## Getting started with Terraform Serverless Patterns Read more about general requirements and deployment instructions for Terraform Serverless Patterns [here](https://github.com/aws-samples/serverless-patterns/blob/main/terraform-fixtures/docs/README.md). ## Testing After deployment, invoke Lambda function with multiple inputs, and go to the Step Function Console and view the different invocations to note the different behavior with the different inputs. To do this, you can run these commands in the terminal (replace `` with the value returned in `lambda_function_name`): ```shell aws lambda invoke --function-name --payload '{"Choice": "A"}' response.json aws lambda invoke --function-name --payload '{"Choice": "B"}' response.json aws lambda invoke --function-name --payload '{"Choice": "C"}' response.json ``` ## Requirements | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 1.0 | | [aws](#requirement\_aws) | >= 4.9 | | [random](#requirement\_random) | >= 2.0 | ## Providers | Name | Version | |------|---------| | [aws](#provider\_aws) | >= 4.9 | | [random](#provider\_random) | >= 2.0 | ## Modules | Name | Source | Version | |------|--------|---------| | [lambda\_function](#module\_lambda\_function) | terraform-aws-modules/lambda/aws | ~> 4.0 | | [step\_function](#module\_step\_function) | terraform-aws-modules/step-functions/aws | ~> 2.0 | ## Resources | Name | Type | |------|------| | [random_pet.this](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet) | resource | | [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source | ## Inputs No inputs. ## Outputs | Name | Description | |------|-------------| | [lambda\_function\_arn](#output\_lambda\_function\_arn) | The ARN of the Lambda Function | | [lambda\_function\_arn\_static](#output\_lambda\_function\_arn\_static) | The static ARN of the Lambda Function. Use this to avoid cycle errors between resources (e.g., Step Functions) | | [lambda\_function\_invoke\_arn](#output\_lambda\_function\_invoke\_arn) | The Invoke ARN of the Lambda Function | | [lambda\_function\_name](#output\_lambda\_function\_name) | The name of the Lambda Function | | [lambda\_function\_qualified\_arn](#output\_lambda\_function\_qualified\_arn) | The ARN identifying your Lambda Function Version | | [lambda\_function\_version](#output\_lambda\_function\_version) | Latest published version of Lambda Function | | [lambda\_role\_arn](#output\_lambda\_role\_arn) | The ARN of the IAM role created for the Lambda Function | | [state\_machine\_arn](#output\_state\_machine\_arn) | The ARN of the State Machine | | [state\_machine\_id](#output\_state\_machine\_id) | The ARN of the State Machine | | [step\_function\_role\_arn](#output\_step\_function\_role\_arn) | The ARN of the IAM role created for the State Machine | | [step\_function\_role\_name](#output\_step\_function\_role\_name) | The name of the IAM role created for the State Machine |