Selling Partner API on the AWS Cloud

Quick Start Reference Deployment

QS

August 2021
Rugved Dighe, Selling Partner Services team
Andrew Glenn, AWS Integration & Automation team

Visit our GitHub repository for source files and to post feedback, report bugs, or submit feature ideas for this Quick Start.

This Quick Start was created by Amazon.com Services LLC in collaboration with Amazon Web Services (AWS). Quick Starts are automated reference deployments that use AWS CloudFormation templates to deploy key technologies on AWS, following AWS best practices.

Overview

This guide provides instructions for deploying the Selling Partner API (SP-API) Quick Start reference architecture on the AWS Cloud. It is for users who want to set up AWS resources in their AWS account to provide SP-API integration using AWS best practices.

Amazon may share user-deployment information with the AWS Partner that collaborated with AWS on the Quick Start.

Selling Partner API on AWS

This Quick Start deploys SP-API on the Amazon Web Services (AWS) Cloud. It configures an AWS Identity and Access Management (IAM) role to streamline your SP-API onboarding. In addition, it provides a sample AWS Lambda application to demonstrate AWS best practices for SP-API integration. After deployment, input your application’s client identifier, secret, and seller refresh token into the sample application code to test connectivity to SP-API endpoints. For more information, see Post-deployment steps later in this guide.

SP-API is a suite of REST-based APIs providing Amazon Selling Partners programmatic access to their Amazon Seller Central account data. With it, you can build applications that help sellers and vendors manage their Amazon business. You must have a Professional selling plan on Amazon Seller Central and register as a developer to create Seller Central applications.

For more information on SP-API, see the Selling Partner API documentations repository.

AWS costs

You are responsible for the cost of the AWS services and any third-party licenses used while running this Quick Start. There is no additional cost for using the Quick Start.

The AWS CloudFormation templates for Quick Starts include configuration parameters that you can customize. Some of the settings, such as the instance type, affect the cost of deployment. For cost estimates, see the pricing pages for each AWS service you use. Prices are subject to change.

After you deploy the Quick Start, create AWS Cost and Usage Reports to deliver billing metrics to an Amazon Simple Storage Service (Amazon S3) bucket in your account. These reports provide cost estimates based on usage throughout each month and aggregate the data at the end of the month. For more information, see What are AWS Cost and Usage Reports?

Software licenses

No additional licenses are required to use this Quick Start.

Architecture

Deploying this Quick Start with default parameters builds the following SP-API environment in the AWS Cloud.

Architecture
Figure 1. Quick Start architecture for SP-API tutorial on AWS

As shown in Figure 1, the Quick Start sets up the following:

  • An AWS IAM role providing a secure way to interact with SP-API.

  • An AWS Lambda function to use the IAM role to call SP-SPI endpoints.

Planning the deployment

Specialized knowledge

This deployment requires a moderate level of familiarity with AWS services. If you’re new to AWS, see Getting Started Resource Center and AWS Training and Certification. These sites provide materials for learning how to design, deploy, and operate your infrastructure and applications on the AWS Cloud.

This Quick Start assumes familiarity with Selling Partner API. For more information on SP-API, see the Selling Partner API documentations repository.

AWS account

If you don’t already have an AWS account, create one at https://aws.amazon.com by following the on-screen instructions. Part of the sign-up process involves receiving a phone call and entering a PIN using the phone keypad.

Your AWS account is automatically signed up for all AWS services. You are charged only for the services you use.

Technical requirements

Before you launch the Quick Start, review the following information and ensure that your account is properly configured. Otherwise, deployment might fail.

Resource quotas

If necessary, request service quota increases for the following resources. You might need to request increases if your existing deployment currently uses these resources and if this Quick Start deployment could result in exceeding the default quotas. The Service Quotas console displays your usage and quotas for some aspects of some services. For more information, see What is Service Quotas? and AWS service quotas.

Resource This deployment uses

IAM roles

2

AWS Lambda functions

1

Supported AWS Regions

For any Quick Start to work in a Region other than its default Region, all the services it deploys must be supported in that Region. You can launch a Quick Start in any Region and see if it works. If you get an error such as “Unrecognized resource type,” the Quick Start is not supported in that Region.

For an up-to-date list of AWS Regions and the AWS services they support, see AWS Regional Services.

Certain Regions are available on an opt-in basis. For more information, see Managing AWS Regions.

IAM permissions

Before launching the Quick Start, you must sign in to the AWS Management Console with IAM permissions for the resources that the templates deploy. The AdministratorAccess managed policy within IAM provides sufficient permissions, although your organization may choose to use a custom policy with more restrictions. For more information, see AWS managed policies for job functions.

Prepare your Seller Central account

You must have a Professional selling plan on Amazon Seller Central and register as a developer to create Seller Central applications.

Deployment options

This Quick Start provides one deployment option:

  • Deploy SP-API into an existing VPC. This option provisions SP-API in your existing AWS infrastructure.

Deployment steps

Confirm your AWS account configuration

  1. Sign in to your AWS account at https://aws.amazon.com with an IAM user role that has the necessary permissions. For details, see Planning the deployment earlier in this guide.

  2. Make sure that your AWS account is configured correctly, as discussed in the Technical requirements section.

Launch the Quick Start

Each deployment takes about 5 minutes to complete. Sign in to your AWS account, and choose the following option to launch the AWS CloudFormation template.

Deploy Selling Partner API on AWS

View template

  1. Check the AWS Region that’s displayed in the upper-right corner of the navigation bar, and change it if necessary. This Region is where you build the network infrastructure. The template is launched in the us-east-1 Region by default. For more information, see Supported AWS Regions earlier in this guide.

  2. On the Create stack page, keep the default setting for the template URL, and then choose Next.

  3. On the Specify stack details page, change the stack name if needed. When you finish reviewing, choose Next.

  4. On the Configure stack options page, you can specify tags (key-value pairs) for resources in your stack and set advanced options. When you finish, choose Next.

  5. On the Review page, review and confirm the template settings. Under Capabilities, select the two check boxes to acknowledge that the template creates IAM resources and might require the ability to automatically expand macros.

  6. Choose Create stack to deploy the stack.

  7. Monitor the status of the stack. When the status is CREATE_COMPLETE, the SP-API deployment is ready.

  8. To view the created resources, see the values displayed in the Outputs tab for the stack.

Post-deployment steps

Copy the IAM role ARN

  1. Open the AWS IAM console.

  2. In the navigation pane, choose Roles.

  3. Choose the name of the role that you will use to create the application.

  4. Copy the role Amazon Resource Number (ARN).

Register an app on Seller Central

  1. Sign into Seller Central using the credentials that you used to register as a developer.

  2. Choose Develop Apps from the Apps & Services menu.

  3. Choose Add new app client.

  4. On the App registration page, enter an app name.

  5. Choose SP API from the API Type drop-down list.

  6. For IAM ARN, enter the role ARN you copied previously.

  7. Choose the pertinent application roles.

  8. Enter OAuth login and redirect URIs. These parameters are optional for private seller and vendor applications.

  9. Choose Save and exit.

  10. Choose Develop Apps from the Apps & Services menu.

  11. Choose View under LWA credentials for the app you registered previously.

  12. Copy the client identifier and client secret. You will enter these on lines 26 and 27, respectively, of lambda_function.py later.

Obtain seller authorization

Obtain seller authorization using either the website authorization workflow or self authorization. You will enter the refresh token on line 32 of lambda_function.py later.

Edit and test the AWS Lambda function

  1. Open the AWS Lambda console.

  2. In the navigation pane, choose Functions.

  3. Choose the name of the Lambda function created by the Selling Partner API Quick Start.

  4. On the Code tab, choose lambda_function.py in Environment window.

  5. On line 26, enter the client identifier you copied previously.

  6. On line 27, enter the client secret.

  7. On line 32, enter the refresh token you received previously from the seller.

  8. Choose Deploy.

  9. Choose Test.

  10. On the Configure test event dialog box, enter an event name, and choose Create.

  11. Choose Test. The Execution results tab shows the status and details of the test.

Best practices for using SP API on AWS

For more information about SP-API best practices, see the Selling Partner API Developer Guide.

Security

  • Use of an IAM role with permission to call SP-API is a best practice.

  • The temporary credentials received from the IAM role are valid only for one hour.

FAQ

Q. I encountered a CREATE_FAILED error when I launched the Quick Start.

A. If AWS CloudFormation fails to create the stack, relaunch the template with Rollback on failure set to Disabled. This setting is under Advanced in the AWS CloudFormation console on the Configure stack options page. With this setting, the stack’s state is retained, and the instance keeps running so that you can troubleshoot the issue. (For Windows, look at the log files in %ProgramFiles%\Amazon\EC2ConfigService and C:\cfn\log.)

When you set Rollback on failure to Disabled, you continue to incur AWS charges for this stack. Delete the stack when you finish troubleshooting.

For more information, see Troubleshooting AWS CloudFormation.

Q. I encountered a size-limitation error when I deployed the AWS CloudFormation templates.

A. Launch the Quick Start templates from the links in this guide or from another S3 bucket. If you deploy the templates from a local copy on your computer or from a location other than an S3 bucket, you might encounter template-size limitations. For more information, see AWS CloudFormation quotas.

Troubleshooting

Q. I cannot create an app on Seller Central.

A. You must have a Professional selling plan on Amazon Seller Central and register as a developer to create Seller Central applications.

Q. How do I get the refresh token to test the API call?

A. Obtain seller authorization using either the website authorization workflow or self authorization.

Q. I cant see any orders in the API response. What do I do?

A. If you are a third-party developer, you must add the refresh token from the seller to lambda_function.py. For more information, see Post-deployment steps. If you self-authorized your application, the API response will not contain orders.

Q. I sell in multiple marketplaces on Amazon Seller Central, why do I only see orders for a single marketplace?

A. This Quick Start deployment makes a call to get orders in the first marketplace in a seller’s marketplace list. For more information, see Choose your source and target marketplaces.

Customer responsibility

After you successfully deploy this Quick Start, confirm that your resources and services are updated and configured — including any required patches — to meet your security and other needs. For more information, see the AWS Shared Responsibility Model.

Send us feedback

To post feedback, submit feature ideas, or report bugs, use the Issues section of the GitHub repository for this Quick Start. To submit code, see the Quick Start Contributor’s Guide.

Quick Start reference deployments

GitHub repository

Visit our GitHub repository to download the templates and scripts for this Quick Start, to post your comments, and to share your customizations with others.


Notices

This document is provided for informational purposes only. It represents AWS’s current product offerings and practices as of the date of issue of this document, which are subject to change without notice. Customers are responsible for making their own independent assessment of the information in this document and any use of AWS’s products or services, each of which is provided “as is” without warranty of any kind, whether expressed or implied. This document does not create any warranties, representations, contractual commitments, conditions, or assurances from AWS, its affiliates, suppliers, or licensors. The responsibilities and liabilities of AWS to its customers are controlled by AWS agreements, and this document is not part of, nor does it modify, any agreement between AWS and its customers.

The software included with this paper is licensed under the Apache License, version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at http://aws.amazon.com/apache2.0/ or in the accompanying "license" file. This code is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or implied. See the License for specific language governing permissions and limitations.