├── .gitmodules ├── .nojekyll ├── .taskcat.yml ├── CODEOWNERS ├── LICENSE.txt ├── NOTICE.txt ├── README.md ├── docs ├── generated │ ├── parameters │ │ └── index.adoc │ ├── regions │ │ └── index.adoc │ └── services │ │ ├── index.adoc │ │ └── metadata.adoc ├── images │ ├── amazon-selling-partner-api-architecture-diagram.png │ ├── amazon-selling-partner-api-architecture-diagram.pptx │ ├── architecture_diagram.png │ ├── aws-quickstart-graphic.png │ └── code-editor.png └── partner_editable │ ├── _settings.adoc │ ├── additional_info.adoc │ ├── architecture.adoc │ ├── deploy_steps.adoc │ ├── deployment_options.adoc │ ├── faq_troubleshooting.adoc │ ├── licenses.adoc │ ├── overview_target_and_usage.adoc │ ├── pre-reqs.adoc │ ├── product_description.adoc │ ├── regions.adoc │ ├── service_limits.adoc │ └── specialized_knowledge.adoc ├── functions ├── packages │ └── ExampleLambda │ │ └── lambda.zip └── source │ └── ExampleLambda │ ├── lambda_function.py │ └── requirements.txt └── templates └── SP_API_IAM_Role.template.yml /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "docs/boilerplate"] 2 | path = docs/boilerplate 3 | url = https://github.com/aws-quickstart/quickstart-documentation-base-common.git 4 | branch = main 5 | -------------------------------------------------------------------------------- /.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-quickstart/quickstart-amazon-selling-partner-api/61f39ce6386c66480da3fa3f0f528d75d7bf8d97/.nojekyll -------------------------------------------------------------------------------- /.taskcat.yml: -------------------------------------------------------------------------------- 1 | project: 2 | name: quickstart-amazon-selling-partner-api 3 | owner: aws-ia-eng@amazon.com 4 | lambda_source_path: functions/source 5 | lambda_zip_path: functions/packages 6 | regions: 7 | - ap-northeast-1 8 | - ap-northeast-2 9 | - ap-south-1 10 | - ap-southeast-1 11 | - ap-southeast-2 12 | - ca-central-1 13 | - eu-central-1 14 | - eu-west-1 15 | - eu-west-2 16 | - eu-west-3 17 | - us-east-1 18 | - us-east-2 19 | - us-west-1 20 | - us-west-2 21 | tests: 22 | selling-partner-api: 23 | regions: 24 | - us-east-2 25 | parameters: 26 | QSS3BucketName: $[taskcat_autobucket] 27 | template: templates/SP_API_IAM_Role.template.yml 28 | 29 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @aws-quickstart/aws_quickstart_team 2 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2016-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | 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 4 | 5 | http://aws.amazon.com/apache2.0/ 6 | 7 | or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # quickstart-amazon-selling-partner-api 2 | ## Deprecation Notice 3 | 4 | :x: This repository is subject to deprecation in Q4 2024. For more details, [please review this announcement](https://github.com/aws-ia/.announcements/issues/1). 5 | 6 | ## This repository has been deprecated in favor of https://github.com/aws-ia/cfn-ps-amazon-selling-partner-api. 7 | ***We will archive this repository and keep it publicly available until May 1, 2024.*** 8 | -------------------------------------------------------------------------------- /docs/generated/parameters/index.adoc: -------------------------------------------------------------------------------- 1 | // placeholder 2 | -------------------------------------------------------------------------------- /docs/generated/regions/index.adoc: -------------------------------------------------------------------------------- 1 | // placeholder 2 | -------------------------------------------------------------------------------- /docs/generated/services/index.adoc: -------------------------------------------------------------------------------- 1 | // placeholder 2 | -------------------------------------------------------------------------------- /docs/generated/services/metadata.adoc: -------------------------------------------------------------------------------- 1 | // placeholder 2 | -------------------------------------------------------------------------------- /docs/images/amazon-selling-partner-api-architecture-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-quickstart/quickstart-amazon-selling-partner-api/61f39ce6386c66480da3fa3f0f528d75d7bf8d97/docs/images/amazon-selling-partner-api-architecture-diagram.png -------------------------------------------------------------------------------- /docs/images/amazon-selling-partner-api-architecture-diagram.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-quickstart/quickstart-amazon-selling-partner-api/61f39ce6386c66480da3fa3f0f528d75d7bf8d97/docs/images/amazon-selling-partner-api-architecture-diagram.pptx -------------------------------------------------------------------------------- /docs/images/architecture_diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-quickstart/quickstart-amazon-selling-partner-api/61f39ce6386c66480da3fa3f0f528d75d7bf8d97/docs/images/architecture_diagram.png -------------------------------------------------------------------------------- /docs/images/aws-quickstart-graphic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-quickstart/quickstart-amazon-selling-partner-api/61f39ce6386c66480da3fa3f0f528d75d7bf8d97/docs/images/aws-quickstart-graphic.png -------------------------------------------------------------------------------- /docs/images/code-editor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-quickstart/quickstart-amazon-selling-partner-api/61f39ce6386c66480da3fa3f0f528d75d7bf8d97/docs/images/code-editor.png -------------------------------------------------------------------------------- /docs/partner_editable/_settings.adoc: -------------------------------------------------------------------------------- 1 | // Change the following attributes. 2 | :quickstart-project-name: quickstart-amazon-selling-partner-api 3 | :partner-product-name: Selling Partner API 4 | // For the following attribute, if you have no short name, enter the same name as partner-product-name. 5 | :partner-product-short-name: SP-API 6 | // If there's no partner, comment partner-company-name. 7 | :partner-company-name: Amazon.com Services LLC 8 | :doc-month: August 9 | :doc-year: 2021 10 | // Uncomment the following "contributor" attributes as appropriate. If the partner agrees to include names, enter contributor names for every line we use. If partner doesn't want to include names, delete all placeholder names and keep only "{partner-company-name}" and "AWS Quick Start team." 11 | //:partner-contributors: Shuai Ye, Michael McConnell, and John Smith, {partner-company-name} 12 | :other-contributors: Rugved Dighe, Selling Partner Services team 13 | //:aws-contributors: Janine Singh, AWS IoT Partner team 14 | :quickstart-contributors: Andrew Glenn, AWS Integration & Automation team 15 | // For deployment_time, use minutes if deployment takes an hour or less, 16 | // for example, 30 minutes or 60 minutes. 17 | // Use hours for deployment times greater than 60 minutes (rounded to a quarter hour), 18 | // for example, 1.25 hours, 2 hours, 2.5 hours. 19 | :deployment_time: 5 minutes 20 | :default_deployment_region: us-east-1 21 | // :parameters_as_appendix: 22 | // Uncomment the following two attributes if you are using an AWS Marketplace listing. 23 | // Additional content will be generated automatically based on these attributes. 24 | // :marketplace_subscription: 25 | // :marketplace_listing_url: https://example.com/ 26 | // Uncomment the following attribute to add a statement about AWS and our stance on compliance-related Quick Starts. 27 | // :compliance-statement: Deploying this Quick Start does not guarantee an organization’s compliance with any laws, certifications, policies, or other regulations. 28 | // Uncomment the following attribute if you are deploying a CDK Quick Start. Make sure to comment out :parameters_as_appendix: also. 29 | // :cdk_qs: 30 | // Uncomment the following attribute if you are deploying a Terraform Quick Start. Make sure to comment out :parameters_as_appendix: also. 31 | // :terraform_qs: 32 | // Uncomment the following two attributes if you are deploying a Terraform Quick Start. Make sure to comment out :parameters_as_appendix: also. 33 | :no_parameters: 34 | // :git_repo_url: https://example.com/ 35 | // Uncomment the following attribute if you are deploying AWS Control Tower. 36 | // :control_tower -------------------------------------------------------------------------------- /docs/partner_editable/additional_info.adoc: -------------------------------------------------------------------------------- 1 | // Add steps as necessary for accessing the software, post-configuration, and testing. Don’t include full usage instructions for your software, but add links to your product documentation for that information. 2 | //Should any sections not be applicable, remove them 3 | 4 | 5 | == Post-deployment steps 6 | // If post-deployment steps are required, add them here. If not, remove the heading 7 | 8 | 9 | === Copy the IAM role ARN 10 | 11 | . Open the https://console.aws.amazon.com/iam/[AWS IAM console]. 12 | . In the navigation pane, choose *Roles*. 13 | . Choose the name of the role that you will use to create the application. 14 | . Copy the role Amazon Resource Number (ARN). 15 | 16 | === Register an app on Seller Central 17 | 18 | . Sign into https://sellercentral.amazon.com/[Seller Central] using the credentials that you used to register as a developer. 19 | . Choose *Develop Apps* from the *Apps & Services* menu. 20 | . Choose *Add new app client*. 21 | . On the *App registration* page, enter an app name. 22 | . Choose *SP API* from the *API Type* drop-down list. 23 | . For *IAM ARN*, enter the role ARN you copied previously. 24 | . Choose the pertinent application roles. 25 | . Enter OAuth login and redirect URIs. These parameters are optional for private seller and vendor applications. 26 | . Choose *Save and exit*. 27 | . Choose *Develop Apps* from the *Apps & Services* menu. 28 | . Choose *View* under LWA credentials for the app you registered previously. 29 | . Copy the client identifier and client secret. You will enter these on lines 26 and 27, respectively, of *lambda_function.py* later. 30 | 31 | === Obtain seller authorization 32 | 33 | Obtain seller authorization using either the https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/developer-guide/SellingPartnerApiDeveloperGuide.md#website-authorization-workflow[website authorization workflow] or https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/developer-guide/SellingPartnerApiDeveloperGuide.md#self-authorization[self authorization]. You will enter the refresh token on line 32 of *lambda_function.py* later. 34 | 35 | 36 | === Edit and test the AWS Lambda function 37 | 38 | . Open the https://console.aws.amazon.com/lambda/[AWS Lambda console]. 39 | . In the navigation pane, choose *Functions*. 40 | . Choose the name of the Lambda function created by the Selling Partner API Quick Start. 41 | //TODO: What's the name of this function? 42 | . On the *Code* tab, choose *lambda_function.py* in *Environment* window. 43 | . On line 26, enter the client identifier you copied previously. 44 | . On line 27, enter the client secret. 45 | . On line 32, enter the refresh token you received previously from the seller. 46 | . Choose *Deploy*. 47 | . Choose *Test*. 48 | . On the *Configure test event* dialog box, enter an event name, and choose *Create*. 49 | . Choose *Test*. The *Execution results* tab shows the status and details of the test. 50 | 51 | == Best practices for using SP API on AWS 52 | // Provide post-deployment best practices for using the technology on AWS, including considerations such as migrating data, backups, ensuring high performance, high availability, etc. Link to software documentation for detailed information. 53 | For more information about SP-API best practices, see the https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/developer-guide/SellingPartnerApiDeveloperGuide.md[Selling Partner API Developer Guide]. 54 | 55 | 56 | == Security 57 | // Provide post-deployment best practices for using the technology on AWS, including considerations such as migrating data, backups, ensuring high performance, high availability, etc. Link to software documentation for detailed information. 58 | 59 | * Use of an IAM role with permission to call SP-API is a best practice. 60 | * The temporary credentials received from the IAM role are valid only for one hour. 61 | 62 | -------------------------------------------------------------------------------- /docs/partner_editable/architecture.adoc: -------------------------------------------------------------------------------- 1 | :xrefstyle: short 2 | 3 | Deploying this Quick Start with default parameters builds the following {partner-product-short-name} environment in the AWS Cloud. 4 | 5 | // Replace this example diagram with your own. Follow our wiki guidelines: https://w.amazon.com/bin/view/AWS_Quick_Starts/Process_for_PSAs/#HPrepareyourarchitecturediagram. Upload your source PowerPoint file to the GitHub {deployment name}/docs/images/ directory in this repo. 6 | 7 | [#architecture1] 8 | .Quick Start architecture for {partner-product-short-name} tutorial on AWS 9 | image::../images/amazon-selling-partner-api-architecture-diagram.png[Architecture] 10 | 11 | As shown in <>, the Quick Start sets up the following: 12 | 13 | * An AWS IAM role providing a secure way to interact with SP-API. 14 | * An AWS Lambda function to use the IAM role to call SP-SPI endpoints. 15 | -------------------------------------------------------------------------------- /docs/partner_editable/deploy_steps.adoc: -------------------------------------------------------------------------------- 1 | === Confirm your AWS account configuration 2 | 3 | . Sign in to your AWS account at https://aws.amazon.com with an IAM user role that has the necessary permissions. For details, see link:#_planning_the_deployment[Planning the deployment] earlier in this guide. 4 | . Make sure that your AWS account is configured correctly, as discussed in the link:#_technical_requirements[Technical requirements] section. 5 | 6 | === Launch the Quick Start 7 | 8 | Each deployment takes about {deployment_time} to complete. 9 | //TODO: Can't find a folder in https://s3.console.aws.amazon.com/s3/buckets/aws-quickstart/?region=us-east-1&tab=objects to make permalinks for deploy and template. 10 | Sign in to your AWS account, and choose the following option to launch the AWS CloudFormation template. 11 | 12 | [cols="3,1"] 13 | |=== 14 | ^|https://fwd.aws/PzJVq?[Deploy Selling Partner API on AWS^] 15 | ^|https://fwd.aws/9gYGW?[View template^] 16 | |=== 17 | 18 | . 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 {default_deployment_region} Region by default. For more information, see link:#_supported_aws_regions[Supported AWS Regions] earlier in this guide. 19 | . On the *Create stack* page, keep the default setting for the template URL, and then choose *Next*. 20 | . On the *Specify stack details* page, change the stack name if needed. When you finish reviewing, choose *Next*. 21 | -------------------------------------------------------------------------------- /docs/partner_editable/deployment_options.adoc: -------------------------------------------------------------------------------- 1 | // Edit this placeholder text to accurately describe your architecture. 2 | 3 | This Quick Start provides one deployment option: 4 | 5 | * *Deploy {partner-product-short-name} into an existing VPC*. This option provisions {partner-product-short-name} in your existing AWS infrastructure. 6 | -------------------------------------------------------------------------------- /docs/partner_editable/faq_troubleshooting.adoc: -------------------------------------------------------------------------------- 1 | // Add any tips or answers to anticipated questions. 2 | 3 | == FAQ 4 | 5 | *Q.* I encountered a *CREATE_FAILED* error when I launched the Quick Start. 6 | 7 | *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*.) 8 | // Customize this answer if needed. For example, if you’re deploying on Linux instances, either provide the location for log files on Linux or omit the final sentence. If the Quick Start has no EC2 instances, revise accordingly (something like "and the assets keep running"). 9 | 10 | WARNING: When you set *Rollback on failure* to *Disabled*, you continue to incur AWS charges for this stack. Delete the stack when you finish troubleshooting. 11 | 12 | For more information, see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/troubleshooting.html[Troubleshooting AWS CloudFormation^]. 13 | 14 | *Q.* I encountered a size-limitation error when I deployed the AWS CloudFormation templates. 15 | 16 | *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 http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cloudformation-limits.html[AWS CloudFormation quotas^]. 17 | 18 | 19 | == Troubleshooting 20 | 21 | *Q.* I cannot create an app on Seller Central. 22 | 23 | *A.* You must have a Professional selling plan on https://sellercentral.amazon.com/[Amazon Seller Central^] and https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/developer-guide/SellingPartnerApiDeveloperGuide.md#registering-as-a-developer[register^] as a developer to create Seller Central applications. 24 | 25 | *Q.* How do I get the refresh token to test the API call? 26 | 27 | *A.* Obtain seller authorization using either the https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/developer-guide/SellingPartnerApiDeveloperGuide.md#website-authorization-workflow[website authorization workflow^] or https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/developer-guide/SellingPartnerApiDeveloperGuide.md#self-authorization[self authorization^]. 28 | 29 | *Q.* I cant see any orders in the API response. What do I do? 30 | 31 | *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 link:#post-deployment_steps[Post-deployment steps]. If you self-authorized your application, the API response will not contain orders. 32 | 33 | *Q.* I sell in multiple marketplaces on Amazon Seller Central, why do I only see orders for a single marketplace? 34 | 35 | *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 https://sellercentral.amazon.com/gp/help/external/G202121600?language=en_US[Choose your source and target marketplaces]. 36 | 37 | -------------------------------------------------------------------------------- /docs/partner_editable/licenses.adoc: -------------------------------------------------------------------------------- 1 | // Include details about any licenses and how to sign up. Provide links as appropriate. If no licenses are required, clarify that. The following paragraphs provide examples of details you can provide. Remove italics, and rephrase as appropriate. 2 | 3 | No additional licenses are required to use this Quick Start. -------------------------------------------------------------------------------- /docs/partner_editable/overview_target_and_usage.adoc: -------------------------------------------------------------------------------- 1 | // Replace the content in <> 2 | // Identify your target audience and explain how/why they would use this Quick Start. 3 | //Avoid borrowing text from third-party websites (copying text from AWS service documentation is fine). Also, avoid marketing-speak, focusing instead on the technical aspect. 4 | 5 | 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. 6 | 7 | -------------------------------------------------------------------------------- /docs/partner_editable/pre-reqs.adoc: -------------------------------------------------------------------------------- 1 | // If no preparation is required, remove all content from here 2 | 3 | ==== Prepare your Seller Central account 4 | 5 | You must have a Professional selling plan on https://sellercentral.amazon.com/[Amazon Seller Central^] and https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/developer-guide/SellingPartnerApiDeveloperGuide.md#registering-as-a-developer[register^] as a developer to create Seller Central applications. 6 | -------------------------------------------------------------------------------- /docs/partner_editable/product_description.adoc: -------------------------------------------------------------------------------- 1 | // Replace the content in <> 2 | // Briefly describe the software. Use consistent and clear branding. 3 | // Include the benefits of using the software on AWS, and provide details on usage scenarios. 4 | 5 | This Quick Start deploys {partner-product-short-name} on the Amazon Web Services (AWS) Cloud. It configures an AWS Identity and Access Management (IAM) role to streamline your {partner-product-short-name} onboarding. In addition, it provides a sample AWS Lambda application to demonstrate AWS best practices for {partner-product-short-name} integration. After deployment, input your application’s client identifier, secret, and seller refresh token into the sample application code to test connectivity to {partner-product-short-name} endpoints. For more information, see link:#_post_deployment_steps[Post-deployment steps] later in this guide. 6 | 7 | https://developer.amazonservices.com/[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. 8 | 9 | For more information on SP-API, see the https://github.com/amzn/selling-partner-api-docs[Selling Partner API documentations repository^]. -------------------------------------------------------------------------------- /docs/partner_editable/regions.adoc: -------------------------------------------------------------------------------- 1 | This Quick Start supports all AWS Regions listed in https://docs.aws.amazon.com/general/latest/gr/rande.html[AWS service endpoints^]. 2 | -------------------------------------------------------------------------------- /docs/partner_editable/service_limits.adoc: -------------------------------------------------------------------------------- 1 | // Replace the in each row to specify the number of resources used in this deployment. Remove the rows for resources that aren’t used. 2 | |=== 3 | |Resource |This deployment uses 4 | 5 | // Space needed to maintain table headers 6 | |IAM roles |2 7 | |AWS Lambda functions |1 8 | |=== 9 | -------------------------------------------------------------------------------- /docs/partner_editable/specialized_knowledge.adoc: -------------------------------------------------------------------------------- 1 | // Replace the content in <> 2 | // For example: “familiarity with basic concepts in networking, database operations, and data encryption” or “familiarity with .” 3 | // Include links if helpful. 4 | // You don't need to list AWS services or point to general info about AWS; the boilerplate already covers this. 5 | 6 | This Quick Start assumes familiarity with Selling Partner API. For more information on SP-API, see the https://github.com/amzn/selling-partner-api-docs[Selling Partner API documentations repository^]. -------------------------------------------------------------------------------- /functions/packages/ExampleLambda/lambda.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-quickstart/quickstart-amazon-selling-partner-api/61f39ce6386c66480da3fa3f0f528d75d7bf8d97/functions/packages/ExampleLambda/lambda.zip -------------------------------------------------------------------------------- /functions/source/ExampleLambda/lambda_function.py: -------------------------------------------------------------------------------- 1 | import json 2 | import boto3 3 | from datetime import datetime, timedelta 4 | 5 | # Importing "requests" library to make HTTPS calls to SP API endpoints 6 | import requests 7 | # Importing requests_aws4auth library to calculate the AWS SigV4 signature and add it to SP API requests 8 | from requests_aws4auth.aws4auth import AWS4Auth 9 | 10 | 11 | def lambda_handler(event, context): 12 | # Calling AssumeRole operation to receive temporary credentials from "SPAPIIAMRole" created through CloudFormation. 13 | client = boto3.client('sts') 14 | aws_account_id = context.invoked_function_arn.split(":")[4] 15 | iamrole = 'arn:aws:iam::'+aws_account_id+':role/SPAPIIAMRole' 16 | response = client.assume_role( 17 | RoleArn= iamrole, 18 | RoleSessionName='SPAPIRoleSession' 19 | ) 20 | # Initializing AccessKey, SecretKey and SessionToken variables to be used in signature signing. 21 | AccessKeyId = response['Credentials']['AccessKeyId'] 22 | SecretAccessKey = response['Credentials']['SecretAccessKey'] 23 | SessionToken = response['Credentials']['SessionToken'] 24 | 25 | # Fetch "client_id" and "client_secret" from your application in Seller Central by clicking on "View" in front of your application ID. 26 | client_id = 'your_application_client_id' 27 | client_secret = 'your_application_client_secret' 28 | 29 | # In order to call an API for a seller, you will need to paste the refresh_token for that particular seller below. You can get refresh token for a seller using OAuth flow. 30 | # Otherwise, you can self-authorize your application by clicking on "Authorize" from the dropdown menu in front of your application ID in seller central. 31 | # Once you click on "Generate Refresh Token", you would be able to receive a refresh token and paste it below. 32 | refresh_token = 'sellers_refresh_token' 33 | 34 | # Create body for calling "api.amazon.com/auth/o2/token" endpoint with grant_type as "refresh_token" 35 | payload = {'grant_type':'refresh_token','client_id':client_id,'client_secret':client_secret,'refresh_token':refresh_token} 36 | 37 | # Call the LWA endpoint to receive access token 38 | lwa = requests.post("https://api.amazon.com/auth/o2/token", data=payload) 39 | 40 | # Uncomment to print out the response of the LWA requests. 41 | #print(lwa.text) 42 | 43 | access_token = lwa.json()['access_token'] 44 | 45 | # Create headers to add to SP API request. Headers should include: content_type and "x-amz-access-token" 46 | headers = {'content-type': 'application/json','Accept': 'application/json','x-amz-access-token':access_token} 47 | 48 | # Create AWS SigV4 signature with temporary credentials received from the above AssumeRole request. 49 | # AWS4Auth library calcuates the signature and creates a canonical string to be added in the "Authorization" header. It also adds x-amz-date and x-amz-security-token to the headers. 50 | # If you want to call the EU or FE endpoint, change region in the parameters to "eu-west-1" or "us-west-2". For more information refer to this link: https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/developer-guide/SellingPartnerApiDeveloperGuide.md#selling-partner-api-endpoints 51 | auth = AWS4Auth(AccessKeyId, SecretAccessKey, 'us-east-1', 'execute-api', 52 | session_token=SessionToken) 53 | 54 | # Make a call to the SP API Sellers API endpoint with headers and AWS Signature Auth 55 | # If you want to call the EU or FE endpoint, change the SP API endpoint to "sellingpartnerapi-eu" or "sellingpartnerapi-fe". For more information refer to this link: https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/developer-guide/SellingPartnerApiDeveloperGuide.md#selling-partner-api-endpoints 56 | sellersResponse = requests.get("https://sellingpartnerapi-na.amazon.com/sellers/v1/marketplaceParticipations", headers=headers, auth=auth) 57 | 58 | # Uncomment to print out the Sellers API request URL. 59 | #print("Request URL: ", sellersResponse.request.url) 60 | 61 | # Uncomment to print out the Headers added to the Sellers API request URL. 62 | #print("Request Headers: ", sellersResponse.request.headers) 63 | 64 | print("Seller participates in the following marketplaces: ", sellersResponse.text) 65 | 66 | # Fetch first marketplace Id from the list of supported marketplaces within the authorized region. 67 | marketplaceId = sellersResponse.json()['payload'][0]['marketplace']['id'] 68 | 69 | # Get timestamp for 2 hours from now to fetch all orders within the last two hours 70 | createdAfter = (datetime.utcnow() - timedelta(hours=2)).isoformat() 71 | 72 | #print(createdAfter) 73 | 74 | # Add parameters for the GetOrders API call 75 | params = {'CreatedAfter': createdAfter, 'MarketplaceIds': marketplaceId} 76 | 77 | # Make a call to the SP API Orders API endpoint with params, headers and AWS Signature Auth 78 | # If you want to call the EU or FE endpoint, change the SP API endpoint to "sellingpartnerapi-eu" or "sellingpartnerapi-fe". For more information refer to this link: https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/developer-guide/SellingPartnerApiDeveloperGuide.md#selling-partner-api-endpoints 79 | ordersResponse = requests.get("https://sellingpartnerapi-na.amazon.com/orders/v0/orders", params=params, headers=headers, auth=auth) 80 | 81 | # Uncomment to print out the Orders API request URL . 82 | #print("Request URL: ", ordersResponse.request.url) 83 | 84 | # Uncomment to print out the Headers added to the Orders API request URL. 85 | #print("Request Headers: ", ordersResponse.request.headers) 86 | 87 | print("Orders from the first Marketplace supported by seller: ", ordersResponse.text) 88 | 89 | return { 90 | 'statusCode': 200, 91 | 'body': json.dumps('Hello from Lambda!') 92 | } 93 | -------------------------------------------------------------------------------- /functions/source/ExampleLambda/requirements.txt: -------------------------------------------------------------------------------- 1 | requests-aws4auth 2 | -------------------------------------------------------------------------------- /templates/SP_API_IAM_Role.template.yml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: '2010-09-09' 2 | Description: This template onboards your AWS account to interact with the Amazon Selling 3 | Partner API. A sample AWS Lambda function is included. (qs-1s617385e) 4 | Parameters: 5 | QSS3BucketName: 6 | AllowedPattern: ^[0-9a-zA-Z]+([0-9a-zA-Z-]*[0-9a-zA-Z])*$ 7 | ConstraintDescription: Quick Start bucket name can include numbers, lowercase 8 | letters, uppercase letters, and hyphens (-). It cannot start or end with a hyphen 9 | (-). 10 | Default: aws-quickstart 11 | Description: Name of the S3 bucket for your copy of the Quick Start assets. 12 | Keep the default name unless you are customizing the template. 13 | Changing the name updates code references to point to a new Quick 14 | Start location. This name can include numbers, lowercase letters, 15 | uppercase letters, and hyphens, but do not start or end with a hyphen (-). 16 | See https://aws-quickstart.github.io/option1.html. 17 | Type: String 18 | QSS3KeyPrefix: 19 | AllowedPattern: ^[0-9a-zA-Z-/]*$ 20 | ConstraintDescription: Quick Start key prefix can include numbers, lowercase letters, 21 | uppercase letters, hyphens (-), and forward slash (/). 22 | Default: quickstart-amazon-selling-partner-api/ 23 | Description: S3 key prefix that is used to simulate a directory for your copy of the 24 | Quick Start assets. Keep the default prefix unless you are customizing 25 | the template. Changing this prefix updates code references to point to 26 | a new Quick Start location. This prefix can include numbers, lowercase 27 | letters, uppercase letters, hyphens (-), and forward slashes (/). End with 28 | a forward slash. See https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html 29 | and https://aws-quickstart.github.io/option1.html. 30 | Type: String 31 | Conditions: 32 | UsingDefaultBucket: !Equals [!Ref QSS3BucketName, 'aws-quickstart'] 33 | Resources: 34 | SPAPIIAMRole: 35 | Type: AWS::IAM::Role 36 | Properties: 37 | AssumeRolePolicyDocument: 38 | Version: '2012-10-17' 39 | Statement: 40 | - Effect: Allow 41 | Principal: 42 | AWS: !Sub "arn:${AWS::Partition}:iam::${AWS::AccountId}:root" 43 | Action: sts:AssumeRole 44 | Condition: {} 45 | Policies: 46 | - PolicyDocument: 47 | Version: '2012-10-17' 48 | Statement: 49 | - Effect: Allow 50 | Action: execute-api:Invoke 51 | Resource: arn:aws:execute-api:*:*:* 52 | PolicyName: SellingPartnerAPI 53 | RoleName: SPAPIIAMRole 54 | LambdaExecutionRole: 55 | Type: AWS::IAM::Role 56 | Properties: 57 | RoleName: SPAPILambdaRole 58 | AssumeRolePolicyDocument: 59 | Version: '2012-10-17' 60 | Statement: 61 | - Effect: Allow 62 | Principal: 63 | Service: lambda.amazonaws.com 64 | Action: sts:AssumeRole 65 | Policies: 66 | - PolicyName: SPDSLambdaPolicy 67 | PolicyDocument: 68 | Version: '2012-10-17' 69 | Statement: 70 | - Sid: VisualEditor0 71 | Effect: Allow 72 | Action: 73 | - sts:AssumeRole 74 | - logs:CreateLogGroup 75 | - logs:CreateLogStream 76 | - logs:PutLogEvents 77 | Resource: '*' 78 | LambdaFunction: 79 | Type: AWS::Lambda::Function 80 | Properties: 81 | Handler: lambda_function.lambda_handler 82 | Role: !GetAtt 'LambdaExecutionRole.Arn' 83 | Code: 84 | S3Bucket: !If 85 | - UsingDefaultBucket 86 | - !Sub '${QSS3BucketName}-${AWS::Region}' 87 | - !Ref QSS3BucketName 88 | S3Key: !Sub '${QSS3KeyPrefix}functions/packages/ExampleLambda/lambda.zip' 89 | Runtime: python3.8 90 | --------------------------------------------------------------------------------