All Projects → aws-samples → example-step-functions-integration-api-gateway

aws-samples / example-step-functions-integration-api-gateway

Licence: other
Example application using the new Step Functions integration with API Gateway. It developers to call API Gateway REST APIs and API Gateway from a Step Functions workflow.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to example-step-functions-integration-api-gateway

Aws Lambda Fastify
Insipired by aws-serverless-express to work with Fastify with inject functionality.
Stars: ✭ 190 (+1017.65%)
Mutual labels:  lambda, api-gateway
yake
A Rake-like DSL for writing AWS Lambda handlers
Stars: ✭ 146 (+758.82%)
Mutual labels:  lambda, api-gateway
Serverless Sinatra Sample
Demo code for running Ruby Sinatra on AWS Lambda
Stars: ✭ 195 (+1047.06%)
Mutual labels:  lambda, api-gateway
Hexaville
The modern serverless web application engine and framework for Swift
Stars: ✭ 123 (+623.53%)
Mutual labels:  lambda, api-gateway
cim
CIM takes the pain out of Infrastructure as Code and CloudFormation
Stars: ✭ 51 (+200%)
Mutual labels:  lambda, api-gateway
Serverless Next.js
⚡ Deploy your Next.js apps on AWS Lambda@Edge via Serverless Components
Stars: ✭ 2,977 (+17411.76%)
Mutual labels:  lambda, api-gateway
Apilogs
Easy logging and debugging for Amazon API Gateway and AWS Lambda Serverless APIs
Stars: ✭ 216 (+1170.59%)
Mutual labels:  lambda, api-gateway
Up
Up focuses on deploying "vanilla" HTTP servers so there's nothing new to learn, just develop with your favorite existing frameworks such as Express, Koa, Django, Golang net/http or others.
Stars: ✭ 8,439 (+49541.18%)
Mutual labels:  lambda, api-gateway
serverless-email-scheduler
Schedule future emails with AWS Lambda and Step Functions
Stars: ✭ 29 (+70.59%)
Mutual labels:  lambda, step-functions
serverless-certificate-creator
serverless plugin to manage the certificate of your lambdas custom domain (API Gateway=
Stars: ✭ 33 (+94.12%)
Mutual labels:  lambda, api-gateway
Hello Lambda
🔥 An example of a Python (AWS) Lambda exposed with API Gateway, configured with Terraform.
Stars: ✭ 114 (+570.59%)
Mutual labels:  lambda, api-gateway
super-serverless-sample
Backend serverless que simula o sistema de votação do BBB
Stars: ✭ 30 (+76.47%)
Mutual labels:  lambda, api-gateway
Serverless Sharp
Serverless image optimizer for S3, Lambda, and Cloudfront
Stars: ✭ 102 (+500%)
Mutual labels:  lambda, api-gateway
Zappa
Serverless Python
Stars: ✭ 11,859 (+69658.82%)
Mutual labels:  lambda, api-gateway
Aws Cli Cheatsheet
☁️ AWS CLI + JQ = Make life easier
Stars: ✭ 94 (+452.94%)
Mutual labels:  lambda, api-gateway
Aws Mobile React Native Starter
AWS Mobile React Native Starter App https://aws.amazon.com/mobile
Stars: ✭ 2,247 (+13117.65%)
Mutual labels:  lambda, api-gateway
Corgi
AWS Lambda / API Gateway native, fast and simple web framework
Stars: ✭ 44 (+158.82%)
Mutual labels:  lambda, api-gateway
Serverless Es Logs
A Serverless plugin to transport logs to ElasticSearch
Stars: ✭ 51 (+200%)
Mutual labels:  lambda, api-gateway
Hands-On-Serverless-Applications-with-Go
Hands-On Serverless Applications with Go, published by Packt.
Stars: ✭ 92 (+441.18%)
Mutual labels:  lambda, api-gateway
shim
HTTP Handler shim for Go projects running on AWS Lambda
Stars: ✭ 64 (+276.47%)
Mutual labels:  lambda, api-gateway

Example Step Functions API Gateway integration

The new Step Functions integration with API Gateway provides an additional resource type, arn:aws:states:::apigateway:invoke and can be used with both Standard and Express workflows. It allows customers to call API Gateway REST APIs and API Gateway.

See this AWS compute blog for more information on the Step Functions service integration with API Gateway.

API Gateway Step Fcuntions service integration

This project contains source code and supporting files for a serverless application that you can deploy with the SAM CLI. It includes the following files and folders:

  • functions - Code for the application's Lambda functions to check the value of buy or sell shares of a stock.
  • statemachines - Definition for the state machine that orchestrates the stock trading workflow.
  • template.yaml - A template that defines the application's AWS resources.

This application creates a mock stock trading workflow which runs on a pre-defined schedule (note that the schedule is disabled by default to avoid incurring charges). It demonstrates the power of Step Functions to orchestrate Lambda functions and other AWS resources to form complex and robust workflows, coupled with event-driven development using Amazon EventBridge.

When the workflow is run, a Lambda function is invoked via a GET request from API Gateway to the /check resource. This returns a random stock value between 1 and 100. This value is evaluated in the Buy or Sell choice step, depending on if it is less or more than 50. The Sell and Buy states use the API Gateway integration to invoke a Lambda function, with a POST method. A stock_value is provided in the POST request body. A transaction_result is returned in the Response Body and provided to the next state. The final state writes a log of the transition to a DynamoDB table.

Deploy the sample application

The Serverless Application Model Command Line Interface (SAM CLI) is an extension of the AWS CLI that adds functionality for building and testing Lambda applications. It uses Docker to run your functions in an Amazon Linux environment that matches Lambda.

To use the SAM CLI, you need the following tools:

To build and deploy your application for the first time, run the following in your shell:

  1. Clone the GitHub repository:
$ git clone https://github.com/aws-samples/example-step-functions-integration-api-gateway.git
$ cd example-step-functions-integration-api-gateway 
  1. Deploy the application resources:
sam build
sam deploy --guided

The first command will build the source of your application. The second command will package and deploy your application to AWS, with a series of prompts:

  • Stack Name: The name of the stack to deploy to CloudFormation. This should be unique to your account and region, and a good starting point would be something matching your project name.
  • AWS Region: The AWS region you want to deploy your app to.
  • Confirm changes before deploy: If set to yes, any change sets will be shown to you before execution for manual review. If set to no, the AWS SAM CLI will automatically deploy application changes.
  • Allow SAM CLI IAM role creation: Many AWS SAM templates, including this example, create AWS IAM roles required for the AWS Lambda function(s) included to access AWS services. By default, these are scoped down to minimum required permissions. To deploy an AWS CloudFormation stack which creates or modified IAM roles, the CAPABILITY_IAM value for capabilities must be provided. If permission isn't provided through this prompt, to deploy this example you must explicitly pass --capabilities CAPABILITY_IAM to the sam deploy command.
  • Save arguments to samconfig.toml: If set to yes, your choices will be saved to a configuration file inside the project, so that in the future you can just re-run sam deploy without parameters to deploy changes to your application.

You can find your State Machine ARN in the output values displayed after deployment.

Manually trigger the workflow from a terminal window:

aws stepfunctions start-execution \
--state-machine-arn <StockTradingStateMachineArnValue>

Cleanup


## Cleanup

To delete the sample application that you created, use the AWS CLI. Assuming you used your project name for the stack name, you can run the following:

```bash
aws cloudformation delete-stack --stack-name sfn-apigw-example2

Resources

See this AWS compute blog for more information on the Step Functions service integration with API Gateway.

See the AWS SAM developer guide for an introduction to SAM specification, the SAM CLI, and serverless application concepts.

Next, you can use AWS Serverless Application Repository to deploy ready to use Apps that go beyond hello world samples and learn how authors developed their applications: AWS Serverless Application Repository main page

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].