Catalog API Solution Overview
- Overview
- Pre-requisite steps
- Build lambda layer
- Setup the catalog API invocation process
- Setup SNS message process
- Onboard to the Amazon systems
- Confirm Connectivity
- Process the SNS message
- Testing
Overview
This is a sample solution providing Just Walk Out customers with a sample implementation to interact with the Catalog API
Pre-requisite steps
Create S3 bucket for Lambda layer called my-urllib3-layer-bucket. This allows the lambda functions below to execute correctly. For steps on how to create an S3 follow AWS best practices here. If you select a different bucket name, please make sure to use that value in the subsequent steps
Gather you python version and make sure to replace 3.x with the Python version of your Lambda runtime
Build lambda layer
The solution sample depends on using urllib3 to invoke APIs and therefore you will need to create a lambda layer to enable the solution to work as expected. Follow these steps to build a lambda layer
Step 1 - Create a local directory for the layer content:
macOS
mkdir -p python/lib/python3.x/site-packages
Windows
mkdir python\lib\python3.x\site-packages
Step 2 - Replace 3.x with the Python version of your Lambda runtime (e.g., 3.9, 3.11). Install urllib3 into the layer directory.
macOS
pip install urllib3 -t python/lib/python3.x/site-packages/
Windows
pip install urllib3 -t python\lib\python3.x\site-packages\
Step 3 - Ensure 3.x matches your Lambda runtime. If you need a specific version of urllib3 (e.g., for compatibility with older Python runtimes or OpenSSL versions), specify it:
macOS
pip install urllib3 -t python\lib\python3.x\site-packages\
Windows
pip install "urllib3<1.27" -t python/lib/python3.x/site-packages/
Step 4 - Create a zip archive of the layer content:
macOS
zip -r urllib3_layer.zip python/
Windows
Compress-Archive -Path python -DestinationPath urllib3_layer.zip
- Upload lambda layer file to the S3 bucket
- Upload sample report file sample_report.json stored here This file is needed for testing later in the process
Setup the catalog API invocation process
Run the Invoke_catalog_api template, this will build a lambda that allows you to test the catalog API with a test payload
The template requires the URL for the invoke API, please visit the FAQ section here to get the invoke URL
Setup SNS message process
Run the SQSSetupTemplate to create the SQS and resources needed for the Amazon system to notify you when a catalog upload has been completed. Amazon offers an API method that allows you to get the status of a catalog API which can be seen here here
Note: The template requires the SNS topic ARN. Please visit the FAQ section here to get the SNS topic ARN
Onboard to the Amazon systems
Login to the the Amazon Just Walk Out merchant portal to begin the onboarding process. You can follow the steps for onboarding here
At this point you have completed the authorization to allow your AWS account to call the Catalog API. For any issues you face during the onboarding process please see the FAQ page here or contact the Amazon team.
You can refresh the status in the merchant portal to confirm the subscription is complete
Confirm Connectivity
Run the connectivity test lambda found here. The lambda function takes input for the stores you plan to use the catalog for. You can get the store list by navigating to in the Catalog API setup in the Amazon merchant portal. Sample payload below
{
"storeList": [
"<STORE ID HERE>",
"<STORE ID HERE>"
]
}
Process the SNS message
At this point you have deployed all the resources necessary to run the solution. If you have built your own Lambda to process the SNS message then you can follow the steps on how to setup the trigger here
You can also use the template here to build a sample lambda that will process the message and move the report into a local S3.
Note: This sets up the process where a catalog upload is processed by Amazon and a message is sent from Amazon to your SQS. The Lambda will wake up and proces the SNS message, sample message can be found in here
Make sure to match the environment for the URLs
Testing
You can invoke a catalog upload call and confirm that the results file is stored in the destination bucket. To do that follow these steps
Go to the lambda created in invoke_catalog_api.yaml and modify the payload for the catalog API. You will need to change the value for "store_id": "", to match your store id. The value for the store id is available in the catalog API UI
Execute the lambda by clicking test
If you receive a 201 then you should receive a results file in the destination bucket created in
process_catalog_message template once the upload is completed