Questions tagged with Amazon API Gateway
Content language: English
Sort by most recent
Hello, I tried the following tutorial https://docs.aws.amazon.com/en_us/apigateway/latest/developerguide/api-gateway-create-api-as-simple-proxy-for-http.html. But when I use my own URL for testing purposes I got the following error:
Thu Mar 09 16:16:27 UTC 2023 : Execution failed due to configuration error: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Thu Mar 09 16:16:27 UTC 2023 : Method completed with status: 500
If I look at the certificate, it is not a selfsigned cert, and it is not expired. How can I install that certificate in my AWS API Gateway environment.
It is worth mentioning that the destination port is not the standard (443).
#### What I'm trying to do:
I'm trying to create an API using API Gateway that invokes a Lambda Function. I am trying these objects in AWS using SAM templates and deploying to Cloudformation. I am also trying to make sure that generated documentation (Swagger/OpenApi) appears correctly (specifically for response status code, body, and description). Additionally, my goal is to keep the project simple for myself and my fellow team members who do not work with this technology regularly.
#### How I've done it so far:
I've used `AWS::Serverless::Api` and `AWS::Serverless::Function` within my templates since they provide more features without having to define individual methods within API Gateway. With these tools, I've been able to create the functionality of what I'm trying to achieve along with some (but not all) of the documentation I would like to see.
#### The issue:
Within the documentation of both `AWS::Serverless::Api` and `AWS::Serverless::Function`, I see no reference to Method Responses. As a result, the documentation that is generated does not contain response(s). Not entirely surprising because I'm not defining them in the template, but I have been unsuccessful in finding where they might be defined.
#### What I've tried so far:
I've tried using Documentation Parts, defining the method explicitly, and briefly attempted to use a separate yaml file for the definition body (which I don't want to do). None of these have fixed the issue.
#### Question:
Is there a way to define a response/method response while using only `AWS::Serverless::Api` and `AWS::Serverless::Function` within the template without the use of DefinitionBody or a separate yaml file?
#### Thank you!
Thank you for reading this! I am open to trying new solutions and I'll be happy to share the testing template I've been working with if that helps answer the question.
Anyone else getting a network error in the AWS console when hitting save on an authorizer edit.
```
vendors.js:88608 PATCH https://apigateway.ap-southeast-2.amazonaws.com/v2/apis/0XXXXXXX9/authorizers/dXXXXw net::ERR_FAILED
handleRequest @ vendors.js:88608
<snip>
clickHandler @ vendors.js:6471
edit-attach:1 Access to XMLHttpRequest at 'https://apigateway.ap-southeast-2.amazonaws.com/v2/apis/0XXXXXXX9/authorizers/dXXXXw' from origin 'https://ap-southeast-2.console.aws.amazon.com' has been blocked by CORS policy: Method PATCH is not allowed by Access-Control-Allow-Methods in preflight response.
```
Hi all. I have a Lambda question. I am trying to use the SERP API for some scholar data with a Lambda function. My function is working mostly for the first pull but am getting a connection refused for the follow up loop in my test. should i split up the function into multiple (or put an API gateway)?
It's the commented out line for const additionalcitations and getCitationsFromPaginationUrls that is getting the connection refused. Why is it refusing connection on the second attempt (I can manually go there in my browser…there are no service blocks either)?
(Note I ultimately want to add additionalcitations to citations and return that combined list. What you see here doesn't take that into account as I am trying to debug).
```
import * as https from 'https'; // Importing the 'https' package
export const handler = async (event) => {
const serpapiKey = process.env.serpapikey; // Get the SerpAPI key from environment variables
const url = event.article_cited_by_serapi_link + '&api_key=' + serpapiKey; // Create the URL to make the SerpAPI request with the article_cited_by_serapi_link and API key
const response = await getPage(url); // Call the getPage function with the URL and wait for a response
const {paginationUrls,citations} = await getPaginationUrls(response, url); // Call the getPaginationUrls function with the response and URL to get an array of pagination URLs
//const additionalCitations = await getCitationsFromPaginationUrls(paginationUrls);
//return paginationUrls; // Return the pagination URLs array
return {citations,paginationUrls};
}
const getPage = async (url) => {
return new Promise((resolve, reject) => {
https.get(url, (res) => { // Make an HTTPS GET request to the specified URL using the 'https' package
let data = '';
res.on('data', (chunk) => {
data += chunk; // As data comes in, add it to the data variable
});
res.on('end', () => {
resolve(JSON.parse(data)); // When the response ends, parse the data and resolve the promise with the result
});
}).on('error', (err) => {
reject(err); // If there is an error, reject the promise with the error
});
});
};
//get the list of pagination URLs to later loop through
const getPaginationUrls = async (response, url) => {
let paginationUrls = []; // Create an empty array to hold the pagination URLs
let citations = [];
if (response.serpapi_pagination) { // If the response includes pagination information
const otherPages = response.serpapi_pagination.other_pages; // Get the 'other_pages' object from the pagination information
const numPages = Math.ceil(response.search_information.total_results / 10); // Calculate the number of pages based on the total number of results and the fact that each page shows 10 results
for (let i = 1; i <= numPages; i++) {
paginationUrls.push(`${url}&start=${10*(i-1)}`); // Add a URL to the paginationUrls array for each page, with the appropriate start parameter
}
}
// Extract citations from organic results
if (response.organic_results) {
citations = extractCitations(response);
}
return {paginationUrls,citations}; // Return the paginationUrls array
};
```
I couldn't find any docs explicitly mentioned any cost related to the cache configured for a custom authorizer.
If we have a batch or some program to call 300k records one by one and to send it to REST endpoint one at a time to pull the json response in 500 lines so in that flow what could be the best architecture considering the compute, performance and time to complete and preventing data loss ? And this happens once a month, what are the points to consider and what solution is best considering the OCP and S3 resources are availble and we could add pulsar or Kafka for the second flow.
When receiving the response from rest endpoint we need to be make sure the response is received and synchronously handshake from previous step and the rest response should be pushed to s3 and if any failures that call has to be retried with some mechanism to store and record the processing status.
I need the architecture diagram for the batch program to call for 50k records one by one -> rest endpoint-> receive the rest response in json with 500 lines -> store them in s3
Consider no messages are lost and even when restendpoint is down it should record the status and retry and get the response and pushed to s3 so all this calls are synchronous
What should be the technology stack used in this workflow.
Thanks
I have a question regarding automating the process of creating a dataset, revision, and jobs in data exchange (API) using lambda functions and SAM template. I am trying to achieve this using Boto3, but I am facing an issue during the job creation step where I am unable to locate OpenAPI. Can someone guide me on how to resolve this issue?
I would appreciate any help or suggestions on how to automate this process successfully.
Thank you.
We would like to apply our model validation to multiple content types in proxy integration with lambda functions. This is without specifying a mapping template.
We think it is either achiveable via accepting multiple content type in the request body in "Method Request". Or by rejecting any content type that does not match the specified content types in "Method Request".
We have also tried setting the "passthrough behaviour", but as the integration is a proxy lambda integration, it does not validate the request body.
I have an architecture where two entities are posting data to an API gateway. They both follow their own (different) json schema, API GW then pushes it into Kinesis Stream/Firehose. Should I create a separate stream+firehose for each schema? I understand that I could stream them both into the same Kinesis Stream / Firehose and use a lambda to parse each datapoint and determine how to write each data to s3 however I am afraid of lambda concurrency issues should the velocity of the data spike. What is the best practice in this context?
I have two api gateways. One for test and one for uat.
Uat I added up a personal ipaddress to security group and to resource policy of the api gateway, and i can reach it, for test I done the same but cannot reach that, well actually I do reach it but get a 403 error I think. What is actually happening is when I go to the website and hit the submit button the api gateway should come back with a form but I get a spinning wheel on the website, again it works perfectly in uat, the only difference between the two of them is that test is on a network load balancer and uat is on an application load balancer but that shouldn’t matter since I can get to the website. Please help
Hello, I'm trying to use apigatewayv2 websocket.
Is there a way to save context variables at route:$connect when using Iam authorizer?
My purpose is verify context variables in $connect route and continue using these variables in any other routes.
(To restrict important variables like identityId...)
I know I could do this when using lambda authorizer, with lambda output {context: <any>}.
But when I'm trying to use Iam authorizer, I could not find how to do it.
We have physical gateways deployed all around the country, they've been working for months, and out of the blue they've stopped posting data.
**Our architecture:**
1. nRF thingy91 as the gateway
2. Serverless with API gateway and Lambdas
3. HTTPS POST request from the gateway to the endpoint
4. MongoDB as the database
**Things we've discovered: **
1. Gateways stopped sending data a week ago
2. Testing the gateway, we found that it does post, but receives an error from the backend
2. No changes were made to the backend and no redeployments
3. All gateways have enough data on their sims
4. Serverless offline works
5. Lambdas aren't being invoked, but the API gateway is getting some traffic, though I'm having trouble deciphering what and how exactly
6. CloudWatch shows no new logs
7. Postman doesn't work either
8. Don't see any billing issues
9. Redeploying doesn't resolve the issue
10. Receiving and handling requests works just fine and dandy from our mobile and web apps, which communicate with different endpoints but are under the same stage.