This article is a mirror article of machine translation, please click here to jump to the original article.

View: 1552|Reply: 1

AWS creates an API Gateway gateway of the HTTP API type

[Copy link]
Posted on 12/1/2024 12:42:15 PM | | | |
Requirements: Create a gateway on AWS and then use Lambda to add authentication capabilities.

Log in to the AWS console, select the appropriate region according to your situation, and then create an HTTP API gateway as shown in the following figure:



Start a name, then keep next (or directly review and create), set other configurations later, and click Create in the last step, as shown in the figure below:



Below create a route /bbs reverse proxy to this website, fill it out“/bbs/{proxy+}”, the routing method can be selected ANY, which allows all HTTP methods, as shown in the figure below:



After creating the route, select the path and click the Attach Integration button on the right, as shown in the image below:



Select Create and attach an integration as shown in the following image:



Integration type type Select HTTP URI, and fill in the specific reverse proxy URL (https://www.itsvse.com/{proxy}), and finally click Create, as shown below:



Click on the API to view the endpoint address and use postman to test as shown below:



If you don't want to access it publicly, you need to set up Authorization, find the Lambda menu from the AWS backend, and create a function as shown in the figure below:



Give it a name: demo-authentication, select :node.js 22.x version at runtime, choose arm64 for the architecture (the price will be cheaper), and finally click create function, as shown below:



The editor code is as follows:



Click the deploy button on the left, as shown below:



To set the lambda environment variables, click Configuration -> Environment variables -> Edit, as shown in the following figure:

Back to the API Gateway dashboard, select Authorization and click create as shown in the following figure:



Select Attach authorizers to routes to add existing authentications, as shown in the following image:



Try using the postman request interface again and return a 401 status and an error message (Unauthorized), as shown in the figure below:



When we add Authorization information to the request header, the request can be successful, as shown in the figure below:



Reference:

The hyperlink login is visible.
The hyperlink login is visible.

(End)





Previous:The difference between REST API and HTTP API in AWS API Gateway
Next:NPM installs local packages and local dependencies
 Landlord| Posted on 12/1/2024 12:44:32 PM |
Exported configurations




Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com