aws-api-gateway

Validating request path parameter of AWS API gateway?

老子叫甜甜 提交于 2019-11-30 22:24:26
Let's say I have an api with paths / and /{pets} and /{pets}/pet . Now I'm trying to validate the path {pets} parameter so that only path having alphanumerical characters of length 6 will be validated and processed to the backend lambda all others will be rejected. I tried the following swagger schema specifying format and type for the parameter. I even tried using pattern in the schema but it seems to be not working. May I know how can we limit only path parameters of certain IDs. { ...... "/{pets}/pet": { "get": { "consumes": [ "application/json" ], "produces": [ "application/json" ],

Amazon API Gateway : response body is not transformed when the API is called via Postman?

梦想的初衷 提交于 2019-11-30 22:01:44
When executing a testvia the AWS API Gateway console, I see that the output response from the Lambda function is correctly transformed: { "type" : "", "message" : "", "request-id" : "" } See logs below: Tue Sep 06 14:46:06 UTC 2016 : Endpoint request body after transformations: {} Tue Sep 06 14:46:06 UTC 2016 : Endpoint response body before transformations: {"errorMessage":"501stef"} Tue Sep 06 14:46:06 UTC 2016 : Endpoint response headers: {x-amzn-Remapped-Content-Length=0, x-amzn-RequestId=a4540f42-7440-11e6-90ce-214b29fcde38, Connection=keep-alive, Content-Length=26, Date=Tue, 06 Sep 2016

How setup header in Postman for Api Gateway authenticated with Cognito?

被刻印的时光 ゝ 提交于 2019-11-30 21:27:57
I use AWS Identity Pool with Facebook provider to authenticate client. I need to invoke AWS Lambda using Api Gateway. From Cognito, using Facebook token, i received credentials: AccessKeyId, SecretKey and SessionToken. Using this credentials, how should I setup header request to invoke my Lambda? Api Gateway setup (test calls my lambda) I try to call my api, it returns "The security token included in the request is invalid." Thank you! You have to manually set ' x-amz-security-token ' in Postman and pass the token in that header. Please try this for postman: http://docs.aws.amazon.com

How can i call AWS Step Functions by API Gateway? [closed]

早过忘川 提交于 2019-11-30 21:19:42
I would like to know how to make API Gateway call a Step Function and execute it. API Gateway added support for Step Functions currently. Now you can create an AWS Service integration via API Gateway Console. Integration Type: AWS Service AWS Service: Step Functions HTTP method: POST Action Type: Use action name Action: StartExecution Execution role: role to start the execution Headers: X-Amz-Target -> 'AWSStepFunctions.StartExecution' Content-Type -> 'application/x-amz-json-1.0' Body Mapping Templates/Request payload: { "input": "string", "name": "string", "stateMachineArn": "string" } You

Returning binary body and http headers from an AWS lambda through API gateway

删除回忆录丶 提交于 2019-11-30 19:55:47
问题 I have a lambda that needs to return a binary object and some http headers (e.g. content-type) through an api gateway (using lambda integration) OR redirect to another URL. In the binary support examples (e.g. https://aws.amazon.com/blogs/compute/binary-support-for-api-integrations-with-amazon-api-gateway/) the lambda only returns the (base64 of the) binary object (the image). In my case, I also need to return a status code and http headers (or something equivalent). I struggle with how I can

Request validation using serverless framework

霸气de小男生 提交于 2019-11-30 19:34:48
I am using serverless framework for the backend. How can I implement request validation? (do not want to write validation inside lambda functions). To implement request validation using serverless you need to do a couple of things: Include your model/header definitions in your stack, and then tell API gateway to use them for request validation. You'll need to install the following packages: serverless-aws-documentation serverless-reqvalidator-plugin And then you'll need to include them in your serverless.yml : plugins: - serverless-reqvalidator-plugin - serverless-aws-documentation Note: below

Request payload limit with AWS API Gateway

醉酒当歌 提交于 2019-11-30 19:31:16
What is the request-payload limit with AWS API-Gateway? I need to send a JSON payload with base64 encoded files and some other parameters to API Gateway, that will then pass on the payload to AWS Lambda. I could not find AWS documentation regarding this. Vijayanath Viswanathan Maximum payload to API gateway is 10 MB and maximum payload for Lambda is 6 MB, which cannot be increased. Please see API gateway payload limits here Please see Lambda payload limits here But there is an alternative way (a work around) to achieve the same by uploading data to an S3 bucket if your size is more that 10 MB.

How to config the api gateway for the service deployed in private subnet?

China☆狼群 提交于 2019-11-30 19:12:50
I deployed a web service in my private subnet without ELB in public subnet. Now I want to expose it to public. Can I use API gateway as the http proxy to make it public? Anyone knows how to do that? The service has to be public for API Gateway to be able to connect to it. You can use SSL Client certs to restrict access to only API Gateway. Otherwise, API Gateway would not be a good solution to your issue. Update: You can now configure API Gateway to access resources inside a VPC using VPC Link . In addition to @Mark B's excellent answer, you could also consider using a Lambda function as a

AWS Lambda fails to return PDF file

匆匆过客 提交于 2019-11-30 19:09:25
I have created a lambda function using serverless . This function is fired via API Gateway on a GET request and should return a pdf file from a buffer. I'm using html-pdf to create the buffer and trying to return the pdf file with the following command let response = { statusCode: 200, headers: {'Content-type' : 'application/pdf'}, body: buffer.toString('base64'), isBase64Encoded : true, }; return callback(null, response); but the browser is just failing to load the pdf, so I don't know exactly how to return the pdf file directly to the browser. Could'nt find a solution for that. well, I found

How to get the HTTP method in AWS Lambda?

帅比萌擦擦* 提交于 2019-11-30 18:53:20
In an AWS Lambda code, how can I get the HTTP method (e.g. GET, POST...) of an HTTP request coming from the AWS Gateway API? I understand from the documentation that context.httpMethod is the solution for that. However, I cannot manage to make it work. For instance, when I try to add the following 3 lines: if (context.httpMethod) { console.log('HTTP method:', context.httpMethod) } into the AWS sample code of the "microservice-http-endpoint" blueprint as follows: exports.handler = function(event, context) { if (context.httpMethod) { console.log('HTTP method:', context.httpMethod) } console.log(