Contributions are more than welcome! Please create a branch, commit your code and create a pull request. Please make sure you document your changes, and that you use conventional commit guidelines when commiting.
This repository comprises of two parts:
- A lambda function (
commercetools-lambda
) - A terraform script (
terraform-lambda-sns
)
The lambda function code is needed for the terraform script, and it handles the processing and updating of a product into algolia.
The lambda currently does three things:
- Parse the event and retrieve the commercetools product ID from the SNS message
- Fetch the full product from Commercetools
- Update the product inside algolia using save objects
The lambda currently only supports:
- A product which is created/published in commercetools
The terraform script does three things:
- Create a message queue (SNS) connected to a lambda in AWS
- Create a subscription in commercetools to pass events to the message queue
- Connect the subscription to the queue to the lambda so new products get added to algolia
- AWS account + CLI
- Commercetools account
- Algolia account
- Rename .example.env to .env and add your own values where "XXXX" is specified
-
Rename example.variables.tf to variables.tf, uncomment all lines and add your own values where "XXXX" is specified
-
Ensure you have installed Terraform and configured it for use with AWS
-
Run
terraform init
, thenterraform plan
to ensure the configuration is set up successfully, you will receive a view of everything that will be created. -
Run
terraform apply
to create all of the needed infrastructure on commercetools and AWS.
You can test the lambda event locally using SAM in order to adjust the function to your specific needs. There is a sample event in the root of commercetools-lambda
-
Make sure sam is installed locally
-
In the
commercetools-lambda
directory, runsam local invoke -e example-event.json CommercetoolsLambda
Found in Github issues + projects