简体   繁体   中英

How should I send HTTPS request to a third-party api in AWS

I am currently implementing proactive reporting in Alexa and left scratching my head about how to properly implement sending the ChangeReport interface to Alexa. Currently I am just sending the request through a Lambda function, however this seems like it may be an anti-pattern in AWS Lambda .

What I would like to do is have a Lambda function create the proper message payload and then hand the payload off to some AWS service to send the request to the Alexa endpoint. Ideally This would also have a retry policy in place.

What options do I have to send this request? Am I purely limited to Lambda to do this or can I use another AWS service for this?

Currently I am sending the request through a lambda function, which works but might be an anti-pattern. The lambda function is running Node 16 if this is relevant. I experimented with setting this up in SNS and, unfortunately, SNS requires the endpoint to reply with a confirmation upon subscription.

You can send HTTPS requests to a 3rd party API in AWS. There are a few different options you can use:

  1. Amazon Simple Queue Service (SQS)
  2. Amazon Simple Notification Service (SNS)
  3. AWS SDK for Node.js

Option 1 - Amazon Simple Queue Service (SQS)

With SQS, you can create a message containing the HTTPS request and add it to a queue. You can then configure an AWS Lambda function to process messages from the queue and send the HTTPS request.

This allows you to use Lambda to create the message payload and then hand it off to SQS for delivery, and it also gives you the ability to set up a retry policy for failed requests.

Option 2 - Amazon Simple Notification Service (SNS)

With SNS, you can create a message containing the HTTPS request and publish it to a topic. You can then subscribe the third-party API endpoint to the topic, and SNS will automatically deliver the message to the endpoint.

This allows you to use Lambda to create the message payload and then hand it off to SNS for delivery.

Option 3 - AWS SDK for Node.js

AWS SDK provides APIs for making HTTPS requests, and you can use these APIs to send the request directly from your Lambda function.

This allows you to use Lambda to create the message payload and send the HTTPS request in a single step.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM