Example implementation of Saleor app using AWS Lambda. It provides a serverless, cost-effective way to extend Saleor's API.
By using this approach, you could for example listen to Saleor webhooks about Orders and inject them into your existing ERP system.
This project uses AWS Lambda as compute platform and API Gateway as a proxy. For storing API keys from Saleor, it uses AWS Parameter Store.
Application uses FastAPI and could be easily deployed to AWS Lambda, thanks to the awesome https://github.com/jordaneremieff/mangum project!
- Create AWS Lambda using console or some IaaC tool. Select Python 3.9 as Runtime
- If you want to benefit from saving the API keys in Parameter Store, you need to extend the IAM Execution Role of your lambda function. Here is example policy:
Given, that function uses a prefix of demo.lambda.app
following IAM policy would allow the function to write and read all parameters with this prefix.
You could change the prefix in config.py
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ssm:PutParameter",
"ssm:GetParametersByPath",
"ssm:GetParameters",
"ssm:GetParameter"
],
"Resource": "arn:aws:ssm:<Your Region>:<your AWS Account ID>:parameter/demo.lambda.app*"
},
{
"Effect": "Allow",
"Action": "ssm:DescribeParameters",
"Resource": "*"
}
]
}
- Create API Gateway - use HTTP API type and enable Lambda integration and use
$default
route for Lambda
- Build and deploy lambda
$ ./build.sh
Upload the artifact.zip
to Lambda
You are all set! The app is ready to be connected with Saleor.
- Important! Set up correct path for the lambda handler. It should be set to the
lambda_saleor_app.main.handler
- the object created by Mangum.
The example app exposes all the endpoints needed to act as a proper Saleor App. All you need to do is to enter Saleor Dashboard and install the application using Manifest URL.
Manifest URL is https://<your API gateway URL>/manifest.json
Now once you click to your app name in the Dashboard, you'll see content rendered by the /app
endpoint (the one defined as appUrl
in manifest).
Happy coding!
Crafted with ❤️ by Mirumee Software